<!--//
var isIE;
if (navigator.appName == "Microsoft Internet Explorer") {
	isIE = true;
}
if (navigator.appName == "MSIE") {
	isIE = true;
}
function loadMovie(src,h,w,fvars) {
	var text = "";
	if (isIE) {
		text	 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		text	= text + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
		text	= text + 'width="' + w + '" height="' + h + '">';
		text = text + '<param name="movie" value="' + src + '" />';
		text = text + '<param name="allowScriptAccess" value="sameDomain" />';
		text = text + '<param name="wmode" value="transparent" />';
		text = text + '<param name="quality" value="high" />';
		if (fvars.length > 0) {
			text = text + '<param name="FlashVars" value="' + fvars + '" />';
		}
		text = text + '</object>';
	} else {
		text	= '<embed src="' + src + '" ';
		text	= text + 'quality="high" ';
		text	= text + 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ';
		text	= text + 'type="application/x-shockwave-flash" ';
		text	= text + 'width="' + w + '" height="' + h + '" ';
		text	= text + 'allowscriptaccess="samedomain" ';
		text	= text + 'wmode="transparent"';
		if (fvars.length > 0) {
			text	= text + ' flashvars="' + fvars + '"';
		}		
		text	= text + '></embed>';
	}
	//alert(text);
	document.write(text);
}

function loadVideo2(src,h,w,ui,autostart,conn) {
	if (conn == "cable" || conn == "broadband") {
		w = 540;
		h = 360;
	}
	loadVideo(src,h,w,ui,autostart);
}

function loadVideo(src,h,w,ui,autostart) {
	var text = "";
	if (isIE) {
		text = '<object id="winplayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" ';
		text	= text + 'standby="Loading Windows Media Player components..." ';
		if (ui == "none") {
			text	= text + 'width="' + w + '" height="' + h + '" type="application/x-oleobject">';
			text	= text + '<param name="showcontrols" value="false" />';
			text	= text + '<param name="showstatusbar" value="false" />';
			text	= text + '<param name="enablecontextmenu" value="false" />';
			text = text + '<param name="uimode" value="none" />';
			text = text + '<param name="animationatStart" value="true" />';
			text = text + '<param name="transparentatStart" value="true" />';
		} else if 
		   (ui == "mini") {		
			h	= h + 40;
			text	= text + 'width="' + w + '" height="' + h + '" type="application/x-oleobject">';
			text	= text + '<param name="showcontrols" value="true" />';
			text	= text + '<param name="showstatusbar" value="true" />';
			text	= text + '<param name="enablecontextmenu" value="true" />';
			text = text + '<param name="uimode" value="mini" />';
			text = text + '<param name="animationatStart" value="true" />';
			text = text + '<param name="transparentatStart" value="true" />';
		} else if 
		   (ui == "invisible") {
			text	= text + 'width="' + w + '" height="' + h + '" type="application/x-oleobject">';
			text	= text + '<param name="showcontrols" value="false" />';
			text	= text + '<param name="showstatusbar" value="true" />';
			text	= text + '<param name="enablecontextmenu" value="false" />';
			text = text + '<param name="uimode" value="invisible" />';
			text = text + '<param name="animationatStart" value="true" />';
			text = text + '<param name="transparentatStart" value="true" />';			
		} else {		
			h	= h + 40;
			text	= text + 'width="' + w + '" height="' + h + '" type="application/x-oleobject">';
			text	= text + '<param name="showcontrols" value="true" />';
			text	= text + '<param name="showstatusbar" value="true" />';
			text	= text + '<param name="enablecontextmenu" value="true" />';
			text = text + '<param name="uimode" value="full" />';
			text = text + '<param name="animationatStart" value="true" />';
			text = text + '<param name="transparentatStart" value="true" />';
		}
		if (autostart) {
			text = text + '<param name="autostart" value="true" />';
		} else {
			text = text + '<param name="autostart" value="false" />';
		}
		text	= text + '<param name="url" value="' + src + '" />';
		text	= text + '</object>';
	} else {
		if (ui == "none") {			
			text = '<object id="video1" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" width="' + w + '" height="' + h + '">\n';
			text = text + '<param name="url" value="' + src + '">\n';
			text = text + '<param name="src" value="' + src + '">\n';
			text = text + '<param name="ShowStatusBar" value="0">\n';
			text = text + '<param name="uimode" value="none">\n';
		} else if 
		   (ui == "mini") {		
			h	= h + 40;
			text = '<object id="video1" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" width="' + w + '" height="' + h + '">\n';
			text = text + '<param name="url" value="' + src + '">\n';
			text = text + '<param name="src" value="' + src + '">\n';
			text = text + '<param name="ShowStatusBar" value="1">\n';
			text = text + '<param name="uimode" value="mini">\n';
		} else {		
			h	= h + 40;
			text = '<object id="video1" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" width="' + w + '" height="' + h + '">\n';
			text = text + '<param name="url" value="' + src + '">\n';
			text = text + '<param name="src" value="' + src + '">\n';
			text = text + '<param name="ShowStatusBar" value="1">\n';
			text = text + '<param name="uimode" value="full">\n';
		}
		if (autostart) {
			text = text + '<param name="autostart" value="1">\n';
		} else {
			text = text + '<param name="autostart" value="0">\n';
		}
		text = text + '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" ';
		text	= text + 'src="' + src + '" ';
		if (ui == "none") {
			text = text + 'enablecontextmenu="false" showstatusbar="false" uimode="none" ';
		} else {
			h	= h + 40;
			text = text + 'enablecontextmenu="true" showstatusbar="true" uimode="full" ';
		}
		text = text + 'width="' + w + '" height="' + h + '" ';
		text = text + 'animationatstart="true" transparentatStart="true" ';
		if (autostart) {
			text = text + 'autostart="true"></embed>';
		} else {
			text = text + 'autostart="false"></embed>';
		}
		text = text + '</object>\n';
	}
//	alert(text);
	document.writeln(text);
}

function changeCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	frmObj.value = tmpStr;
}
function changeLower(frmObj) {
	var tmpStr;
	tmpStr = frmObj.value.toLowerCase();
	frmObj.value = tmpStr;
}
function changeUpper(frmObj) {
	var tmpStr;
	tmpStr = frmObj.value.toUpperCase();
	frmObj.value = tmpStr;
}

function validateLogon() {
	if (document.logon.username.value == "") {
		alert("Please enter YOUR Username");
		document.logon.username.focus();
		return false;
	}
	if (document.logon.username.value.length <= 3) {
		alert("Please enter a VALID Username.");
		document.signup.username.focus();
		return false;
	}
	var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
	var allValid = 1;
	var i = 0; 
	var j = 0;
	var entryCount = document.logon.username.value.length;
	var good = 0;
	var OKlength = checkOK.length;
	while (i < entryCount) {
		ch = document.logon.username.value.charAt(i);
		while  (j < OKlength) {
			if (ch == checkOK.charAt(j)) {
				good = 1;
				break;
			}
			j++;
		}
		if (good < 1) {
			alert("Please enter only letters and/or numbers for your USERNAME. No Spaces Allowed\n");
			document.logon.username.value = '';
			document.logon.username.focus();
			return false;
		}
		good = 0;
		i++;
		j = 0;
	}
	if (document.logon.password.value.length == 0) {
		alert("Please enter YOUR Account Password.");
		document.logon.password.focus();
		return false;
	}
	if (document.logon.password.value.length <= 4) {
		alert("Your Password MUST be at-least 5 letters and/or numbers in length. Please enter YOUR Account Password.");
		document.logon.password.focus();
		return false;
	}
}

function previewTemplate() {
	var template = document.config.template.value;
	var templateURL = 'http://www.exotictravelmart.com/?mode=preview&template=' + template + '&';
	var win = window.open(templateURL,'','scrollbars=no,menubar=no,height=580,width=760,resizable=yes,toolbar=no,location=no,status=no');
}

function jm_phonemask(t) {
	var patt1 = /(\d{3}).*(\d{3}).*(\d{4})/;
	var patt2 = /^\((\d{3})\).(\d{3})-(\d{4})$/;
	var str = t.value;
	var result;
	if (!str.match(patt2)) {
		result = str.match(patt1);
		if (result!= null) {
			t.value = t.value.replace(/[^\d]/gi,'');
			str = '(' + result[1] + ') ' + result[2] + '-' + result[3];
			t.value = str;
		} else {
			if (t.value.match(/[^\d]/gi)) {
				t.value = t.value.replace(/[^\d]/gi,'');
			}
		}
	}
}

function checkPhone(c,t) {
	var country = c.value;
//	alert('Country: ' + country);
	if (country == "US" || country == "CA") {
		jm_phonemask(t);
	}
}

