// JavaScript Document

function contactus()
{
	$.ajax({
	type : "POST",
	url	 : baseurl+'contactus/view',
	data : 'rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);
		//alert($("#divNews");
		$("#divContactUs").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	//return false;
}
function MaxCheck1()
{
	if(!allowedCharacter(document.getElementById('txtMsg'),1000))
	{
		$("#reg_err").html("Message should not be more then 1000 characters");
		ge('txtMsg').focus();
		return false;
	}

}
function isRegExpSupported()
{

//#-- are regular expressions supported?
		if (window.RegExp)
		{
			//#-- assign expression
				var vTempStr = "a";
				var vTempReg = new RegExp(vTempStr);
				//#-- return status
				return (vTempReg.test(vTempStr));
		}
		//#-- return status
		return (false);

} //#-- close of isRegExpSupported()
function isPhoneNumber(str){
  var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
  return re.test(str);
}
function check_contactus()
{
	var vEmail	 = trim($("#txtEmail").val());
	var vFName	 = trim($("#txtFName").val());
	var vLName	 = trim($("#txtLName").val());
	var vCompany = trim($("#txtCompany").val());
	var vPhone	 = trim($("#txtPhone").val());
	var vComment  = trim($("#txtMsg").val());
			
	
	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(!isPhoneNumber(vPhone) && (vPhone!=""))
	{
		$("#reg_err").html("Please enter valid phone number");
		ge('txtPhone').focus();
		return false;
	}
	else if(vEmail =="")
	{
		$("#reg_err").html("Please enter email address");
		ge('txtEmail').focus();
		return false;
	}
	else if(!isValidEmail(vEmail))
	{
		$("#reg_err").html("Please enter valid email address");
		ge('txtEmail').focus();
		return false;
	}
	else if(vComment =="")
	{
		$("#reg_err").html("Please enter message");
		ge('txtMsg').focus();
		return false;
	}
	else if(!allowedCharacter(document.getElementById('txtMsg'),1000))
	{
		$("#reg_err").html("Message should not be more then 1000 characters");
		ge('txtMsg').focus();
		return false;
	}
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'contactus/save',
	data : 'email='+vEmail+'&fname='+vFName+'&lname='+vLName+'&company='+vCompany+'&phone='+vPhone+'&comment='+vComment+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		$("#divContactUs").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
		//setTimeout('funContactClear()',2000);
	}
	});
	return false;
}

function funContactClear()
{
	document.getElementById('txtEmail').value = "";
	document.getElementById('txtFName').value = "";
	document.getElementById('txtLName').value = "";
	document.getElementById('txtCompany').value = "";
	document.getElementById('txtPhone').value = "";
	document.getElementById('txtMsg').value = "";
	document.getElementById('reg_err').innerHTML="";
}


// JavaScript Document  suppoet
function support()
{
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'support/view',
	data : 'rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);
		//alert($("#divNews");
		$("#divSupport").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	//return false;

}

function allowedCharacter(vObject, vAllowedLength)
{
		/****************************
		// vObject 			= text area control name
		// vAllowedLength 	= Length of character should be in text area
		****************************/

		// Check whether the character entered in the text area is greater then the given Allowed length
		if (vObject.value.length > vAllowedLength)
		{
			// Cut the remaining character which exceeds the Allowed length
			vObject.value = vObject.value.substring(0,(vAllowedLength));
			return false;	// return value
		}
	return true;	// return value
} 

function MaxCheck()
{
	if(!allowedCharacter(document.getElementById('txtComment'),1000))
	{
		$("#reg_err").html("Comment should not be more then 1000 characters");
		ge('txtComment').focus();
		return false;
	}

}



