// JavaScript Document

function preloadImages(){
	for (i = 0; i < arguments.length; i++){   
		var oImage = new Image;
		oImage.src = 'images/' + arguments[i];
	}
}

function swapImage(element, image){
	element.src = 'images/' + image;
}

function goto_url(url){
	document.location.href = url;
}
function triggerDialogue(){
	
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
}

function checkAgeCheckBox(f){

	var dob=new Date();
	var date=dob.getDate();
	var month=dob.getMonth() + 1;
	var year=dob.getFullYear();

	var cmbmonth=parseInt(document.getElementById("cmbmonth").options[document.getElementById("cmbmonth").selectedIndex].value);
	var cmbday=parseInt(document.getElementById("cmbday").options[document.getElementById("cmbday").selectedIndex].value);
	var cmbyear=parseInt(document.getElementById("cmbyear").options[document.getElementById("cmbyear").selectedIndex].value);

	age=year-cmbyear;

	if(cmbmonth>month){
		age--;
	}else{
		if(cmbmonth==month && cmbday>=date){
			age--;
		}
	}

	if(cmbmonth==0){
		alert("You must enter the month you were born in.");
		return false;
	}else if(cmbday==0){
		alert("You must enter the day you were born on.");
		return false;
	}
	else if(cmbyear==2005){
		alert("You must enter the year you were born in.");
		return false;
	}else if(age<21){
		alert("You need to be 21 years or older to visit this site. You will now be redirected to a companion site at http://www.toughestcowboy.com.");
		location.replace("http://www.toughestcowboy.com/");
		return false;
	}else{
	    document.getElementById("age").value = age;
	    document.getElementById("formAge").action = document.location.href;
	    document.getElementById("formAge").submit();
//		document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none';
//		setCookie("age", 21, 365);
	}

}

