// JavaScript Document
function freetrial(prodid)
{
	l = new dialog( {title:'', width:500, height:100, onclose:'l.close()', ismodel:true, isdrag:false, top:100} );
	l.sethtml( 'Loading...' ); 
	l.show();

	$.ajax({
	type : "POST",
	url	 : baseurl+'view/form',
	data : 'prodid='+prodid+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
}

function check_freetrial()
{
	//alert($('input[@name="privacy"]').is(':checked')? 1 : 0);
	//return false;
	var email = trim($("#email").val());
	var cemail = trim($("#cemail").val());
	
	if(email =="")
	{
		$("#reg_err").html("Please enter email address");
		ge('email').focus();
		return false;
	}
	else if(!isValidEmail(email))
	{
		$("#reg_err").html("Please enter valid email address");
		ge('email').focus();
		return false;
	}
	else if(cemail =="")
	{
		$("#reg_err").html("Please enter confirm email address");
		ge('cemail').focus();
		return false;
	}
	else if(cemail != email )
	{
		$("#reg_err").html("Email address mismatch");
		ge('cemail').focus();
		return false;
	}
	else if(!$("#country").val())
	{
		$("#reg_err").html("Please select country");
		ge('country').focus();
		return false;
	}
	else if(!$('input[@name="privacy"]').is(':checked'))
	{
		$("#reg_err").html("Please select privacy policy");
		ge('privacy').focus();
		return false;
	}
	
	var privacy		= $('input[@name="privacy"]').is(':checked')? 1 : 0;
	var newsletter 	= $('input[@name="newsletter"]').is(':checked')? 1 : 0;
	
	if($("#prodid"))
		var prodid = $("#prodid").val();
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'view/save',
	data : 'prodid='+prodid+'&email='+email+'&country='+$("#country").val()+'&newsletter='+newsletter+'&privacy='+privacy+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
	
	return false;
}


function userlogin()
{
	l = new dialog( {title:'', width:250, height:100, onclose:'l.close()', ismodel:false, isdrag:true} );
	l.sethtml( 'Loading...' ); 
	l.show();

	$.ajax({
	type : "POST",
	url	 : baseurl+'user_mod/login',
	data : 'rand='+Math.random(),
	dataType: "html",
	success: function(html){		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
}

function check_loginuser()
{
	var email 	 = trim($("#email").val());
	var password = trim($("#pwd").val());
	//$("#errUser").html("");
	//$("#errPass").html("");

	if(email =="")
	{
		$("#reg_err").html("Please enter email address");
		ge('email').focus();
		return false;
	}
	else if(!isValidEmail(email))
	{
		$("#reg_err").html("Please enter valid email address");
		ge('email').focus();
		return false;
	}
	else if(password =="")
	{
		$("#reg_err").html("Please enter password");
		ge('pwd').focus();
		return false;
	}
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'user_mod/valid',
	data : 'email='+email+'&password='+password+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		if(html ==1)
			$("#reg_err").html("Invalid email or password");
		else
		{
			$("#divLogin").html("<span class='blacktext'>Successfully logged wait you will redirect soon!...</span>");	
			window.setTimeout(function(){window.location.href=window.location.href;}, 1000);
		}
		// l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	
	return false;
}

function funProductInfo(prodid)
{
	l = new dialog( {title:'', width:500, height:200, onclose:'l.close()', ismodel:true, isdrag:false,top:10} );
	l.sethtml( 'Loading...' ); 
	l.show();

	$.ajax({
	type : "POST",
	url	 : baseurl+'product_more_info',
	data : 'prodid='+prodid+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
}
function check_product_moreinfo()
{
	
	var vEmail	 = trim($("#txtMoreEmail").val());
	var vFName	 = trim($("#txtFName").val());
	var vLName	 = trim($("#txtLName").val());
	var vCompany = trim($("#txtCompany").val());
	var vTitle	 = trim($("#txtTitle").val());
	var vWebSite = trim($("#txtWebSite").val());
	var vCountry = trim($("#txtCountry").val());
	var vState	 = trim($("#txtState").val());
	var vPhone	 = trim($("#txtPhone").val());
	var vAbout	 = trim($("#txtAbout").val());
	var vIndestry = trim($("#txtIndestry").val());
	var vPurchase = trim($("#txtPurchase").val());
	var vComment  = trim($("#txtComment").val());
			
	if(vEmail =="")
	{
		$("#reg_err").html("Please enter email address");
		ge('txtMoreEmail').focus();
		return false;
	}
	else if(!isValidEmail(vEmail))
	{
		$("#reg_err").html("Please enter valid email address");
		ge('txtMoreEmail').focus();
		return false;
	}
	else if(vFName =="")
	{
		$("#reg_err").html("Please enter first name");
		ge('txtFName').focus();
		return false;
	}
	else if(vLName =="")
	{
		$("#reg_err").html("Please enter last name");
		ge('txtLName').focus();
		return false;
	}
	else if(!$("#txtCountry").val())
	{
		$("#reg_err").html("Please select country");
		ge('txtCountry').focus();
		return false;
	}
	else if(!$("#txtState").val())
	{
		$("#reg_err").html("Please select state");
		ge('txtState').focus();
		return false;
	}
	else if(vPhone =="")
	{
		$("#reg_err").html("Please enter phone");
		ge('txtPhone').focus();
		return false;
	}
	else if(!isPhoneNumber(vPhone))
	{
		$("#reg_err").html("Please enter valid phone number");
		ge('txtPhone').focus();
		return false;
	}
	else if(vComment !="")
	{
		if(!allowedCharacter(document.getElementById('txtComment'),1000))
		{
		$("#reg_err").html("Message should not be more then 1000 characters");
		ge('txtComment').focus();
		return false;
		}
    }
	var vNewsletter 	= $('input[@name="chkNewsletter"]').is(':checked')? 1 : 0;
	if($("#prodid"))
		var vProdid = $("#prodid").val();
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'product_more_info/save',
	data : 'prodid='+vProdid+'&email='+vEmail+'&fname='+vFName+'&lname='+vLName+'&company='+vCompany+'&title='+vTitle+'&website='+vWebSite+'&country='+vCountry
			+'&state='+vState+'&phone='+vPhone+'&about='+vAbout+'&indestry='+vIndestry+'&purchase='+vPurchase+'&comment='+vComment+'&newsletter='+vNewsletter+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
	return false;
}

//#!-- stay connected

function check_stay_connect()
{
	var vEmail	 = trim($("#txtStayEmail").val());
	var vCountry = trim($("#cmdSelect").val());
	var vTerms   = $('input[@name="chkbox"]').is(':checked')? 1 : 0;
	
	if((vEmail =="") || (vEmail =="Email Address"))
	{
		$("#stay_err").html("Please enter email address");
		ge('txtStayEmail').focus();
		return false;
	}
	else if(!isValidEmail(vEmail))
	{
		$("#stay_err").html("Please enter valid email address");
		ge('txtStayEmail').focus();
		return false;
	}
	else if(vCountry =="")
	{
		$("#stay_err").html("Please select country");
		ge('cmdSelect').focus();
		return false;
	}
	else if(vTerms ==0)
	{
		$("#stay_err").html("You should accept the privacy policy");
		ge('chkbox').focus();
		return false;
	}
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'stay/connect',
	data : 'email='+vEmail+'&country='+vCountry+'&terms='+vTerms+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		$("#full_err").html(html);
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
		//setTimeout('funClear()',3000);
	}
	});
	return false;

}
function funClear()
{
	document.getElementById('txtEmail').value = "Email Address";
	document.getElementById('cmdSelect').value = "";
	document.getElementById('chkbox').checked = false;
	document.getElementById('reg_err').innerHTML="";
}

function clearTextfield()
{
	if(document.getElementById('txtEmail').value == "Email Address")
		document.getElementById('txtEmail').value ="";
		document.getElementById('txtEmail').focus;
}
/*
function funPrivacy()
{
	l = new dialog( {title:'', width:500, height:100, onclose:'l.close()', ismodel:true, isdrag:false, top:100} );
	l.sethtml( 'Loading...' ); 
	l.show();

	$.ajax({
	type : "POST",
	url	 : '/zecurion/privacy',
	data : 'rand='+Math.random(),
	dataType: "html",
	success: function(html){		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});

}
*/
// JavaScript Document
//#!-- comparision chart
function funPrivacy()
{
	l = new dialog( {title:'', width:500, height:100, onclose:'l.close()', ismodel:true, isdrag:false,top:100} );
	l.sethtml('Loading...'); 
	l.show();
	$.ajax({
	type : "POST",
	url	 : baseurl+'privacy',
	data : 'type=popup&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);		
		l.sethtml(html);
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
}


function funForgetPassword()
{
	//alert(pmQuesId);
	$.ajax({
	type : "POST",
	url	 : baseurl+'user_mod/forgotpassword',
	data : 'rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);
		//alert($("#divNews");
		$("#divPassword").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	//return false;
}

function check_forgotpassword()
{
	var email 	 = trim($("#email").val());
	if(email =="")
	{
		$("#reg_err").html("Please enter email address");
		ge('email').focus();
		return false;
	}
	else if(!isValidEmail(email))
	{
		$("#reg_err").html("Please enter valid email address");
		ge('email').focus();
		return false;
	}
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'user_mod/forgotvalid',
	data : 'email='+email+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		if(html ==0)
			$("#reg_err").html("Invalid email address");
		else
		{
			$("#divPass").html("<br><span class='blacktext'>Password sent to your email Address</span><br><br>");	
			window.setTimeout(function(){window.location.href=window.location.href;}, 1000);
		}
		// l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	
	return false;

}


