function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externalLinks; 

function fieldMaskFocus(field, mask)
{
	if(field.value==mask)
		field.value='';	
}

function fieldMaskBlur(field, mask)
{
	if(field.value=='')
		field.value=mask;	
}

// HELP FUNCTIONS

function movehelpdiv(evt,helpdivid)
{
	poisitionhelp(evt,helpdivid);

}

function showhelpdiv(helpdivid)
{
	document.getElementById(helpdivid).style.display="block";


}

function hidehelpdiv(helpdivid)
{
	document.getElementById(helpdivid).style.display="none";
}

function poisitionhelp(e,helpdivid) {
		  var posx = 0;
		  var posy = 0;
		 
	//	  if (!e) var e = window.event;
		  
		  if (e.pageX || e.pageY)       
		  {
				posx = e.pageX;
				posy = e.pageY;


		  }
	
		  else if (e.clientX || e.clientY) {
				posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			//	posx = e.clientX + document.body.scrollLeft; //+ document.body.scrollLeft;
			//	posy = e.clientY + document.body.scrollTop; //+ document.body.scrollTop;
		}
	
	

	document.getElementById(helpdivid).style.position="absolute";
	document.getElementById(helpdivid).style.top=(posy-20)+"px";
	document.getElementById(helpdivid).style.left=(posx+20)+"px";
}


// VALIDATION FUNCTIONS
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
ValidationTypes=new Object();
ValidationTypes.HolderNames="[a-zA-Z'-]{1,50}";
ValidationTypes.Email= "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
ValidationTypes.BankName="[a-zA-Z0-9'-]{1,35}";
ValidationTypes.Name= "[a-zA-Z'-]{1,35}";
ValidationTypes.CardNo= "[0-9]{13,19}";
ValidationTypes.WebReference= "[0-9]{3}-[0-9]{3}-[0-9]{3}";
function getErrorMessages(errkey)
{
	xmlDoc=null;
	try {  xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); }
	catch(e)
  	{
  		try {xmlDoc=document.implementation.createDocument("","",null);}
  		catch(e) {alert(e.message)}
	}
	try 
  	{
  		xmlDoc.async=false;
  		xmlDoc.load("../brand.config");  
  	}
	catch(e) {alert(e.message)}
	var errmsg="";
	var errmsgs = null;
	errmsgs=xmlDoc.getElementsByTagName("ErrorMessage");	
	for (i = 0; i < errmsgs.length; i++) 
	{
		var n = errmsgs[i];
		var src = n.getAttribute("key"); 
		if (src==errkey) 
		{ 
			errmsg=n.firstChild.nodeValue; 
		}
	}
//alert(xmlDoc.getElementsByTagName("ErrorMessage").length)
xmlDoc=null;
errmsgs = null;
	return errmsg;
}
function regmatch(regrule,strvalue)
{
    var re = new RegExp(regrule);
    var m = re.exec(strvalue);
      if (m == null) 
        {return false;}
      else 
        {return true;}
}
function emailcheck(sender, args)
{
if(args.Value.trim().length<1)
   { 
    args.IsValid=false;
    document.getElementById("valEmail").firstChild.nodeValue=getErrorMessages("PROPOSER.EMAIL.REQ");
   }
else
{
    if(regmatch(ValidationTypes.Email,args.Value.trim()))
    {
        args.IsValid=true;
    }
    else
    {
        args.IsValid=false;
        document.getElementById("valEmail").firstChild.nodeValue=getErrorMessages("PROPOSER.EMAIL.VALID")
    }
}
 

if(args.IsValid)

{stylediv("EmailWrapper","RowControl")}

else

{{stylediv("EmailWrapper","RowControlErr")}

}

return;

}

function stylediv(divname,classname)

{

document.getElementById(divname).setAttribute("className",classname);

}
//SHOW & HIDE QUOTATIONS
function showdiv()
    {
    if(document.getElementById("ShowQuoteControl").style.display=="none")
       document.getElementById("ShowQuoteControl").style.display="block"; 
    else
        document.getElementById("ShowQuoteControl").style.display="none";
    }
    function hidediv()
    {
    document.getElementById("ShowQuoteControl").style.display="none";
    }