function showImage(t){
	var stxt = "";
	
	stxt += "<html><head><title>Image viewer</title></head><body>";
	stxt += "<table border=0 cellpadding=0 cellspacing=0><tr><td align=center><br><font size=2 face=arial><b>Image Viewer</b></td></tr>";
	stxt += "<tr><td><br>";
	stxt += "<img src='"+ t +"'>";
	stxt += "</td></tr><tr><td align=center><br><a href=javascript:window.close();><font size=2 face=arial color=blue>Close Window</font></a></td></tr></table>";
	
	var win = window.open("","","width=625,height=625,resizable=yes,scrollbars=yes")
	win.document.write(stxt);
	
}

function emailValidator(elem){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		return false;
	}
}

function checkEmail()
	{
	var strEmail, strError, countAtRate, countDot, i;
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	strEmail = checkEmail.arguments[0];

	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (strEmail.length >= 7)
		{
		for(i=0;i<strEmail.length;i++)
			{
			if(strEmail.charAt(i)=="@")
				countAtRate++;
			if(strEmail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(strEmail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}
			}
		}
	checkAtRate=strEmail.indexOf("@",1);
	checkDot=strEmail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=strEmail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=strEmail.length-2)
		strError=0;
	if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
		strError=0;
	if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;

	return strError;
}


function isBlank(C) {
	for (i=0;i<C.length;i++) {if (C.charAt(i) != " ") return false}
	return true;
}

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;
} //End Function


function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function keyCheck(eventObj, obj)
{
	var keyCode	
	
	// Check For Browser Type
	if (document.all){ 
		keyCode=eventObj.keyCode
	}
	else{
		keyCode=eventObj.which
	}

	var str=obj.value
	if(keyCode==46){ 
		if (str.indexOf(".")>0){
			return false
		}
	}
	
	if((keyCode<48 || keyCode >58)){ // Allow only integers
		return false
	}
	
	return true
}

/* Show Demo Script */
function show_demo(dm)
{
	if(dm.txturl.value=="" || dm.txturl.value=="http://www.thisisyourdomain.com")
		{
		alert("Please enter your website URL.");
		dm.txturl.focus();
		return false;
		}
	else{
		return true;
	}
}
/* Show Demo Script */

function frmLoginValidate(dm){
	var strError="";	
		
	if(isBlank(dm.txtusername.value))
		strError += "Username\n";	
	if(isBlank(dm.txtpassword.value))
		strError += "Password\n";

		
	if(strError!=""){		
		alert("Please check the following required field(s) \n------------------------------------------------\n"+strError);
		return false;
	}	
	return true;
}

function frmRegistrationValidate(dm){
	var strError="";
		
	if(isBlank(dm.txtname.value))
		strError += "Full Name\n";
	if(isBlank(dm.txtcompany.value))
		strError += "Company Name\n";
	if(isBlank(dm.txtaddress.value))
		strError += "Address 1\n";
	if(isBlank(dm.txtcity.value))
		strError += "City\n";
	if(isBlank(dm.cbcountry.value))
		strError += "Country\n";
	if(isBlank(dm.txtphone.value))
		strError += "Telephone\n";
	
	if(isBlank(dm.txtusername.value))
		strError += "Username\n";
	if(isBlank(dm.txtpassword.value))
		strError += "Password\n";
	else if(LTrim(dm.txtpassword.value) != LTrim(dm.txtconfirmpassword.value))
		strError += "Confirm Password does not match\n";
		
	if(isBlank(dm.txtemail.value))
		strError += "Email Address\n";
	else if(checkEmail(dm.txtemail.value)==0)
		strError += "Invalid Email Address\n";		
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	}	
	return true;
}

function frmMyAccountValidate(dm){
	var strError="";
		
	if(isBlank(dm.txtname.value))
		strError += "Full Name\n";
	if(isBlank(dm.txtcompany.value))
		strError += "Company Name\n";
	if(isBlank(dm.txtaddress.value))
		strError += "Address 1\n";
	if(isBlank(dm.txtcity.value))
		strError += "City\n";
	if(isBlank(dm.cbcountry.value))
		strError += "Country\n";
	if(isBlank(dm.txtphone.value))
		strError += "Telephone\n";
		
	if(isBlank(dm.txtemail.value))
		strError += "Email Address\n";
	else if(checkEmail(dm.txtemail.value)==0)
		strError += "Invalid Email Address\n";	
	
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	}	
	return true;
}