function check_support()
{
	var vEmail	 = trim($("#txtEmail").val());
	var vName	 = trim($("#txtName").val());
	var vIssue	 = trim($("#txtIssue").val());
	var vComment  = trim($("#txtComment").val());
			
	
	if(vName =="")
	{
		$("#reg_err").html("Please enter name");
		ge('txtName').focus();
		return false;
	}
	else if(vEmail =="")
	{
		$("#reg_err").html("Please enter email address");
		ge('txtEmail').focus();
		return false;
	}
	else if(!isValidEmail(vEmail))
	{
		$("#reg_err").html("Please enter valid email address");
		ge('txtEmail').focus();
		return false;
	} 
	else if(vIssue =="")
	{
		$("#reg_err").html("Please select the issue");
		ge('txtIssue').focus();
		return false;
	}
	else if(vComment =="")
	{
		$("#reg_err").html("Please enter comment");
		ge('txtComment').focus();
		return false;
	}
	else if(!allowedCharacter(document.getElementById('txtComment'),1000))
	{
		$("#reg_err").html("Comment should not be more then 1000 characters");
		ge('txtComment').focus();
		return false;
	}
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'support/save',
	data : 'email='+vEmail+'&name='+vName+'&issue='+vIssue+'&comment='+vComment+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		$("#divSupport").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
		//setTimeout('funSupportClear()',2000);
		return false;
	}
	});
	return false;
}


function funSupportClear()
{
	document.getElementById('txtName').value = "";
	document.getElementById('txtEmail').value = "";
	document.getElementById('txtIssue').value = "";
	document.getElementById('txtComment').value = "";
	document.getElementById('reg_err').innerHTML="";
}

// JavaScript Document
//#!-- comparision chart
function funComparsionChart()
{
	l = new dialog( {title:'', width:500, height:100, onclose:'l.close()', ismodel:true, isdrag:false ,top:10,left:50} );
	l.sethtml( 'Loading...' ); 
	l.show();
	$.ajax({
	type : "POST",
	url	 : baseurl+'compare',
	data : 'type=popup&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);		
		l.sethtml( html );
		l.resizeDialog();
		//d.setHeight(200);
	}
	});
}

// JavaScript Document
//#!-- faq question
function check_question()
{
	var vEmail	 = trim($("#txtEmail").val());
	var vName	 = trim($("#txtName").val());
	var vTopic	 = trim($("#cmdTopic").val());
	var vQuestion  = trim($("#txtQuestion").val());
			
	if(vName =="")
	{
		$("#Qes_err").html("Please enter name");
		ge('txtName').focus();
		return false;
	}
	else if(vEmail =="")
	{
		$("#Qes_err").html("Please enter email address");
		ge('txtEmail').focus();
		return false;
	}
	else if(!isValidEmail(vEmail))
	{
		$("#Qes_err").html("Please enter valid email address");
		ge('txtEmail').focus();
		return false;
	} 
	else if(vTopic =="")
	{
		$("#Qes_err").html("Please select the topic");
		ge('cmdTopic').focus();
		return false;
	}
	else if(vQuestion =="")
	{
		$("#Qes_err").html("Please enter question");
		ge('txtQuestion').focus();
		return false;
	}
	else if(!allowedCharacter(document.getElementById('txtQuestion'),100))
	{
		$("#Qes_err").html("Comment should not be more then 100 characters");
		ge('txtQuestion').focus();
		return false;
	}
	$.ajax({
	type : "POST",
	url	 : baseurl+'faq/save',
	data : 'email='+vEmail+'&name='+vName+'&topic='+vTopic+'&question='+vQuestion+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		$("#Qes_err").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
		
		setTimeout('funclear()',4000);
	}
	});
	return false;
}
function QuesMaxCheck()
{
	if(!allowedCharacter(document.getElementById('txtQuestion'),100))
	{
		$("#Qes_err").html("Question should not be more then 100 characters");
		ge('txtQuestion').focus();
		return false;
	}

}
function funclear()
{
	document.getElementById('txtName').value = "";
	document.getElementById('txtEmail').value = "";
	document.getElementById('cmdTopic').value = "";
	document.getElementById('txtQuestion').value = "";
	document.getElementById('Qes_err').innerHTML="";
}

