//::Open/Close Curtain Function
function ToggleCurtain() {
	var objCurtain = $j("#curtain");
	objCurtain.animate({
			marginLeft: parseInt(objCurtain.css("marginLeft"),10) == 0 ?
			objCurtain.outerWidth() : 0
		},
		2000,
		"swing",
		function() {
			$j("#body").fadeIn();
		}
	);
}

//::Open Curtain Function
function OpenCurtain() {
	$j("#curtain").css("visibility","hidden");
}


//::Close Curtain Function
function CloseCurtain(strHref) {
	if (document.getElementById("curtain").style.display != "none") {
		document.getElementById("curtain").style.visibility = "visible";
		document.getElementById("boothcurtain").SetVariable("url",strHref);
		document.getElementById("boothcurtain").Play();
		return false;
	}
	else {
		document.location.href = strHref;
		return false;
	}
}


//::Show Body
function ShowBody() {
	$j("#body").css("visibility","visible");
}


//::Trim String Function
function Trim(str){
	str = str.replace(/\s+/,'');
	str = str.replace(/\s+$/,'');
	return str;
}

//::IsNumeric Function
function IsNumeric(val){
	if (val != "") {
		for (i=0; i<val.length; i++){
			if (isNaN(val.charAt(i)) &&
			   (val.charAt(i) != "," &&
				val.charAt(i) != ".")){
				return false;
			}
		}
	}
	else {
		return false;
	}
	return true;
}

//::Valid E-Mail
function ValidEmail(str){
	SpcPos = str.indexOf(' ');
	AccPos = str.indexOf('@');
	AccStr = str.substr(0,AccPos);
	AccLen = AccStr.length;
	DomPos = str.lastIndexOf('.');
	DomStr = str.substr(AccPos+1,(DomPos-AccPos)-1);
	DomLen = DomStr.length;
	ExtPos = DomPos + 1;
	ExtLen = str.length - ExtPos;
	ExtStr = str.substr(ExtPos,ExtLen);
	if(	   (SpcPos == -1)
		&& (AccPos != -1)
		&& (DomPos != -1)
		&& (AccLen >= 2)
		&& (DomLen >= 2)
		&& (ExtLen >= 2)
		&& (ExtLen <= 4)){
		return true;
	}
	else{return false}
}

//::Valid Telephone
function ValidTelephone(str){
	str = Trim(str);
	str = str.replace("(","");
	str = str.replace(")","");
	str = str.replace(".","");
	str = str.replace(".","");
	str = str.replace("-","");
	str = str.replace("-","");
	str = str.replace(" ","");
	strLen = str.length;
	if((strLen == 10 || strLen == 7) && IsNumeric(str)){
		return true;
	}
	else{
		return false;
	}
}

//::check if radio or checkbox items are selected
function CheckSelected(arr){
	if(arr.length > 0){
		for(var index = 0; index < arr.length; index++){
			if(arr[index].checked){
				return true;
				break;
			}
		}
	}
	else{
		if(arr.checked){
			return true;
		}
		else{
			return false;
		}
	}
	return false;
}


//::Build E-Mail Link
//ex. [script]document.write(BuildEmail('Click Here','email','isp.com','Subject','class="Link"'));[/script]
function BuildEmail(lnkName,lnkEmail,lnkHost,lnkSubject,lnkStyle){
	if(lnkName == ""){
		lnkName = lnkEmail + "&#64;" + lnkHost;
	}
	if(lnkSubject != ""){
		lnkSubject = "?subject=" + lnkSubject;
	}
	return "<a href='" + "mail" + "to:" + lnkEmail + "@" + lnkHost + lnkSubject + "' " + lnkStyle + ">" + lnkName + "</a>";
}
