document.observe("dom:loaded", function(e){
		$('mainNav').dropnav();
});

if (document.images){
	path = 'http://levi-uat04.uat.gsipartners.com/images/header/';
	header_search_on = new Image();header_search_on.src = path + "header_search_on.jpg";
	header_search = new Image();header_search.src = path + "header_search.jpg";
}

function clearSearchBox(obj){
	if ($(obj).value=='KEY WORD OR NUMBER'){
		$(obj).value = '';
		$(obj).style.textAlign='left';
	}
}
				
function emailSignupPopup(){
	if ($('emailSignupPopup').style.display == 'none'){
		$('emailSignupPopup').style.display = '';
		// Check to see if the form doesn't exist.  If so, then the form has already been submitted and we need to trigger the rollup animation.
		//if(window.frames['emailSignUpiframe'].document.body.innerHTML.indexOf('ValidateEForm(this)') == -1){
			//$('email_closeBtn').style.display = "none";
			//setTimeout("animateHide()", 2500);
		//}
	}else{
		// Refresh on hide rather than show to hide page flip...
		//$('emailSignUpiframe').src = 'http://levi-uat04.uat.gsipartners.com/include/entry.jsp';
		//window.frames['emailSignUpiframe'].location.reload(true);	
		$('emailSignupPopup').style.display = 'none';
	}
}

function validEmail(){
	var str=document.emailForm.emailAddress.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		return true
	}else{
		return false;
	}
}

var genderCheck = -1;

function validateGender(){
	for (i=0; i<document.emailForm.gender.length; i++){
		if (document.emailForm.gender[i].checked){
			genderCheck = i;
		}
	}
	if (genderCheck == -1){
		return false;
	}else{
		return true;
	}
}

function ValidateEForm(frm){
	if (!validEmail()){
		$("formContent").innerHTML = '<div id="subTitle" class="error">Sorry!</div><div id="blurb" class="error">Please enter a valid email address.<br /><br /></div>'
		return false;
	}else{
		document.emailForm.submit();
		return false;
	}
}

// Animation stuff...
var currHeight = 215;
var rollup;
var rollupRate = 2;

function animateHideTrigger(){
	$('email_closeBtn').style.display = "none";
	setTimeout("animateHide()",2500);
}

function animateHide(){
	currHeight = 215;
	rollupRate = 2;
	rollUp = setInterval("rollUpAnimation()", 10);
	$('emailSignupPopup').style.overflow = 'hidden';
}

function rollUpAnimation(){
	rollupRate += 2;
	currHeight -= rollupRate;
	if(currHeight < 1){
		clearInterval(rollUp);
		// Reset the div to the original settings (so it displays again if opened)
		$('emailSignupPopup').style.display = 'none';
		$('emailSignupPopup').style.height = '215px';
	}else{
		$('emailSignupPopup').style.height = currHeight + 'px';
	}
}	
// End Animation stuff...

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function remoteTest(){
	alert('remoteTest triggered');
}