IE = (document.all)? true:false;
FF = (document.getElementById && !document.all)? true:false;
NS = (document.layers && !document.all)? true:false;
x = 0;
y = 0;

if (IE){
  		document.onmousemove=move;
}
if(NS){
	window.captureEvents(Event.MOUSEMOVE);
   	window.onmousemove=move;
}
if(FF){
   	window.onmousemove=move;
}

function move(e) {
   	if (IE){
       	//x=window.event.clientX + document.body.scrollLeft; 
		//y=window.event.clientY+ document.body.scrollTop; 
		x=window.event.clientX + document.documentElement.scrollLeft;
		y=window.event.clientY + document.documentElement.scrollTop
   	}
	if (NS){
      	x=e.pageX;
		y=e.pageY;
	}
	if (FF){
      	x=e.pageX;
		y=e.pageY;
	}
}

CustomerHelp = [
			"<br><b>Company Name</b> of the <u>Dealer</u> who have registered a product and who disseminates the Promo Code.", 
			"<br><b>Promotional Code</b> is the <u>NUMERIC CODE</u> given to Distributors by Trimble. If you do not have a promotional code please contact your Trimble Distributor.",
		    "<br>Checking this box means you <u>Agree to Join</u> the <b>Customer Rewards Program</b>. Please click <a href='CRLEarnHow.aspx' target='_new'>here</a> to learn more about Customer Rewards Program",
		    ];
			
DealerHelp = [
			"<br><b>Registered Password</b> in your <a href='http://www.trimble.com/mytrimble/' target='_blank' style='color:#3333CC'>MyTrimble</a> Account", 
			"<br>Checking this box means you <u>Agree to Join</u> the Loyalty Program and have access to Microsite",
		    ];


function Help(msg){
	
	if (IE){
	    
		document.all["hlpBox"].style.left = x;
		document.all["hlpBox"].style.top = y;
		document.all["hlpBox"].style.display = "block";
		document.all["hlpBoxContent"].innerHTML = msg;
	}
	if (NS) {
		document.layers("hlpBox").style.left = x;
		document.layers("hlpBox").style.top = y;
		document.layers("hlpBox").style.display = "block";
		document.layers("hlpBoxContent").innerHTML = msg;
	}
	if (FF){
		document.getElementById("hlpBox").style.left = x + 'px';
		document.getElementById("hlpBox").style.top = y + 'px';
		document.getElementById("hlpBox").style.display = "block";
		document.getElementById("hlpBoxContent").innerHTML = msg;
	}
	//alert(x + ' & ' + y);
}

function hideDiv(obj){
	document.getElementById(obj).style.display = "none";
}




function LoadMessage(msg){
    document.getElementById('loadMessage').innerHTML = msg;
}

/*

function ValidateCheckBox(obj, container){
	if(obj.checked){
		document.getElementById(container).style.background = "None";
		document.getElementById(container).style.borderColor = "#999999";
		document.getElementById(container).style.borderWidth = "0px";
		return true;
	}else{
		document.getElementById(container).style.background = "#FFFFCC";
		document.getElementById(container).style.borderColor = "#000000";
		document.getElementById(container).style.borderWidth = "1px";
		return false;
	}
}

function validateTextBox(txtbox, datatype){
	txtbox = txtbox;
	errColor = "#FFFFCC";
	wht = "#FFFFFF";
	errBorder = "#000000";
	bdr = "#999999";
	val = false;
	
	if(txtbox.value==""){
		txtbox.style.background = errColor;
		txtbox.style.borderColor = errBorder;
		val = false;
		
	}else{
		val = true;
		txtbox.style.background = wht;
		txtbox.style.borderColor = bdr;
		
		if(datatype!=null){
			switch (datatype){
				case "INT":
					if (isNaN(txtbox.value)){
						txtbox.style.background = errColor;
						txtbox.style.borderColor = errBorder;
						val = false;
					}
					break;
					
				case "EMAIL":
					if (!emailCheck(txtbox.value)){
						txtbox.style.background = errColor;
						txtbox.style.borderColor = errBorder;
						val = false;
					}
					break;
			}
		}else{
			txtbox.style.background = wht;
			txtbox.style.borderColor = bdr;
			val = true;
		}
		
		
	}
	return val;
}
*/

function validateTextBoxRED(txtbox, datatype){
	txtbox = txtbox;
	errColor = "#FF6262";
	wht = "#FFFFFF";
	errBorder = "#000000";
	bdr = "#999999";
	val = false;
	
	if(txtbox.value==""){
		txtbox.style.background = errColor;
		txtbox.style.borderColor = errBorder;
		val = false;
		
	}else{
		val = true;
		txtbox.style.background = wht;
		txtbox.style.borderColor = bdr;
		
		if(datatype!=null){
			switch (datatype){
				case "INT":
					if (isNaN(txtbox.value)){
						txtbox.style.background = errColor;
						txtbox.style.borderColor = errBorder;
						val = false;
					}
					break;
					
				case "EMAIL":
					if (!emailCheck(txtbox.value)){
						txtbox.style.background = errColor;
						txtbox.style.borderColor = errBorder;
						val = false;
					}
					break;
			}
		}else{
			txtbox.style.background = wht;
			txtbox.style.borderColor = bdr;
			val = true;
		}
		
		
	}
	return val;
}

/*
function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) {
		//alert("Email address seems incorrect (check @ and .'s)")
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	if (user.match(userPat)==null) {
	    // user is not valid
	    //alert("The username doesn't seem to be valid.")
	    return false;
	}
	
	//if the e-mail address is at an IP address (as opposed to a symbolic
	//host name) make sure the IP address is valid. 
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        //alert("Destination IP address is invalid!")
			return false;
		    }
	    }
	    return true;
	}
	// Domain is symbolic name
	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
		//alert("The domain name doesn't seem to be valid.")
	    return false;
	}
	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) {
	   // the address must end in a two letter or three letter word.
	  // alert("The address must end in a three-letter domain, or two letter country.")
	   return false;
	}
	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="This address is missing a hostname!"
	  // alert(errStr)
	   return false;
	}
	// If we've gotten this far, everything's valid!
	return true;
}
*/

function toggleRadioCompany(val, obj){

	if(val=="DEALER")disp = "block";
	else disp = "none";
	
	if (IE){
  		document.all[obj].style.display = disp;
	}
	if(NS){
		document.layers(obj).style.display = disp;
	}
	if(FF){
	   	document.getElementById(obj).style.display = disp;
	}
}

function toggleDivByChk(chk, divName){
    //alert(divName);
    if(chk) document.getElementById(divName).style.display = "block";
    else document.getElementById(divName).style.display = "none";
}

function ClearPromo(fld){
	fld.value = "";
}

function radChecker(fld){
	val = "";
	for (counter = 0; counter < fld.length; counter++){
		if (fld[counter].checked) val = fld[counter].value; 
	}
	return val;
}

