// Function: MM_openBrWindow 
// Description: Opens popup window.
//---------------------------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//---------------------------------------------------------------------------
// Function: validEmail
// Description: Determines whether an email address is in valid format (x@x.xxx)
// Inputs: email - email address to check
// Return Value: true if valid, else false
//---------------------------------------------------------------------------
function validEmail(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('The email address you entered is invalid. Example of valid email address: username@domain.com');
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	if (user.match(userPat)==null) {
    	alert('The email address you entered is invalid. Example of valid email address: username@domain.com');
	    return false;
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
	    	if (IPArray[i]>255) {
	        	alert('The email address you entered is invalid. Example of valid email address: username@domain.com');
			    return false;
		    }
	    }
    	return true;
	}
	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
    	alert('The email address you entered is invalid. Example of valid email address: username@domain.com');
		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) {
	   	alert('The email address you entered is invalid. Example of valid email address: username@domain.com');
	   	return false;
	}
	if (len<2) {
   		var errStr="This address is missing a hostname!";
   		alert('The email address you entered is invalid. Example of valid email address: username@domain.com');
   		return false;
	}
	return true;
}

// Function: selectOption 
// Description: Submits selected category id from side nav.
//---------------------------------------------------------------------------
function selectOption(catOID,selectedForm)
{
    	if (catOID==""){
    	    alert ("Please make a selection.");
    	    return;
    	}
	
    	if (selectedForm=="formShopMen"){
	    document.forms.formShopMen.submit(catOID);
    	}

    	if (selectedForm=="formShopWomen"){
	    document.forms.formShopWomen.submit(catOID);
    	}
	if (selectedForm=="formShopClear"){
	    document.forms.formShopClear.submit(catOID);
    	}
	if (selectedForm=="formShopApparel"){
	    document.forms.formShopApparel.submit(catOID);
    	}
    	if (selectedForm=="formShopMensApparel"){
	    document.forms.formShopMensApparel.submit(catOID);
	}
	if (selectedForm=="formShopWomensApparel"){
	    document.forms.formShopWomensApparel.submit(catOID);
	}
	if (selectedForm=="formShopAccessories"){
	    document.forms.formShopAccessories.submit(catOID);
    	}
}

// Function: selectOption 
// Description: Submits selected category id from side nav.
// Determines whether the string is blank (empty string or string of spaces)
// Return true if blank, else return false;
//---------------------------------------------------------------------------
function isBlank(inputStr) {
	if( inputStr == '' ) return true;
	for(var i=0; i<inputStr.length; i++ ) {
		if( inputStr.charAt(i) != ' ' ) return false;
	}
	return true;
}