function frmActorPositioningValidate(dm,pg){
	var strError="";
	if(isBlank(dm.cbwebsiteactor.value))
		strError += "Select your actor\n";	
	if(isBlank(dm.txtXpos.value))
		strError += "X Pos\n";
	if(isBlank(dm.txtYpos.value))
		strError += "Y Pos\n";
	
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);	
	} else {
		dm.method = "POST";
		dm.action = pg;
		dm.submit();
	}
	return true;
}

function frmViralLinksValidate(dm){
	var strError="";
	
	if(isBlank(dm.txtvirallink.value))
		strError += "Viral Link\n";
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	}	
	return true;
}

function frmTimeInteractionValidate(dm){
	var strError="";
	
	if(isBlank(dm.cbtime.value))
		strError += "Timed Interactions\n";
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	}	
	return true;
}

function frmMultiLanguageEditValidate(dm){
	var strError="";
	if(isBlank(dm.txtmultilanguagename.value))
		strError += "Script Name\n";
	if(isBlank(dm.cbwebsiteactor.value))
		strError += "Your Actor\n";			
	if(isBlank(dm.cblanguage.value))
		strError += "Language\n";	
	if(isBlank(dm.txtcontent.value))
		strError += "Script\n";
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	}	
	return true;
}

function frmMultiLanguageSetSorderValidate(dm){
	var strError="";
	if(isBlank(dm.cbwebsiteactor.value))
		strError += "Select your actor\n";
	if(isBlank(dm.cbclosecaption.value))
		strError += "Select close captioning\n";			
	
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	} 
	return true;
}

function frmCcSwitchOnValidate(dm){
	var strError="";
	if(isBlank(dm.hwebsiteactorcode.value))
		strError += "Select your actor\n";	
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	} 
	return true;
}

function frmReportValidate(dm){
	var strError="";
	if(isBlank(dm.actor.value))
		strError += "Select your actor\n";
	
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	} 
	return true;
}

function frmRequestAnActorValidate(dm){
	var strError="";
	if(isBlank(dm.txtactorname.value))
		strError += "Actor Name\n";
	if(isBlank(dm.txtwebsiteurl.value))
		strError += "Your website URL\n";
	if(dm.cbpaymentplan.value=="0")
		strError += "Payment Plan\n";	
	
		
	if(strError!=""){		
		alert("Please check the following required field(s) \n-----------------------------------------------------\n"+strError);
		return false;
	} 
	return true;
}

function frmRequestLinkValidate(dm) 
 {
	var err = "";	
	if(LTrim(dm.txtfullname.value)=="")
		err += "Full Name\n";
	if(LTrim(dm.txttelephone.value)=="")
		err += "Telephone Number\n";
	if(LTrim(dm.txtemail.value)=="")
		err += "Email Address\n";
	else if(emailValidator(dm.txtemail)==0){
		alert("Invalid Email Address");
		dm.txtemail.select();
		return false;
	}
	if(LTrim(dm.txtyourwebsiteURL.value)=="")
		err += "Your website URL\n";		
	
	
	if(err!=""){
		alert("Please check the following required field(s).......\n\n"+err);
		return false;
	}
	else
		return true;
}

function frmLoginRequestValidate(dm) 
 {
	var err = "";	
	if(LTrim(dm.txtfullname.value)=="")
		err += "Full Name\n";	
	if(LTrim(dm.txtemail.value)=="")
		err += "Email Address\n";
	else if(emailValidator(dm.txtemail)==0){
		alert("Invalid Email Address");
		dm.txtemail.select();
		return false;
	}
	if(LTrim(dm.txtyourwebsiteURL.value)=="")
		err += "Your website URL\n";		
	
	
	if(err!=""){
		alert("Please check the following required field(s).......\n\n"+err);
		return false;
	}
	else
		return true;
}

function frmContactUsValidate(dm) 
 {
	var err = "";	
	if(LTrim(dm.txtfullname.value)=="")
		err += "Full Name\n";	
	if(LTrim(dm.txtemail.value)=="")
		err += "Email Address\n";
	else if(emailValidator(dm.txtemail)==0){
		alert("Invalid Email Address");
		dm.txtemail.select();
		return false;
	}
	if(LTrim(dm.txttelephone.value)=="")
		err += "Telephone Number\n";
	if(LTrim(dm.txtyourwebsiteURL.value)=="")
		err += "Your website URL\n";	
	
	if(err!=""){
		alert("Please check the following required field(s).......\n\n"+err);
		return false;
	}
	else
		return true;
}

function frmForgetPasswordValidate(dm) 
 {
	var err = "";	
	if(LTrim(dm.txtusername.value)=="")
		err += "Username\n";		
	
	if(err!=""){
		alert("Please check the following required field(s).......\n\n"+err);
		return false;
	}
	else
		return true;
}