var errMsgHeader = "<strong>Some of your information is incorrect or missing: </strong>";
var errMsgFormatEmail = "The email information you entered is not in the proper format for an email address. Please update your information using the following format: Name@companyname.com";
var errMsgMatchEmail = "The email addresses you entered do not match. Please re-enter your email address.";


//Dynamiclly display message instead of refresh the page with asp
function displayText (message, id)
{
		
		var errMsgHeader = "<strong>Some of your informatin is incorrect or missing: </strong>";
		if (document.getElementById) 
		{   doc = document.getElementById(id); 
			doc.innerHTML = ''; 
			doc.innerHTML = message; 
		} 
		else if (document.all)
			{document.all[id].innerHTML =  message}
		else if (document.layers) 
		{	doc = document.layers[id];
			doc.document.open();
	        doc.write(message);
	        doc.close();
		}
		
		
}


//Check field's value for bad words
function chkProf(strField) {

	var wordlist = "fuck|shit|nigger|nigga|niggaz|niggas|bitch|cunt|asshole|pussy|cocksucker|piss|tits|titties|whore|ass";
	wordlistarray = wordlist.split("|");
	var strText = ""
	strText = strField.toLowerCase();
	for(i=0; i<=wordlistarray.length-1; i++)
	{	
		if (strText.indexOf(wordlistarray[i]) != -1)
			{return true;}
	}
	return false;
}


//Check if a field has any thing(include space)
function isblank(svalue)
{	svalue1 = new String(svalue);
	for(var i = 0; i < svalue1.length; i++) 
	{	var c = svalue1.charAt(i);
		if((c != ' ') && (c != '\n') && (c!='\t')) return false;
	} return true;
}
//Check if the email format is correct
function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
//Check if a field's value is integer.
function isInteger (s)
{   var i;
    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {  // Check that current character is number.
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    } return true;
}
function isDigit (c)
{   return (((c >= "0") && (c <= "9")) || (c == ".")) }

//detached file 
function detachedFile(CSSID,Field)
{
	document.getElementById(CSSID).innerHTML="<input type='file' name='"+ Field +"' ID='"+ Field +"'/>"
}

function DisabledField(CheckField,Prefix)
{
        if  (document.getElementById(CheckField).checked==true){
            for (var i=1;i<=12;i++){
            document.getElementById(Prefix+i).disabled=true; 
            document.getElementById(Prefix+i).style.backgroundColor= "#CCCCCC";}  
        }
       else{
            for (var i=1;i<=12;i++){
            document.getElementById(Prefix+i).disabled=false;  
            document.getElementById(Prefix+i).style.backgroundColor= "#FFFFFF";}  
       }
}

function DeleteRecord(actionurl)
{
		var Response = "";
		Response= confirm("Are you sure?");
		if  (Response==true)
			{
			window.location.href=actionurl;
			return false;
			}
}

function ClearField(fname)
{document.getElementById(fname).value="";}

//Stop the cursor after it limit the mas length
function charLimit(fName,Len) {
	if (fName.value.length>=Len) 
	{fName.value=fName.value.substring(0,Len-1);
	 alert("You have reached maximum character")
	}
}
//fName--field name to calculator the number. numUp is to where display the number
function  charCount(fName,numUp) { 
	document.getElementById(numUp).innerHTML=fName.length
}
function charLimitByID(FID,Len) {
	var ChkField=document.getElementById(FID).value;
	if (ChkField.length>=Len) 
	{document.getElementById(FID).value=ChkField.substring(0,Len);
	 alert("You have reached the "+Len+" characters limit")
	}
}


      function getQuery(name)
      {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
      return "";
      else
      return unescape(results[1]);
      }

function confirmMsg()
{
	if (getQuery('status') == "done")
	{document.getElementById("dataForm").style.display ="none";
	document.getElementById("thanks").style.display ="block";
	
	}
	else
	{document.getElementById("dataForm").style.display ="block";
	document.getElementById("thanks").style.display ="none";
	}
}

function autotab(original,destination){
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	document.getElementById(destination).focus()
}

function errorField(ID){
		jQuery('#'+ID+'FN').css({'color': 'red'});
		jQuery('#'+ID).css({'border': '1px solid #f00'});
}

function removeError(ID){
		jQuery('#'+ID+'FN').css({'color': '#482e25'});
		jQuery('#'+ID).css({'border': '1px solid black'});
}
