function clearField(el) {
	if (el.defaultValue==el.value) el.value = ""
}

function makePassword(o){
	o.value="";
	//o.setAttribute("type", "password");
	//alert(o.type);
}

var to; // timeout var

function openNav(me){
//alert(me+"open");
//document.getElementById('subnav').style.visibility='visible';
try{
	document.getElementById('in-section').style.display='none';
}
catch(e){}
document.getElementById('sub-play').style.display='none';
document.getElementById('sub-stay').style.display='none';
document.getElementById('sub-features').style.display='none';
document.getElementById('sub-special-offers').style.display='none';
document.getElementById('sub-'+me).style.display='block';
}

function closeNav(me,on){
//alert(me);
//document.getElementById('subnav').style.visibility='hidden';
try{
	document.getElementById('in-section').style.display='block';	
}
catch(e){}
	document.getElementById('sub-'+me).style.display='none';
//if((on!="home")&&(on!=null)) document.getElementById('sub-'+on).style.display='block';
}

function stayOpenNav(me){
clearTimeout(to);
//document.getElementById('subnav').style.visibility='visible';
try {
	document.getElementById('in-section').style.display='none';
}
catch(e){}
	document.getElementById(me).style.display='block';
}

function delaykillNav(id,page) {
	clearTimeout(to);
	to = window.setTimeout(function(){
		killNav(id,page)
	},3000);
}

function killNav(me,on){
//alert(me+"kill");
//document.getElementById('subnav').style.visibility='hidden';
try {
	document.getElementById('in-section').style.display='block';
}
catch(e){}
	document.getElementById(me).style.display='none';
//if((on!="home")&&(on!=null)) document.getElementById('sub-'+on).style.display='block';
}

function launchSearch(me){
	document.location.href="/vegas/play/"+me+"/index.jsp";
}

function launchDining(me){
	window.open("/vegas/play/dining/recipe.jsp?chef=/xml/recipes/"+me+".xml","recipe",'height=600,width=500,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}
function launchBrochure(me){
	document.location.href="/vegas/features/experience-vegas/"+me+".jsp";
}


//andrews - 120505 - to be used for main page flash pieces.  this way, you have control
//over the URL without having to get a new SWF exported every time.
// 120505 - URL for New Year's in Vegas: /vegas/play/shows/index.jsp
function flashLauncher(){
	document.location.href="/vegas/play/shows/index.jsp";
}

function launchPage(me){
	window.open(me,'popup','height=600,width=500,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}
// new open win function; ditch launchPage later
// u = url, n = target window name, h = height, w = width
function openWin(u,n,h,w){
	//console.log(u + " " + n + " " + h + " " + w);
	window.open('' + u + '','' + n + '','height=' + h + ',width=' + w + ',top=0,left=0,x=0,y=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes')
	}	

function mapsOpener(map){
	var h = window.screen.availHeight;
	var w = window.screen.availWidth;
	window.open('/vegas/stay/planning-information/maps/index.jsp?map=' + map + '','maps','height=' + h + ',width=' + w + ',top=0,left=0,x=0,y=0,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes')
}	
	
function openBeAnyone(u){
	var display = screen.availWidth;
	var getANewMonitor;
	if(display < 1024){getANewMonitor = "yes"}else{getANewMonitor = "no"}

	window.open(u,null,'height=690,width=1010,top=0,left=0,x=0,y=0,status=no,toolbar=no,menubar=no,location=no,scrollbars=' + getANewMonitor + ',resizable=' + getANewMonitor)

	}	
	
	
function changeMonth(me){
	var months = document.getElementById('months');
	for (i=0;i<months.childNodes.length;i++){
		if (months.childNodes[i].nodeName == "OPTION"){
			document.getElementById(months.childNodes[i].value).style.display='none';  //do initalization
		}
	}
	document.getElementById(me).style.display='block';
}
	
/*validation library*/

function validField(str) {
	if(str.length == 0 || str==" ") {
		return false;
	}
	return true;
}

function validSelect(str) {
	if(str == "Please Select") {
		return false;
	}
	return true;
}

function validSelectDOB(str) {
	if(str == "") {
		return false;
	}
	return true;
}

function validEmail(email) {
    invalidChars = " /:,;"
	if(email == '') {
		return false;
	} else {
		for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
                return false;
			}
		}
        // check for @ symbol
		atPos = email.indexOf("@",1)			
		if (atPos == -1) {
            return false;
		}
        //check for only 1 @ symbol
		if (email.indexOf("@",atPos+1) != -1) {
            return false;
		}
        // and at least one . after the @
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
        	return false;
		}
		//check for only 1 char after @ and before .
		if (atPos+1>=periodPos){
			return false;
		}
        // must be at least 2 characters after the .
		if (periodPos+3 > email.length)	{
        	return false;
		}
	}
	return true;
}

function validPassword(str1,str2) {
	if(str1.length != 0) {
		if(str1 != str2) {
			return false;
		}
	} else {
		return false;
	}
	return true;
}

function validPhone(str) {
	if(str.charAt(0) == "0") {
		return false;
	}
	if(str.charAt(0) == "1") {
		if(str.length != 11) {
			return false;
		}
	} else {
		if(str.length != 10) {
			return false;
		}
	}
	return true;
}

function checkNewZip(strValue,country) {
	if(country=="US" || country==" "){
		var objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)|(^\d{5}\s\d{4}$)/;
		return (objRegExp.test(strValue));
	}else{
		return validField(strValue);
	}
}

function killonunload() {
    window.onunload = null;
}




