var message="";

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")

var ns6=document.getElementById&&!document.all?1:0
var head="display:''"
var folder=''

function expandit(curobj){
folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
if (folder.display=="none")
folder.display=""
else
folder.display="none"
}

var user;
var domain;
var suffix;
var aa;
var bb;
function jemail(user, domain, suffix,aa,bb)
{
document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '" class="'+aa+'" title="'+bb+'">' + user + '@' + domain + '.' + suffix + '</a>');
}


function checkEmailValid(emailStr,msg)
{
	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 errMsg="";   
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
	{
	   errMsg=errMsg+"The "+msg+"email address seems incorrect!";
	   return errMsg;
	}
	else
	{
	  var user=matchArray[1]
	  var domain=matchArray[2]
	  if (user.match(userPat)==null) 
	  {
		errMsg=errMsg+"The "+msg+"email address seems incorrect!";
		return errMsg;       
	  }
	  var IPArray=domain.match(ipDomainPat)
	  if (IPArray!=null) 
	  {
		  for (var i=1;i<=4;i++) 
			  {
			if (IPArray[i]>255) 
				{
				errMsg=errMsg+"The "+msg+"email address seems incorrect!";
				return errMsg;
				}//IF
			  }//for
	   }//IP Array
	   var domainArray=domain.match(domainPat)
	   if (domainArray==null) 
	   {
		 errMsg=errMsg+"The "+msg+"email address seems incorrect!";
		 return errMsg;
	   }
	   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>3) 
	   {
		 errMsg=errMsg+"The "+msg+"email address seems incorrect!";
		 return errMsg;	
	   } 
	   if (len<2) 
	   {
		 errMsg=errMsg+"The "+msg+"email address seems incorrect!";
		 return errMsg;	 
	   } 
	 }//End  Match
	return "0";
}



function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

function WholeNumberOnly(opt,msg)
{
	var pos=opt.value.indexOf(".")
	if  (pos>0)
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value=opt.value.substr(0,opt.value.length-1);
		opt.focus();
	  }	 
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value=opt.value.substr(0,opt.value.length-1);
		opt.focus();
	  }
}

function WholeNumberOnlyEmpty(opt,msg)
{
	var pos=opt.value.indexOf(".")
	if  (pos>0)
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value="";
		opt.focus();
	  }	 
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value="";
		opt.focus();
	  }
}

function TinyIntOnly(opt,msg)
{
	if(opt.value>255)
	{
		alert("The "+msg+" can not be greater than 255!");
		opt.value="";
		opt.focus();
	}
}

function NumericOnly(opt,msg)
{
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be numbers!"); 
		opt.value=opt.value.substr(0,opt.value.length-1);
		opt.focus();
	  }
}

function NumericOnlyEmpty(opt,msg)
{
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be numbers!"); 
		opt.value="";
		opt.focus();
	  }
}

function SetZero(opt)
{
	if  (opt.value=="")
	  {
		opt.value=0;
	  }
}

function SetBlank(opt)
{
	if  (opt.value=="0")
	  {
		opt.value="";
	  }
}
function changeBorder(obj)
{
	var thing=""
	thing = obj.name

	obj.className="fotgal";
	document.frmData.lngSelImageId.value=thing;
	
	for (counter = 0; counter < document.images.length; counter++)
	{
		if(document.images[counter].name!=thing)
		{
			document.images[counter].className="";
		}
	}
}

function checkCustomerSign()
{
	var e=document.frmData.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	else
	{
		if (checkEmailValid(e)!="0")
		{
			alert(checkEmailValid(e,''));
			return false;	
		} 
	}
	if(document.frmData.strPassword.value=="")
	{
		alert("Please enter your password!");
		return false;
	}
	return true;
}

function checkRePassword()
{
	var e=document.frmData.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	else
	{
		if (checkEmailValid(e)!="0")
		{
			alert(checkEmailValid(e,''));
			return false;	
		} 
	}
	return true;
}

function checkRegister()
{
	var fname=document.frmData.strFirstName.value;
	if (fname=="" || fname==" " || fname=="-" || fname=="_" || fname==".")
	{
		alert("Please enter your first name!");
		return false;
	}
	var lname=document.frmData.strLastName.value;
	if (lname=="" || lname==" " || lname=="-" || lname=="_" || lname==".")
	{
		alert("Please enter your last name!");
		return false;
	}
	
	var pw=document.frmData.strPassword.value;
	var cfpw=document.frmData.strConfPassword.value;
	var e=document.frmData.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	if (checkEmailValid(e)!="0") 
	{
		alert(checkEmailValid(e,'your'));
		return false;	
	}
	if((pw=="" || pw==" " || pw=="-" || pw=="_" || pw==".") && (pw=="" || pw==" " || pw=="-" || pw=="_" || pw=="."))
	{
		alert("Please enter your password!");
		return false;
	}
	if((cfpw=="" || cfpw==" " || cfpw=="-" || cfpw=="_" || cfpw==".") && (cfpw=="" || cfpw==" " || cfpw=="-" || cfpw=="_" || cfpw=="."))
	{
		alert("Please confirm your password!");
		return false;
	}
	if(pw!=cfpw)
	{
		alert("Your password and confirm password do not match!")
		return false;
	}

	
	var tel=document.frmData.strTelephone.value;
	if (tel=="" || tel==" " || tel=="-" || tel=="_" || tel==".")
	{
		alert("Please enter your telephone number!");
		return false;
	}
	var addr=document.frmData.strAddress.value;
	if (addr=="" || addr==" " || addr=="-" || addr=="_" || addr==".")
	{
		alert("Please enter your address!");
		return false;
	}
	var city=document.frmData.strCity.value;
	if (city=="" || city==" " || city=="-" || city=="_" || city==".")
	{
		alert("Please enter your city!");
		return false;
	}
	var zip=document.frmData.strPostal.value;
	if (zip=="" || zip==" " || zip=="-" || zip=="_" || zip==".")
	{
		alert("Please enter your zip/postal!");
		return false;
	}
	if(document.frmData.lngCountryId.value=="0")
	{
		alert("Please select a country!");
		return false;
	}	
	return true;
}