//#!-- faq question
function check_qesComment(pmQuestId)
{
	var vEmail	 = trim($("#txtComEmail"+pmQuestId).val());
	var vName	 = trim($("#txtComName"+pmQuestId).val());
	var vQuestionId	 = trim($("#hidQuestionId"+pmQuestId).val());
	var vComment  = trim($("#txtComComment"+pmQuestId).val());
			
	
	if(vName =="")
	{
		$("#QesComment_err"+pmQuestId).html("Please enter name");
		ge('txtComName'+pmQuestId).focus();
		return false;
	}
	else if(vEmail =="")
	{
		$("#QesComment_err"+pmQuestId).html("Please enter email address");
		ge('txtComEmail'+pmQuestId).focus();
		return false;
	}
	else if(!isValidEmail(vEmail))
	{
		$("#QesComment_err"+pmQuestId).html("Please enter valid email address");
		ge('txtComEmail'+pmQuestId).focus();
		return false;
	} 
	else if(vComment =="")
	{
		$("#QesComment_err"+pmQuestId).html("Please enter comment");
		ge('txtComComment'+pmQuestId).focus();
		return false;
	}
	else if(!allowedCharacter(document.getElementById('txtComComment'+pmQuestId),100))
	{
		$("#QesComment_err"+pmQuestId).html("Comment should not be more then 100 characters");
		ge('txtComComment'+pmQuestId).focus();
		return false;
	}
	$.ajax({
	type : "POST",
	url	 : baseurl+'faqcomment/save',
	data : 'email='+vEmail+'&name='+vName+'&questionid='+vQuestionId+'&comment='+vComment+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		$("#QesComment_err"+pmQuestId).html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
		setTimeout('funViewAll()',4000);
	}
	});
	return false;
}

function ComMaxCheck(pmQuestId)
{
	if(!allowedCharacter(document.getElementById('txtComComment'+pmQuestId),100))
	{
		$("#QesComment_err"+pmQuestId).html("Question should not be more then 100 characters");
		ge('txtComComment'+pmQuestId).focus();
		return false;
	}

}

function funDisplayList()
{
	//var vCurpage = trim($("#vcurpage").val());
	var vCurpage  = document.frmForm.vcurpage.value;
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'faqlist',
	data : 'vCurpage='+vCurpage+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		$("#divPhoto").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	//return false;
}

function funpaging(pmPageId)
{
	document.frmForm.vcurpage.value = pmPageId;
	funDisplayList();
}

//#!-- list the comment details
function funCommentList(pmQuesId)
{
	//alert(pmQuesId);
	$.ajax({
	type : "POST",
	url	 : baseurl+'commentlist',
	data : 'quesId='+pmQuesId+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);
		//alert($("#divNews");
		$("#divNews"+pmQuesId).html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	//return false;
}

function funAddComment(pmQuesId)
{
	//alert(pmQuesId);
	$.ajax({
	type : "POST",
	url	 : baseurl+'addcomment',
	data : 'quesId='+pmQuesId+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html);
		//alert($("#divNews");
		//alert(document.getElementById("divNews"));
		document.getElementById("divNews"+pmQuesId).innerHTML=html;		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
}

//#!-- view all
function funViewAll()
{
	//alert('type=all'+'&rand='+Math.random());
	$.ajax({
	type : "POST",
	url	 : baseurl+'faqlist',
	data : 'type=all'+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html)
		$("#divPhoto").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});
	//return false;

}


function funfaqbyTopic(pmTopicId)
{
	
	$.ajax({
	type : "POST",
	url	 : baseurl+'faqlist',
	data : 'type=all'+'&topicId='+pmTopicId+'&rand='+Math.random(),
	dataType: "html",
	success: function(html){
		//alert(html)
		$("#divPhoto").html(html);		
		//l.sethtml( html );
		//l.resizeDialog();
		//d.setHeight(200);
	}
	});

}

