/*
 * This function removes extra spaces from right side of a string.
 * Param: Strring entered by user.
 */

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

function OpenPrivatePDF() {
    url = "/pdf/MLS_eclipsenet_silverlight.pdf";
    window.open(url, null, 'height=700,width=875,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function closeSurvey(callingItem) {
    url = "/SurveyStatus.aspx?status=close&id=" + querySt("id");
    window.open(url, null, 'height=10,width=15,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no');
}
function remindMeLater() {
    url = "/SurveyStatus.aspx?status=later&id=" + querySt("id")
    window.open(url, null, 'height=10,width=15,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no');
}
function sentForm() {
    url = "/SurveyStatus.aspx?status=completed&id=" + querySt("id")
    window.open(url, null, 'height=10,width=15,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no');
}

function showSurvey(id) {
    url = "/private/Survey.htm?id=" + id
    window.open(url, null, 'height=700,width=900,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function openLiveChat() {
    url = "/private/LiveChat.aspx";
    window.open(url, null, 'height=400,width=475,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function goToDemo(whichDemo) {
    url = "/feedback/goToDemoSite.aspx?type=" + whichDemo;
    window.open(url, null, 'height=700,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function ViewDemo(whichDemo) {
    url = "/feedback/ViewDemo.aspx?type=" + whichDemo;
    window.open(url, null, 'height=700,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function ContactMLS() {
    url = "/feedback/ContactMLS.aspx";
    window.open(url, null, 'height=800,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function openPDF(url, page, keywords) {
    url = "../../PDFViewer.aspx?file=" + url + "&page=" + page + "&searchTerm=" + keywords;
    window.open(url, null, 'height=600,width=900,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function DownloadPDF(url) {
    url = "/feedback/DownloadPDF.aspx?id=" + url;
    window.open(url, null, 'height=700,width=560,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function RequestDemo(type) {
    url = "/feedback/RequestDemo.aspx?type=" + type;
    window.open(url, null, 'height=750,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function RequestCallback() {
    url = "/feedback/RequestCallback.aspx?location=Junior.html";
    window.open(url, null, 'height=750,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function RequestTelephoneCallback() {
    url = "/feedback/RequestTelephoneCallback.aspx";
    window.open(url, null, 'height=750,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function showImage(number) {

    var img = document.getElementById('mainImage');
    img.src = 'images/' + number + '.png';
}

function goTo(url)
{
window.location=url;
}

function OpenSizedWindow(url, width, height) {
    var args = 'height=' + height + ',width= ' + width + ',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes'
    window.open(url, null, args);
}


function openWindow(url) {
    window.open(url, null, 'height=650,width=550,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}


function OpenProductDemo()
{
    url = "/products/ProductDemo.aspx";
    window.open(url,null,'height=650,width=550,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function OpenFamousFive() {
    url = "/feedback/FamousFive.aspx";
    window.open(url, null, 'height=750,width=550,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}
function OpenPDFRegister(url)

{
    url = "/products/predownload.aspx?id=" + url;
    window.open(url,null,'height=650,width=550,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function OpenMoreInfo(partnerName)
{
    url = "/home/registerInfoForPartner.aspx?name=" + partnerName;
    window.open(url,null,'height=450,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function OpenMoreInfoLP(partnerName)
{
    url = "/home/registerInfoForLearningPlatform.aspx?name=" + partnerName;
    window.open(url,null,'height=450,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

function swapHeaderImage(id, imageToShow) {
    var element = document.getElementsByName(id);
    element[0].src = imageToShow;
}

function lTrim(str)	
{
var space,str1 ;
space = 0 ;
str1=str;
if (str1.length==0)
	return str1 ;
	for (i=0;i<=str1.length-1;i++)	{
		if (str1.charAt(i)==" ")
			space++ ;
		else
			break ;
	}
	if (space > 0)
		str1 = str1.substring(space, str1.length) ;
	
return str1 ;
}

/*
 * This function removes extra spaces from right side of a string.
 * Param: Strring entered by user.
 */	
function rTrim(str)	
{
	var space,str1 ;
	space = 0 ;
	str1=str;

	if (str1.length==0){
		return str1 ;
	}

	for (i=str1.length-1;i>=0;i--)	{
			
		if (str1.charAt(i)==" "){		
			space++ ;
		}
		else{
			break;
		}
	}
	if (space > 0){
		str1 = str1.substring( 0,(str1.length-space)) ;
	}
	
return str1 ;
}

/*
*  This method checks if a email entered is a valid email.
*  
*/
function IsEmailValid(emailadd)
{

 var emailcheck; //valid address
	if	((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailadd)))
	{
       emailcheck = 1;
	}
	else
	{
       emailcheck = 0;
	}
return emailcheck;
}


 //  check for valid strings	
function IsChar(strString)
{
   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var strChar;
   var blnResult = true;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
    }
   return blnResult;
}

// This function checks the empty fields of registeration form
function Check_form()
{
	customer_name=rTrim(lTrim(document.register_frm.customer_name.value));
	customer_number=rTrim(lTrim(document.register_frm.customer_number.value));
	customer_postcode=rTrim(lTrim(document.register_frm.customer_postcode.value));
	customer_email=rTrim(lTrim(document.register_frm.customer_email.value));
	usr_name=rTrim(lTrim(document.register_frm.usr_name.value));

	if(customer_name=="")
	{
		alert ("Please enter customer name");
		document.register_frm.customer_name.select();
		document.register_frm.customer_name.focus();
		return false;
	}	
	if(customer_number=="")
	{
		alert ("Please enter customer number");
		document.register_frm.customer_number.select();
		document.register_frm.customer_number.focus();
		return false;
	}
	if(customer_postcode=="")
	{
		alert ("Please enter customer postcode");
		document.register_frm.customer_postcode.select();
		document.register_frm.customer_postcode.focus();
		return false;
	}
	if(IsEmailValid(customer_email)==0)
	{
		alert ("Please enter valid email address");
		document.register_frm.customer_email.select();
		document.register_frm.customer_email.focus();
		return false;
	}
	if(usr_name=="")
	{
		alert ("Please enter valid user name");
		document.register_frm.usr_name.select();
		document.register_frm.usr_name.focus();
		return false;
	}
	/*if(password1!=pass2)
	{
		alert ("Password and confirm password should be same!");
		document.register_frm.password1.select();
		document.register_frm.password1.focus();
		return false;
	}
	if(password1=="")
	{
		alert ("Please enter valid Password");
		document.register_frm.password1.select();
		document.register_frm.password1.focus();
		return false;
	}
	*/
	return true;
}
// This function checks the empty fields of registeration form
function Check_editform()
{
	name=rTrim(lTrim(document.register.name.value));
	institution=rTrim(lTrim(document.register.institution.value));
	postcode=rTrim(lTrim(document.register.postcode.value));
	email=rTrim(lTrim(document.register.email.value));
		
	if(institution=="")
	{
		alert ("Please enter institution");
		document.register.institution.select();
		document.register.institution.focus();
		return false;
	}	
	if(name=="")
	{
		alert ("Please enter your name");
		document.register.name.select();
		document.register.name.focus();
		return false;
	}
	if(IsEmailValid(email)==0)
	{
		alert ("Please enter valid email address");
		document.register.email.select();
		document.register.email.focus();
		return false;
	}
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.register.postcode.select();
		document.register.postcode.focus();
		return false;
	}
	document.register.submit();
	return true;
}


// This function checks the empty fields of registeration form
function Check_login_form()
{
	user_name=rTrim(lTrim(document.register1.user_nam.value));
	postcode=rTrim(lTrim(document.register1.postcode.value));
	if(user_name=="")
	{
		alert ("Please enter username");
		document.register1.user_nam.select();
		document.register1.user_nam.focus();
		return false;
	}	
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.register1.postcode.select();
		document.register1.postcode.focus();
		return false;
	}
	if(user_name!="")
	{
		document.register1.submit();
	}
	return true;
}

function Check_contact_form()
{
	name=rTrim(lTrim(document.contact_us.name.value));
	postcode=rTrim(lTrim(document.contact_us.postcode.value));
	phone=rTrim(lTrim(document.contact_us.phone.value));
	if(name=="")
	{
		alert ("Please enter your name");
		document.contact_us.name.select();
		document.contact_us.name.focus();
		return false;
	}	
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.contact_us.postcode.select();
		document.contact_us.postcode.focus();
		return false;
	}
	if(phone=="")
	{
		alert ("Please enter your phone");
		document.contact_us.phone.select();
		document.contact_us.phone.focus();
		return false;
	}
	document.contact_us.submit();
	return true;
}

function Change_Password()
{
	old_pass1=rTrim(lTrim(document.chng_pass.old_pass1.value));
	old_pass2=rTrim(lTrim(document.chng_pass.old_pass2.value));
	password1=rTrim(lTrim(document.chng_pass.password1.value));
	pass2=rTrim(lTrim(document.chng_pass.pass2.value));
		
	if(old_pass1=="")
	{
		alert ("Please enter old password");
		document.chng_pass.old_pass1.select();
		document.chng_pass.old_pass1.focus();
		return false;
	}
	if(old_pass1!=old_pass2)
	{
		alert ("Invalid old password.");
		document.chng_pass.old_pass1.select();
		document.chng_pass.old_pass1.focus();
		return false;
	}
	if(password1=="")
	{
		alert ("Please enter new password");
		document.chng_pass.password1.select();
		document.chng_pass.password1.focus();
		return false;
	}
	if(pass2!=password1)
	{
		alert ("New password and confirm password should be same");
		document.chng_pass.password1.select();
		document.chng_pass.password1.focus();
		return false;
	}
	return true;
}


// this function counts the number of characters 
function count_char(noOfCharators,obj)
{
	if(obj.value.length>noOfCharators)
	{
	var temp1;
	temp1="";
		for(i=0;i<noOfCharators-2;i++)
		{
			temp1 = temp1 + obj.value.charAt(i)
		}
		obj.value = temp1;
		alert("More then "+noOfCharators+" Charactor not allowed");
		return false;
	}
}	 
 //  check for valid numeric strings	
function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
    }
   return blnResult;
}
//This function checks the extenssion of file.
function upload_pic()
{
if(document.picture.upic.value == "")
{
	alert("Please select image file for uploading");
	document.picture.upic.focus();
	return(false);
}
var str = document.picture.upic.value;
	var pos=str.indexOf(".")
	var pos1 = pos + 1
	var req1 = str.substr(pos1,3)
		if (req1 != "gif" && req1 != "jpg" && req1 != "GIF" && req1 != "JPG") 
			{
				alert("only GIF and JPG files are allowed to upload");
				document.picture.upic.focus();
				return(false);
			}
return(true);
}

function openForum()
        {
        	window.open('http://infodeck.net/forum_register.php', 'MyDialogue',config="modal,width=450px,height=380px,scrollbars=yes");
        }
// This function checks the empty fields of demo request form
function Check_demoform()
{
	name=rTrim(lTrim(document.demo.name.value));
	postcode=rTrim(lTrim(document.demo.postcode.value));
	phone=rTrim(lTrim(document.demo.phone.value));
	//email=rTrim(lTrim(document.demo.email.value));
	
	
	if(name=="")
	{
		alert ("Please enter your name");
		document.demo.name.select();
		document.demo.name.focus();
		return false;
	}	
	
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.demo.postcode.select();
		document.demo.postcode.focus();
		return false;
	}
	if(phone=="")
	{
		alert ("Please enter phone number");
		document.demo.phone.select();
		document.demo.phone.focus();
		return false;
	}
	/*if(IsEmailValid(email)==0)
	{
		alert ("Please enter valid email address");
		document.demo.email.select();
		document.demo.email.focus();
		return false;
	}*/
	document.demo.submit();
	return true;
}
function Check_stform()
{
	name=rTrim(lTrim(document.standard.name.value));
	org_name=rTrim(lTrim(document.standard.org_name.value));	
	postcode=rTrim(lTrim(document.standard.postcode.value));	
	phone=rTrim(lTrim(document.standard.tel.value));
	email=rTrim(lTrim(document.standard.email.value));
	
	
	if(name=="")
	{
		alert ("Please enter your name");
		document.standard.name.select();
		document.standard.name.focus();
		return false;
	}	
	
	if(org_name=="")
	{
		alert ("Please enter School/Company Name");
		document.standard.org_name.select();
		document.standard.org_name.focus();
		return false;
	}
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.standard.postcode.select();
		document.standard.postcode.focus();
		return false;
	}
	if(phone=="")
	{
		alert ("Please enter phone number");
		document.standard.tel.select();
		document.standard.tel.focus();
		return false;
	}
	if(IsEmailValid(email)==0)
	{
		alert ("Please enter valid email address");
		document.standard.email.select();
		document.standard.email.focus();
		return false;
	}
	document.standard.submit();
	return true;
}
// This function checks the empty fields of demo request form
function Check_brochure()
{
	name=rTrim(lTrim(document.demo.name.value));
	org_name=rTrim(lTrim(document.demo.org_name.value));
	postcode=rTrim(lTrim(document.demo.postcode.value));
	phone=rTrim(lTrim(document.demo.phone.value));
	email=rTrim(lTrim(document.demo.email.value));
	hear=rTrim(lTrim(document.demo.hear.value));
	
	if(name=="")
	{
		alert ("Please enter your name");
		document.demo.name.select();
		document.demo.name.focus();
		return false;
	}	
	if(org_name=="")
	{
		alert ("Please enter your Institution");
		document.demo.org_name.select();
		document.demo.org_name.focus();
		return false;
	}
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.demo.postcode.select();
		document.demo.postcode.focus();
		return false;
	}
	if(phone=="")
	{
		alert ("Please enter phone number");
		document.demo.phone.select();
		document.demo.phone.focus();
		return false;
	}
	if(IsEmailValid(email)==0)
	{
		alert ("Please enter valid email address");
		document.demo.email.select();
		document.demo.email.focus();
		return false;
	}
	if(hear=="")
	{
		alert ("Please enter, how did you hear?");
		document.demo.hear.select();
		document.demo.hear.focus();
		return false;
	}
	document.demo.submit();
	return true;
}

function Check_intro_form()
{
	contact=rTrim(lTrim(document.intro.contact.value));
	postcode=rTrim(lTrim(document.intro.postcode.value));
	tel=rTrim(lTrim(document.intro.phone.value));
	
	
	
	if(contact=="")
	{
		alert ("Please enter contact");
		document.intro.contact.select();
		document.intro.contact.focus();
		return false;
	}	
	if(postcode=="")
	{
		alert ("Please enter postcode");
		document.intro.postcode.select();
		document.intro.postcode.focus();
		return false;
	}
	if(tel=="")
	{
		alert ("Please enter phone number");
		document.intro.phone.select();
		document.intro.phone.focus();
		return false;
	}
	document.intro.submit();
	return true;
}

function Chng_Pass()
{
	pass1=rTrim(lTrim(document.frmpass.pass1.value));
	pass2=rTrim(lTrim(document.frmpass.pass2.value));
	
	if(pass1=="")
	{
		alert ("Please enter new password");
		document.frmpass.pass1.select();
		document.frmpass.pass1.focus();
		return false;
	}
	if(pass2!=pass1)
	{
		alert ("New password and confirm password should be same");
		document.frmpass.pass1.select();
		document.frmpass.pass1.focus();
		return false;
	}
	document.frmpass.submit();
	
	return true;
}


//-->