function checkShirtProduct()
{
	if(document.frmData.strQuantity.value=="0")
	{
		alert("Please enter a quantity!");
		return false;
	}
	return true;
}
function checkShirtOption()
{
	if(document.frmData.strQuantity.value=="0")
	{
		alert("Please enter a quantity!");
		return false;
	}
	return true;
}

function checkMeasure()
{
	var neck=document.frmMeasure.strBNeck.value;
		if (neck=="0")
		{
			alert("Please enter your Neck Size!");
			return false;
		}
		
	return true;
}

function checkContactUs()
{
	if (document.frmData.strContactName.value=="" || document.frmData.strContactName.value==" " || document.frmData.strContactName.value=="-" || document.frmData.strContactName.value=="_" || document.frmData.strContactName.value==".")
	{
		alert("Please enter your contact name!");
		return false;
	}
	var e=document.frmData.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	if (checkEmailValid(e)!="0") 
	{
		alert(checkEmailValid(e,''));
		return false;	
	}
	if (document.frmData.strMessage.value=="" || document.frmData.strMessage.value==" " || document.frmData.strMessage.value=="-" || document.frmData.strMessage.value=="_" || document.frmData.strMessage.value==".")
	{
		alert("Please enter your message!");
		return false;
	}	
	return true;
}
function checkCheckOut()
{

		alert("Please enter your first name!");

	var fname=document.frmData.strFirstName.value;
	if (fname=="" || fname==" " || fname=="-" || fname=="_" || fname==".")
	{
		alert("Please enter your first name!");
		return false;
	}
	var lname=document.frmData.strLastName.value;
	if (lname=="" || lname==" " || lname=="-" || lname=="_" || lname==".")
	{
		alert("Please enter your last name!");
		return false;
	}
	
	var pw=document.frmData.strPassword.value;
	var cfpw=document.frmData.strConfPassword.value;
	var e=document.frmData.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	if (checkEmailValid(e)!="0") 
	{
		alert(checkEmailValid(e,'your'));
		return false;	
	}
	if((pw=="" || pw==" " || pw=="-" || pw=="_" || pw==".") && (pw=="" || pw==" " || pw=="-" || pw=="_" || pw=="."))
	{
		alert("Please enter your password!");
		return false;
	}
	if((cfpw=="" || cfpw==" " || cfpw=="-" || cfpw=="_" || cfpw==".") && (cfpw=="" || cfpw==" " || cfpw=="-" || cfpw=="_" || cfpw=="."))
	{
		alert("Please confirm your password!");
		return false;
	}
	if(pw!=cfpw)
	{
		alert("Your password and confirm password do not match!")
		return false;
	}

	
	var tel=document.frmData.strTelephone.value;
	if (tel=="" || tel==" " || tel=="-" || tel=="_" || tel==".")
	{
		alert("Please enter your telephone number!");
		return false;
	}
	var addr=document.frmData.strAddress.value;
	if (addr=="" || addr==" " || addr=="-" || addr=="_" || addr==".")
	{
		alert("Please enter your address!");
		return false;
	}
	var city=document.frmData.strCity.value;
	if (city=="" || city==" " || city=="-" || city=="_" || city==".")
	{
		alert("Please enter your city!");
		return false;
	}
	var zip=document.frmData.strPostal.value;
	if (zip=="" || zip==" " || zip=="-" || zip=="_" || zip==".")
	{
		alert("Please enter your zip/postal!");
		return false;
	}
	if(document.frmData.lngCountryId.value=="0")
	{
		alert("Please select a country!");
		return false;
	}	
	return true;
}
function checkAgentForgotPWD()
{
	var e=document.frmData.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	else
	{
		if (checkEmailValid(e)!="0")
		{
			alert(checkEmailValid(e,''));
			return false;	
		} 
	}
	return true;
}
function checkAgentSignIn()
{
	var un=document.frmData.strUserName.value;
	if(un=="" || un==" ")
	{
		alert("Please enter your login name!");
		return false;
	}
	if(document.frmData.strPassword.value=="")
	{
		alert("Please enter your password!");
		return false;
	}
	return true;
}
function checkSendOrder()
{
	if (document.frmSend.strContactName.value=="" || document.frmSend.strContactName.value==" " || document.frmSend.strContactName.value=="-" || document.frmSend.strContactName.value=="_" || document.frmSend.strContactName.value==".")
	{
		alert("Please enter your contact name!");
		return false;
	}
	var e=document.frmSend.strEmail.value;
	if(e=="" || e==" ")
	{
		alert("Please enter your email address!");
		return false;
	}
	if (checkEmailValid(e)!="0") 
	{
		alert(checkEmailValid(e,''));
		return false;	
	}
	if (document.frmSend.strMessage.value=="" || document.frmSend.strMessage.value==" " || document.frmSend.strMessage.value=="-" || document.frmSend.strMessage.value=="_" || document.frmSend.strMessage.value==".")
	{
		alert("Please enter your requirement!");
		return false;
	}	
	return true;
}