function validateProfile () {
	if (document.profile.firstname.value.length < 2) {
		alert("Please enter your Firstname");
		document.profile.firstname.focus();
		return false;
	}
	if (document.profile.lastname.value.length < 2) {
		alert("Please enter your Lastname.");
		document.profile.lastname.focus();
		return false;
	}
	if (document.profile.address.value.length < 2) {
		alert("Please enter your Address.");
		document.profile.address.focus();
		return false;
	}
	if (document.profile.city.value.length < 2) {
		alert("Please enter your City.");
		document.profile.city.focus();
		return false;
	}
	if (document.profile.state.value.length == '') {
		alert("Please select your State/Prov/Terr.");
		document.profile.state.focus();
		return false;
	}
	if (document.profile.zip.value.length < 4) {
		alert("Please enter your Zip/Postal Code.");
		document.profile.zip.focus();
		return false;
	}
	if (document.profile.country.value.length == '') {
		alert("Please select your Country.");
		document.profile.country.focus();
		return false;
	}	
	if (document.profile.email.value.length == 0) {
		alert("Please enter an email address.");
		document.profile.email.focus();
		return false;
	}
	if (document.profile.email.value.length > 0) {
		i   = document.profile.email.value.indexOf("@");
		j   = document.profile.email.value.indexOf(".",i);
		k   = document.profile.email.value.indexOf(",");
		kk  = document.profile.email.value.indexOf(" ");
		jj  = document.profile.email.value.lastIndexOf(".") + 1;
		len = document.profile.email.value.length;

		if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
		} else {
			alert("Please enter an exact email address.\n" + document.profile.email.value + " is invalid.");
			document.profile.email.focus();
			return false;
		}
	}
	if (document.profile.workphone.value.length < 10) {
		alert("Please enter your Daytime Phone Number.");
		document.profile.workphone.focus();
		return false;
	}
}

function validateSignup () {
	if (document.signup.company.value.length < 1) {
		if (document.signup.firstname.value < 2) {
			alert("Please enter your Firstname");
			document.signup.firstname.focus();
			return false;
		}
		if (document.signup.lastname.value.length < 2) {
			alert("Please enter your Lastname.");
			document.signup.lastname.focus();
			return false;
		}
	} 
	if (document.signup.address.value.length < 2) {
		alert("Please enter your Address.");
		document.signup.address.focus();
		return false;
	}
	if (document.signup.city.value.length < 2) {
		alert("Please enter your City.");
		document.signup.city.focus();
		return false;
	}
	if (document.signup.state.value.length == '') {
		alert("Please select your State/Prov/Terr.");
		document.signup.state.focus();
		return false;
	}
	if (document.signup.zip.value.length < 4) {
		alert("Please enter your Zip/Postal Code.");
		document.signup.zip.focus();
		return false;
	}
	if (document.signup.country.value.length == '') {
		alert("Please select your Country.");
		document.signup.country.focus();
		return false;
	}	
	if (document.signup.email.value.length == 0) {
		alert("Please enter an email address.");
		document.signup.email.focus();
		return false;
	}
	if (document.signup.email.value.length > 0) {
		i   = document.signup.email.value.indexOf("@");
		j   = document.signup.email.value.indexOf(".",i);
		k   = document.signup.email.value.indexOf(",");
		kk  = document.signup.email.value.indexOf(" ");
		jj  = document.signup.email.value.lastIndexOf(".") + 1;
		len = document.signup.email.value.length;

		if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
		} else {
			alert("Please enter an exact email address.\n" + document.signup.email.value + " is invalid.");
			document.signup.email.focus();
			return false;
		}
	}
	if (document.signup.workphone.value.length < 10) {
		alert("Please enter your Daytime Phone Number.");
		document.signup.workphone.focus();
		return false;
	}
	if (document.signup.pay_to.value.length < 1) {
		alert("Please enter a Payment Name.");
		document.signup.pay_to.focus();
		return false;
	}
	if (document.signup.pay_address.value.length < 1) {
		alert("Please enter a Payment Address.");
		document.signup.pay_address.focus();
		return false;
	}
	if (document.signup.pay_city.value.length < 2) {
		alert("Please enter a Payment City.");
		document.signup.paycity.focus();
		return false;
	}
	if (document.signup.pay_state.value.length == '') {
		alert("Please select your Payment State/Prov/Terr.");
		document.signup.pay_state.focus();
		return false;
	}
	if (document.signup.pay_zip.value.length < 4) {
		alert("Please enter your Payment Zip/Postal Code.");
		document.signup.zip.focus();
		return false;
	}
	if (document.signup.pay_country.value.length == '') {
		alert("Please select your Payment Country.");
		document.signup.pay_country.focus();
		return false;
	}
	if (document.signup.title.value.length < 1) {
		alert("Please enter your Travel Site Name.");
		document.signup.title.focus();
		return false;
	}
	if (document.signup.password1.value.length < 1) {
		alert("Please enter your a Password.");
		document.signup.password1.focus();
		return false;
	}
	if (document.signup.password2.value.length < 1) {
		alert("Please verify your Password.");
		document.signup.password2.focus();
		return false;
	}
	if (document.signup.password1.value != document.signup.password2.value) {
		alert("Your passwords did not match. Please re-enter them.");
		document.sugnup.password1.value = '';
		document.sugnup.password2.value = '';
		document.signup.password1.focus();
		return false;
	}
}