function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email);
}
function checkForm(form){
	var valid = true;
	var message = "";
	if(form.name.value.length < 2){
		message += "Please enter a name.\n";
		valid = false;
	}
	if(!validateEmail(form.email.value)){
		message += "Please enter a valid e-mail address.\n";
		valid = false;
	}
	if(!valid){
		alert(message);
	}
	return valid;
}

function checkEmail(email) {

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {

		return true;

	}else {

		return false;

	}

}

function jumpList(field){
	window.location = field.value;
}

function callToActionscript(movieName, call) 
{	
	//alert('callToActionscript('+movieName+','+call+')');
	var mymovie = getFlashMovie(movieName);
    mymovie.sendToActionscript(call);
}
function hideDiv(divID){
	// alert('hideDiv(' + divID + ') called.');
	mydiv = document.getElementById(divID);
	mydiv.style.visibility = "hidden";
}
function eraseDiv(divID){
	hideDiv(divID);
	mydiv = document.getElementById(divID);
	mydiv.innerHTML = '';
	mydiv.style.position = 'absolute';
	mydiv.style.height = '0px';
	mydiv.style.width = '0px';
	try
	{
	$('flash-banner-transparency').fade('out');
	}
	catch(e)
	{
	$('#flash-banner-transparency').fadeOut('slow');
	}
	
}
function restoreDiv(divID){
	mydiv = document.getElementById(divID);
	mydiv.style.visibility = "visible";
	mydiv.innerHTML = '<div id="flash-header" style="height:165px;"></div> <div align="center"><a href="javascript:;" onclick="eraseDiv(\'flash-window\');">Close Flash Window</a></div>';
	mydiv.style.position = 'relative';
	mydiv.style.width = '680px';
	mydiv.style.height = '165px';
	try
	{
	$('flash-banner-transparency').fade('in');
	}
	catch(e)
	{
	$('#flash-banner-transparency').fadeIn('slow');
	}

}
function xtractFile(data){
	data = data.replace(/^\s|\s$/g, "");

	if (/\.\w+$/.test(data)) {
		var m = data.match(/([^\/\\]+)\.(\w+)$/);
		if (m)
			return {filename: m[1], ext: m[2]};
		else
			return {filename: "no file name", ext:null};
	} else {
		var m = data.match(/([^\/\\]+)$/);
		if (m)
			return {filename: m[1], ext: null};
		else
			return {filename: "no file name", ext:null};
	}
}
var containers = new Array();
function showHide(id){
	var element = document.getElementById(id);
	if(containers[id]){
		if(containers[id]['display']){
			if(containers[id]['display'] == 'none'){
				element.style.display = 'block';
				containers[id]['display'] = 'block';
			}else{
				element.style.display = 'none';
				containers[id]['display'] = 'none';
			}
		}
	}else{ // default would be hidden, show the item
		element.style.display = 'block';
		containers[id] = new Array();
		containers[id]['display'] = 'block';
	}
}
function jsAppend(js_file)
{
  js_script = document.createElement('script');
  js_script.type = "text/javascript";
  js_script.src = js_file;
  document.getElementsByTagName('head')[0].appendChild(js_script);
}

// cookie functions
function createCookie(name,value,days) {
	var expires = "";
        if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
// is this an iphone, ipod or ipad?
function ipadipad(){
    var mobisafari = false;
    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
            mobisafari = true;
    }
    return mobisafari;
}

function popup(path){
    window.open(path,'popwindow','scrollbars=no,location=no,width=600,height=600,left=15,top=50,resizable=yes')
}


