/*jslint browser: true , hl_apply_checkbox: true */
/*global browser: true , hl_apply_checkbox: true */ 
function validate_forum_form(frm,web_path){
	var fname = document.getElementById('fname');
	var email = document.getElementById('email');
	var final_post_text = document.getElementById('final_post_text');
	var txtCaptcha = document.getElementById('txtCaptcha');

if(fname.value ==''){
	alert("Please enter your Name.");
	 fname.focus();
	return false;
}else if(email.value ==''){
	alert("Please enter your Email-ID.");
	email.focus();
	return false;
}else if(checkEmail(email.value) === false){
    alert("Please enter valid email-Id.\n Eg. example@domain.com");
	email.focus();
	return false;
}else if(txtCaptcha.value == ''){
    alert("Please enter the varification code");
	txtCaptcha.focus();
	return false;
} else {


	var act = 'captcha_frm';
	var bodyVars = {
		action : act ,
		txtCaptcha  :txtCaptcha.value
	};
	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, Captcha_forum_Response, false, null);
	return false;

	//return true;
}
}

// Function for calling AJAX request for yes or no user DNC confirmation
function ajaxYesNoConfirmation(quick_lead_id)
{
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
						xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}

		xmlhttp.onreadystatechange=function()
		{
						if (xmlhttp.readyState==4 && xmlhttp.status==200)
						{
										//alert(xmlhttp.responseText);
						}
		}

		xmlhttp.open("GET","../../ajaxYesNoConfirmation.php?quick_lead_id="+quick_lead_id,true);
		xmlhttp.send();
}

function Captcha_forum_Response(text, headers, callingContext){
	//alert(text);
	var fname = document.getElementById('fname');
	var email = document.getElementById('email');
	var final_post_text = document.getElementById('final_post_text');

	if(text != 'true'){
		document.getElementById('result_captcha').innerHTML = text;
		return false;
	}
	//window.document.hl_cons_form.action = "?action_type=insert_hl_consultant";
	//document.getElementById("forum_form").submit();
	//return true;
	var bodyVars = {
		action : 'forum_form' ,
		fname :fname.value ,
		email :email.value ,
		final_post_text :final_post_text.value 
	};
	var URLVars = ''; 
	ajaxCaller.postVars("ajax_common.php", bodyVars,URLVars, forum_Response, false, null);
	return false;

		
	//document.getElementById('light').style.display='block';
    //window.location.hash = "#"; 
	//document.getElementById('final_product_item_ids').value = document.getElementById('tempids').value 

}

function forum_Response(text, headers, callingContext){
	//document.getElementById('apply-form-new-content').innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="http://www.rupeetalk.com/images/loader-big.gif"></td><td class="ver11blue">Fetching...</td></tr></table>';
	document.getElementById('apply-form-new-content').innerHTML = text;

}

function validate_expert_form(frm,web_path){
	var name = document.getElementById('expert_form_name');
	var mobile = document.getElementById('expert_form_mobile');
	var email = document.getElementById('expert_form_email');
	var city = document.getElementById('expert_form_city');
	var query = document.getElementById('query');
	var txtCaptcha = document.getElementById('expert_txtCaptcha');

if(name.value ==''){
	alert("Please enter your Name.");
	 name.focus();
	return false;
}else if(mobile.value ==''){
	alert("Please enter your mobile.");
	mobile.focus();
	return false;
}else if(email.value ==''){
	alert("Please enter your Email-ID.");
	email.focus();
	return false;
}else if(checkEmail(email.value) === false){
    alert("Please enter valid email-Id.\n Eg. example@domain.com");
	email.focus();
	return false;
}else if(city.value ==''){
	alert("Please enter your City.");
	city.focus();
	return false;
}else if(query.value ==''){
	alert("Please enter your query.");
	query.focus();
	return false;
}else if(txtCaptcha.value == ''){
    alert("Please enter the varification code");
	txtCaptcha.focus();
	return false;
} else {


	var act = 'captcha_frm';
	var bodyVars = {
		action : act ,
		txtCaptcha  :txtCaptcha.value 
	};
	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, Captcha_expert_Response, false, null);
	return false;

	//return true;
}
}

function Captcha_expert_Response(text, headers, callingContext){
	var name = document.getElementById('expert_form_name');
	var mobile = document.getElementById('expert_form_mobile');
	var email = document.getElementById('expert_form_email');
	var city = document.getElementById('expert_form_city');
	var query = document.getElementById('query');
	//alert(text);
	if(text != 'true'){
		document.getElementById('expert_result_captcha').innerHTML = text;
		return false;
	}
	//window.document.hl_cons_form.action = "?action_type=insert_hl_consultant";
	//document.getElementById("forum_form").submit();
	//return true;
	var bodyVars = {
		action : 'expert_form' ,
		name :name.value ,
		city :city.value ,
		email :email.value ,
		mobile :mobile.value ,
		query :query.value 
	};
	var URLVars = ''; 
	ajaxCaller.postVars("ajax_common.php", bodyVars,URLVars, expert_Response, false, null);
	return false;

		
	//document.getElementById('light').style.display='block';
    //window.location.hash = "#"; 
	//document.getElementById('final_product_item_ids').value = document.getElementById('tempids').value 

}

function expert_Response(text, headers, callingContext){
	//alert(text);
	//document.getElementById('apply-form-new-content').innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="http://www.rupeetalk.com/images/loader-big.gif"></td><td class="ver11blue">Fetching...</td></tr></table>';
	document.getElementById('apply-form-new-content1').innerHTML = '';
	document.getElementById('apply-form-new-content1').innerHTML = text;

}

function validate_download_form(form){
		if(trim(document.getElementById("download_name").value) == ""){
		alert("Please enter your name");
		document.getElementById("download_name").focus();
		return false;
		}
		if(trim(document.getElementById("download_email").value) == "")
        {
		alert("Please enter your email address.");
		document.getElementById("download_email").focus();
		return false;
        }
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = trim(document.getElementById("download_email").value);
		if(reg.test(address) == false)
		{
		 alert('Your email address seems incorrect. Please try again.');
		document.getElementById("download_email").focus();
		 return false;
		}
document.getElementById("download_form").submit();
document.getElementById("ppt-download-form").style.display = 'none';
document.getElementById("dld_msg").style.display = '';
return true;
}


function show_market_live(div,web_path){
	
	var sensex_liv_img = '<img src="http://www.bseindia.com/Sensex/charts/Sensex.png" border="0"/>';
	var nifty_liv_img = '<img src="http://www.nseindia.com/nifty_new.png" border="0" width="280px" height="170px"/>';

	if(div=='sensex_img'){
       document.getElementById(div).src = web_path+'images/sensex-blue.gif';
       document.getElementById('nifty_img').src = web_path+'images/nifty-grey.gif';
       document.getElementById('sensex_tr').style.display ='';
       document.getElementById('nifty_tr').style.display ='none';
	   document.getElementById("market_live").innerHTML = sensex_liv_img;
	   document.getElementById("more-stock-td").innerHTML = '<a href="stock-bse.php">View more &raquo;</a>';

	}
	if(div=='nifty_img'){
	   document.getElementById(div).src = web_path+'images/nifty-blue.gif';
       document.getElementById('sensex_img').src = web_path+'images/sensex-grey.gif';
	   document.getElementById('nifty_tr').style.display ='';
	   document.getElementById('sensex_tr').style.display ='none';
	   document.getElementById("market_live").innerHTML = nifty_liv_img;
	   document.getElementById("more-stock-td").innerHTML = '<a href="stock-nse.php">View more &raquo;</a>';
	}

}


function validate_hl_cons_form(web_path){
var customer_name = document.getElementById('customer_name');
var mobile = document.getElementById('mobile');
var email = document.getElementById('email');
var total_exp = document.getElementById('total_exp');
var monthly_income = document.getElementById('monthly_income');
var DOB_Month = document.getElementById('DOB_Month');
var DOB_Day = document.getElementById('DOB_Day');
var DOB_Year = document.getElementById('DOB_Year');
var city_id = document.getElementById('city_id');
var other_emi = document.getElementById('other_emi');
var property_value = document.getElementById('property_value');
var loan_amt = document.getElementById('loan_amt');
var repay_period = document.getElementById('repay_period');
var occupation = document.getElementById('occupation');
var txtCaptcha = document.getElementById('txtCaptcha').value;

if(customer_name.value ==''){
	alert("Please enter your Name.");
	 customer_name.focus();
	return false;
}else if(mobile.value ==''){
	alert("Please enter your mobile number.");
	mobile.focus();
	return false;
}else
if(ValidateContact(mobile) === false){
    return false;
}else
if(email.value ==''){
	alert("Please enter your Email-ID.");
	email.focus();
	return false;
}else
if(checkEmail(email.value) === false){
    alert("Please enter valid email-Id.\n Eg. example@domain.com");
	email.focus();
	return false;
}else
if(total_exp .value ==''){
	alert("Please select your work experience.");
	total_exp.focus();
	return false;
}else
if(other_emi .value ==''){
	alert("Please enter your EMI.");
	other_emi.focus();
	return false;
}else
if(property_value.value ==''){
	alert("Please enter the property value.");
	property_value.focus();
	return false;
}else
if(loan_amt.value ==''){
	alert("Please enter the loan amount.");
	loan_amt.focus();
	return false;
}else
if(repay_period.value ==''){
	alert("Please select your repayment period");
	repay_period.focus();
	return false;
}else
if(monthly_income.value ==''){
	alert("Please enter your monthly income");
	monthly_income.focus();
	return false;
}else
if(occupation.value ==''){
	alert("Please select your occupation");
	occupation.focus();
	return false;
}else
if(DOB_Month.value ==''){
	alert("Please select month for date of birth.");
	DOB_Month.focus();
	return false;
}else
if(DOB_Day.value ==''){
	alert("Please select day for date of birth.");
	DOB_Day.focus();
	return false;
}else
if(DOB_Year.value ==''){
	alert("Please select year for date of birth.");
	DOB_Year.focus();
	return false;
}else
if(city_id.value ==''){
    alert("Please select city.");
	city_id.focus();
	return false;
} else {


	var act = 'captcha_frm';
	var bodyVars = {
		action : act ,
		txtCaptcha :txtCaptcha 
	};
	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, CaptchaResponse, false, null);
	return false;

	//return true;
}
}

function CaptchaResponse(text, headers, callingContext){
	//alert(text);
	if(text != 'true'){
		document.getElementById('result_captcha').innerHTML = text;
		return false;
	}
	//window.document.hl_cons_form.action = "?action_type=insert_hl_consultant";
	document.getElementById("hl_cons_form").submit();
	return true;

		
	//document.getElementById('light').style.display='block';
    //window.location.hash = "#"; 
	//document.getElementById('final_product_item_ids').value = document.getElementById('tempids').value 

}






//--------------------------------------------//

function checkboxcount_apply(rate_alerts_form,web_path){
	var total_chk = 0;
	var apply_ids = '';
	for (var i=0; i < rate_alerts_form.checkgroup.length; i++)
	{
			if (rate_alerts_form.checkgroup[i].checked==1)
			{
				total_chk++;
				apply_ids = apply_ids + "," + rate_alerts_form.checkgroup[i].value;
			}
	}	
	if(total_chk > 4){
		alert("You can only select up to 4 products at a time!");
		//document.getElementById("age").focus();
		return false;

	} else if(total_chk === 0){
		alert("check atleast one checkbox");
		return false;
	} else {
		//alert(apply_ids);
		apply_ids = apply_ids.substring(1,apply_ids.length);
		document.getElementById('final_product_item_ids').value = apply_ids;
		$(function() {
		var height = $(document).height();
		var width = $(document).width();
		var left_pos = (width-450)/2;
		//$('#fade_hl_consl').fadeIn(700);
		document.getElementById('fade_apply').style.height = height+'px';
		document.getElementById('fade_apply').style.display='block';

		document.getElementById('light_apply').style.left = left_pos+'px';
		document.getElementById('fade_apply').style.width = width+'px';

		document.getElementById('light_apply').style.display='block';
		document.getElementById('fade_apply').style.display='block';
		});
		return false;
	}

}

function display_forum_form(topic_id,display_forum_text_feild){

		if(display_forum_text_feild == 'forum_post_text_home_loan'){
	
			document.getElementById('final_post_text').value = document.getElementById('forum_post_text_home_loan').value;

		} else if(display_forum_text_feild == 'forum_post_text_health'){
			document.getElementById('final_post_text').value = document.getElementById('forum_post_text_health').value;

		} else if(display_forum_text_feild == 'forum_post_text_personalloan'){
			document.getElementById('final_post_text').value = document.getElementById('forum_post_text_personalloan').value;

		} else if(display_forum_text_feild == 'forum_post_text_education'){
			document.getElementById('final_post_text').value = document.getElementById('forum_post_text_education').value;

		} else if(display_forum_text_feild == 'forum_post_text_life'){
			document.getElementById('final_post_text').value = document.getElementById('forum_post_text_life').value;

		}
		document.getElementById('topic_id').value = topic_id;
		document.getElementById('light_forum').style.display='block';
		document.getElementById('fade_forum').style.display='block';

}
function display_expert_form(asktheexpert_post_text){

		//alert(asktheexpert_post_text);

		if(document.getElementById(asktheexpert_post_text) != null)
			document.getElementById('query').value = document.getElementById(asktheexpert_post_text).value;

		//document.getElementById('topic_id').value = topic_id;
		document.getElementById('light_expert').style.display='block';
		document.getElementById('fade_expert').style.display='block';

}

function display_form_2(product_id){
		//alert(product_id);
		document.getElementById('final_product_item_ids').value = product_id;
		document.getElementById('light_apply').style.display='block';
		document.getElementById('fade_apply').style.display='block';
}

function checkboxcount_compare(rate_alerts_form,web_path,product_name_dis){

	//alert("dfdf");
	var total_chk = 0;
	var compare_ids = '';
	for (var i=0; i<rate_alerts_form.checkgroup.length; i++)
	{
			if (rate_alerts_form.checkgroup[i].checked==1)
			{
				total_chk++;
				compare_ids = compare_ids + "," + rate_alerts_form.checkgroup[i].value;
			}
	}	
	if(total_chk > 4){
		alert("You can only select up to 4 products at a time!");
		//document.getElementById("age").focus();
		return false;

	} else if(total_chk === 0){
		alert("check atleast one checkbox");
		return false;
	} else {
		compare_ids = compare_ids.substring(1,compare_ids.length);
		//alert(web_path+product_name_dis+"/compare-and-apply/?compare_ids="+compare_ids);
		if(product_name_dis == 'life-insurance')
			window.location = web_path+product_name_dis+"/compare-and-apply-ulip-plan/?compare_ids="+compare_ids+"#search-result";
		else if(product_name_dis == 'health-insurance')
			window.location = web_path+product_name_dis+"/compare-and-apply-individual-health-insurance/?compare_ids="+compare_ids+"#search-result";
		else if(product_name_dis == 'bank-account')
			window.location = web_path+product_name_dis+"/compare-and-apply-saving-bank-account/?compare_ids="+compare_ids+"#search-result";
		else
			window.location = web_path+product_name_dis+"/compare-and-apply/?compare_ids="+compare_ids+"#search-result";
		//alert("cvcv");
		return false;
	}
	

}

function apply_product(new_ids_str){
    document.getElementById('final_product_item_ids').value = new_ids_str;
  	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	//document.body.style.overflowY = 'hidden';
}

function popup_ApplyNow_NV()
{

	var c_value = "";
	//alert(document.hl_apply_checkbox.apply_product.length);
	for (var i=0; i < document.hl_apply_checkbox.apply_product.length; i++)
	   {
	   if (hl_apply_checkbox.apply_product[i].checked)
		  {
		  c_value = c_value + hl_apply_checkbox.apply_product[i].value + ",";
		  }
	   }

	document.getElementById('final_product_item_ids').value = c_value;
	document.getElementById('light_apply').style.display='block';
	document.getElementById('fade_apply').style.display='block';

	//document.body.style.overflowY = 'hidden';
}


function validateLoginDetails(){
        if (trim(document.getElementById("username").value) =="")
        {
            alert("Login Field can not left blank");
            document.getElementById("username").focus();
            return false;
        }
        if (document.getElementById("new_password").value =="")
        {
            alert("Password Field can not left blank");
            document.getElementById("new_password").focus();
            return false;
        }
	return true;
}
//------------special characters not allowed-------------------------------
function specialCharValidation(getVal) 
{
	   var iChars = "!@#$%^&*()+=[]\\\;,./{}|\":<>?%";
	   for (var i = 0; i < getVal.length; i++)
	   {
		   if (iChars.indexOf(getVal.charAt(i)) != -1)
		   {
					return false;
		   }
		}        
		return true;
}
//--------------- Email validation ----------------//
//----------email format validation----------------//
function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
		return (true);
	}
	return (false);
}
//-------------------------------------------------//

//--------------- First Letter in Caps----------------------------------//
function initialCap(str) {
   str = str.substr(0, 1).toUpperCase() + str.substr(1);
   return str;
}
//-------------------------------------------------//

//--------------- Mobile and land line Number Validation -------------------------------//
function ValidateContact(contact_obj){
	
	var contact = trim(contact_obj.value);
	var first_char = contact.substr(0,1);
	var len = contact.length;
  
	if(contact === '') {
		alert("Please enter contact number.\nFor mobile, E.g., 9892xxxxxx.\n");
		contact_obj.focus();
		return false;
	}
	if(IsNumeric(contact)===false) {
		alert("Please enter numeric value for contact number.\nFor mobile, E.g., 9892xxxxxx.\n");
		contact_obj.focus();
		return false;
	}
	
	if(len != 10){
			alert("Please enter a correct 10-digit contact number.\nE.g. 9892xxxxxx.");
			contact_obj.focus();
			return false;
	}
	
}
//--------------------------------------------------------------------------------//

function validateSearchBox(){
       if (document.getElementById("query").value =="")
        {
            alert("Please enter search term.");
            document.getElementById("query").focus();
            return false;
        }
		if (specialCharValidation(document.getElementById("query").value) === false)
        {
            alert("Special charaters are not allowed.");
            document.getElementById("query").focus();
            return false;
        }
	return true;
}
//------------- quick apply validation --------------------//
function validateTalktome(theform){
    var formcontent = theform.txtcontact.value;
	var name= trim(theform.txtName.value);
	var contact = trim(theform.txtcontact.value);

	if(document.getElementById("product_id").value == 0)
	{
		alert("Please select the product.");
		document.getElementById("product_id").focus();
		return false;        
	}
	if(name =="" || name == "Name")
	{
		alert("Please enter your name.");
		document.getElementById("txtName").focus();
		return false;
	}
	if(specialCharValidation(document.getElementById("txtName").value) === false)
    {
            alert("Special charaters are not allowed.");
            document.getElementById("txtName").focus();
            return false;
    }
	if(document.getElementById("quick_city").selectedIndex === 0)
	{
		alert("Please select the city.");
		document.getElementById("quick_city").focus();
		return false;        
	}
    if (contact =="" || contact == "Mobile/Tel")
	{
		alert("Please enter your mobile No.");
		document.getElementById("txtcontact").focus();
		return false;
	}
	if(ValidateContact(theform.txtcontact) === false){
       return false;
	}
	var address = trim(document.getElementById("txtEmail").value);
	if(address=="" || address=="Email"){
	   alert('Please enter your Email.');
	   document.getElementById("txtEmail").focus();
	   return false;
	}
	if(checkEmail(address) === false)
	{
	   alert('Your email address seems incorrect. Please try again.');
	   document.getElementById("txtEmail").focus();
	   return false;
	}
	return true;
}
//-------------- Check for valid numeric strings ----------------------------//

function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length === 0){
   return false;
   }

   //  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;
   }


function show()
{
	document.getElementById("txtName").value = document.getElementById("txtContent").value;
}


function closeAppPopUp(url) {
	window.location=url;
}


//Coockies Handler
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}




//------------------------Start common function for Validate Refer-a-friend.php and thankyou.php --------------------------------

// check for duplicate email in array
function arrHasDupes(A) {                          // finds any duplicate array elements using the fewest possible       comparison
		var i, j, n;
		n=A.length;
														 // to ensure the fewest possible comparisons
		for (i=0; i<n; i++) {                        // outer loop uses each item i at 0 through n
			for (j=i+1; j<n; j++) {              // inner loop only compares items j at i+1 to n
				if (A[i]==A[j]){ 
				alert(A[i]+" This email address has been already entered.");
				return true;
				}
		}	}
		return false;
}

// function for remove space from string 
function trim(str) { 

	var	str1 = str.replace(/^\s\s*/,''),
		ws = /\s/,
		i = str1.length;
	while (ws.test(str1.charAt(--i)));
	return str1.slice(0, i + 1);

}
function validate_form(form)
{
	//alert(form.length) 
	if (form.txtName.value =="" || form.txtName.value =="Name")
	{
		alert("Enter your name.");
		form.txtName.focus();
		return false;
	}
	if(form.metro_city.selectedIndex == 0)
	{
		alert("Please select city.");
		form.metro_city.focus();
		return false;
	}
	if (form.txtcontact.value =="" || form.txtcontact.value =="Mobile")
	{
		alert("Enter your mobile number.");
		form.txtcontact.focus();
		return false;
	}
	if(IsNumeric(form.txtcontact.value)==false){
       alert("Enter numbers only.")
       form.txtcontact.focus();
	   return false;
	}
	var mobile = form.txtcontact.value;
    if(mobile.length !=10){
       alert("Enter valid 10-digit mobile number.\n\n For E.g. : 9323xxxxxx")
       form.txtcontact.focus();
	   return false;
 	} 
	return true;
}

function validate_refer_friend()
{
   	if (trim(document.getElementById("name").value) =="")
	{
		alert("Please enter your name.");
		document.getElementById("name").focus();
		return false;
	}
	if (trim(document.getElementById("user_email").value) =="")
	{
		alert("Please enter your Email ID.");
		document.getElementById("user_email").focus();
		return false;
	}
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = document.getElementById("user_email").value;
	if(reg.test(address) == false)
	{
	   alert('Your email address seems incorrect. Please try again.');
	   document.getElementById("user_email").focus();
	   return false;
	}
    if (trim(document.getElementById("friend_email").value) =="")
	{
		alert("Please enter your firends Email Id.");
		document.getElementById("friend_email").focus();
		return false;
	}
	var f_email = trim(document.getElementById("friend_email").value);
	var email_arr = f_email.split(",");
	var emails=new Array();
	for(var i = 0; i < email_arr.length; i++)
	{
		
		var address = trim(email_arr[i]);
		emails[i] = address; 
		if(reg.test(address) == false)
		{
			alert(address+' this email address seems incorrect. Please try again.');
			document.getElementById("friend_email").focus();
			return false;
		}
        
	}
	if(arrHasDupes(emails)== true){
		document.getElementById("friend_email").focus();
		return false;
	}
	
	return true;
}
//------------------------End common function for Validate Refer-a-friend.php and thankyou.php --------------------------------
//--------------  Start  Thankyou.php && Refer-a-friend.php common function for gmail and yahoo contact grabber  ----------------

function show_gmail()
{
	document.getElementById('friend').style.display='block';
	document.getElementById('yahoo').style.display='none';
}
function show_yahoo()
{
	document.getElementById('yahoo').style.display='block';
	document.getElementById('friend').style.display='none';
}

function popup(domain)
{
	var u = document.getElementById("yahoo_username").value;
	var p = document.getElementById("yahoo_password").value;
	var web_path = document.getElementById("web_path").value;
   

	var gmail_username = document.getElementById("gmail_username").value;
	var gmail_password = document.getElementById("gmail_password").value;
	if(domain=='gmail'){
		if(gmail_username==''){
		alert("Enter your gmail username name.");
		document.getElementById("gmail_username").focus();  
		}else if(gmail_password==''){
		alert("Enter your password.");
		document.getElementById("gmail_password").focus();  
		}else{
			var uname = (gmail_username);//base64Encode(gmail_username);
			var pswd =  reverse(gmail_password);//base64Encode(gmail_password);
  	        window.open(web_path+'import.php?username='+uname+'&~='+pswd+'','mywindow','width=560,height=500,scrollbars=yes,resizable=1,toolbar=no, menubar=no');

		}
	}
	if(domain=='yahoo'){
		if(u==''){
		alert("Enter your yahoo user name.");
		document.getElementById("yahoo_username").focus();  
		}else if(p==''){
		alert("Enter your password.");
		document.getElementById("yahoo_password").focus();  
		}else{
		  var uname = (u);//base64Encode(u);
		  var pswd = reverse(p);//base64Encode(p);
          window.open(web_path+'yahoo/?username='+uname+'&~='+pswd+'','mywindow','width=560,height=500,scrollbars=yes,resizable=1,toolbar=no, menubar=no');
		}
	}

}


function reverse(my_str){
	
	//var my_str="Welcome to www.plus2net.com"

	var i=my_str.length;
	i=i-1;
    
	var rev ='';
	for (var x = i; x >=0; x--)
	{
	   if(rev=='') rev = (my_str.charAt(x));
	   else rev = rev+''+(my_str.charAt(x));

	}
	return rev;
}
function checkAll(field){
	if(document.getElementById("check_all").checked == true) {
		for (i = 0; i < field.length; i++){
			field[i].checked = true ;
		}
	} else {
			for (i = 0; i < field.length; i++){
			field[i].checked = false ;
			}
	}
}

//get email
function invite_friend()
{
	var myAddresses = "";
	if(document.frm.check.length)
	{
		for (i=0; i<document.frm.check.length; i++)
		{
			if(document.frm.check[i].checked==true)
			{
				if(myAddresses == "")
				myAddresses = document.frm.check[i].value;
				else
				myAddresses = myAddresses + "," + document.frm.check[i].value;

			}
		}
	}
	//document.getElementById("hidden_gmail").value = myAddresses;
	if (window.opener.document)
	window.opener.document.getElementById("friend_email").value = myAddresses;
	window.close();

}

function getEmails()
{
	var myAddresses = "";
	if(document.test.addresses.length)
	{
		for (i=0; i<document.test.addresses.length; i++)
		{
			if(document.test.addresses[i].checked==true)
			{
				if(myAddresses == "")
				myAddresses = document.test.addresses[i].value;
				else
				myAddresses = myAddresses + "," + document.test.addresses[i].value;

			}
		}
	}
	//document.getElementById("hidden_gmail").value = myAddresses;
	if (window.opener.document)
	window.opener.document.getElementById("friend_email").value = myAddresses;
	window.close();

}

//--------------  End  Thankyou.php && Refer-a-friend.php common function for gmail and yahoo contact grabber  ----------------








function popupWindow(url,w,h) {
	
	win = window.open(url ,'opupWin','width='+w+',height='+h+',left=150,top=150,resizable,scrollbars=yes');
	win.focus();
}
//------------------------------------------------------------------------------------------



// Clear default values of field
function clearvalue(field,val){
	if(trim(field.value)==val){
       field.value ='';
	}
}

// only Numeric input
function isNumberKey(evt)
{
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return 0;
 }


 //video-satkam-corner
function video_corner(div){
	    var img_path = document.getElementById('web_img_path').value; 
		
		if(div=='video_div'){
			document.getElementById('video_div').style.display ='';//'tabContentDiv selected';
			document.getElementById('corner_div').style.display ='none';// 'tabContentDiv';
		
			document.getElementById('video_img').src = img_path+'video-lt-blue.gif';
			document.getElementById('corner_img').src = img_path+'satkam-corner-blue.gif';
		}
		if(div=='corner_div'){
			document.getElementById('video_div').style.display ='none';//'tabContentDiv';
			document.getElementById('corner_div').style.display ='';//'tabContentDiv selected';

			document.getElementById('video_img').src = img_path+'video-blue.gif';
			document.getElementById('corner_img').src = img_path+'satkam-corner-lt-blue.gif';
		}
}



//---------------------- More poll Ajax code -------------------------------------
	function vote_now(poll_id){

		var all_que_td = 'all_que_td'+poll_id;
		var ans_rad = 'ans_rad'+poll_id;
		var all_que_td ='all_que_td'+poll_id;
		var cnt = 1 ;
        var img_path = document.getElementById("img_path").value;
        var web_path = document.getElementById("web_path").value;
		
		var ans_rad_obj = document.getElementsByName(ans_rad);
		for(var i =0; i<ans_rad_obj.length; i++){
			if(ans_rad_obj[i].checked==true) {
				var poll_ans_id = ans_rad_obj[i].value;
				cnt++;
				}
		}
		if(cnt==1){
			alert("Please check your opinion first.")
            ans_rad_obj[0].focus();   
		}else{
            document.getElementById(all_que_td).innerHTML = '<br><br><div align="center" valign="bottom"><img src="'+img_path+'loading.gif"></span><br><span class="ver12blue"><br>Loading...</div><br><br>'; 
            var definedFigures = {
			 action: 'more_poll',
			 ans: poll_ans_id,
			 poll_id: poll_id
			}
		
        ajaxCaller.get(web_path+"ajax_common.php", definedFigures, MorePollResponse, false, null);

		}

	}

function MorePollResponse(text, headers, callingContext) {
 

 var response = text.split("~");
 var all_que_td ='all_que_td'+response[1];
 var total_votes ='total_votes'+response[1];
 var vote_now_img ='vote_now_img'+response[1];

 document.getElementById(all_que_td).innerHTML = response[0]; 
 document.getElementById(total_votes).innerHTML = 'Total Votes: <B>'+response[2]+'</B>';
 document.getElementById(vote_now_img).innerHTML = '';

}
//---------------------- ----------------------------------------------------------
//----------Calculor On Home Page ----------------------------------------------------------
function validate_cal(){
var tage = trim(document.getElementById('tage').value); 
var rage = trim(document.getElementById('rage').value); 
if(tage==''){
	alert("Please enter your present age.")
	document.getElementById('tage').focus();
	return false;
}
if(IsNumeric(tage)==false){
	alert("Please enter a numeric value.")
	document.getElementById('tage').focus();
	return false;
}
if(rage==''){
	alert("Please enter your retirement age.")
	document.getElementById('rage').focus();
	return false;
}
if(IsNumeric(rage)==false){
	alert("Please enter a numeric value.")
	document.getElementById('rage').focus();
	return false;
}
if(tage > rage){
	alert("Present age cannot be greater than retirement age.")
	document.getElementById('rage').focus();
	return false;
}

return true;
}
//---------------------- ----------------------------------------------------------


//-------------------- Polling ajax function for polling.php -----------------------------------------------------------
function validate_polling(poll_form,web_path){
		  var ans_arr = poll_form.ans;
          var p =  poll_form.poll_id.value;
		  var ans_id_str = poll_form.ans_id_str.value;
		  var ans_str = poll_form.ans_str.value;
		  ans_str = ans_str.replace(new RegExp(/\\/g),"");
          var cnt =1;
		  for(var i=0;i<ans_arr.length;i++){
			  if(ans_arr[i].checked==true){
				  var poll_ans_id = ans_arr[i].value;
				  cnt++;
			  }
		  }
	 if(cnt==1){
		 alert("Please check your opinion first.");
		 ans_arr[0].focus();
	 }else{
		   document.getElementById('opinion_poll2').style.display ='';
           document.getElementById("result_td").innerHTML = '<br><br><span valign="bottom" align="center"><img src="'+web_path+'images/loading.gif"></span><br><span class="ver12blue"><br>Loading...</span><br><br>'; 
            var definedFigures = {
			ans: poll_ans_id,
			poll_id: p,
			answer_str:ans_str,
			answer_id_str:ans_id_str
			}
		 ajaxCaller.get(web_path+"ajax_poll.php", definedFigures, PollResponse, false, null);
	 }
      return false;
 
}
// this function will get the data from db & put it into var text with | delim. here we split them & again put that into form element
function PollResponse(text, headers, callingContext) {
	document.getElementById("result_td").innerHTML = text;
    return false;
}
//---------------------------------------------------------------------------------



//-------------------- text area max length-----------------------//
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}


//-----------flat rate---------------//
function show_flat_rate(div){
	    var img_path = document.getElementById('web_img_path').value; 
		if(div=='smallflat_div'){
			document.getElementById('smallflat_div').style.display ='';//'tabContentDiv selected';
			document.getElementById('largeflat_div').style.display ='none';// 'tabContentDiv';
		

			document.getElementById('small_flat_img').src = img_path+'small-flat2.gif';
			document.getElementById('large_flat_img').src = img_path+'large-flat.gif';
	
		}
		if(div=='largeflat_div'){
			document.getElementById('largeflat_div').style.display ='';//'tabContentDiv';
			document.getElementById('smallflat_div').style.display ='none';//'tabContentDiv selected';

			document.getElementById('small_flat_img').src = img_path+'small-flat.gif';
			document.getElementById('large_flat_img').src = img_path+'large-flat2.gif';

		}
}

//---------------- js for category drop down ----------------------------//
function show_category(web_path){
	var core_id = document.getElementById('DrpListproduct').value;
	var act = 'show_category';
	var bodyVars = {
		action : act,
		product_id : core_id
	}
	document.getElementById('category').disabled = true;
   	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, ProductCategoryResponse, false, null);
}

function ProductCategoryResponse(text, headers, callingContext) {
    text = trim(text);
	document.getElementById('category').disabled = false;
    document.getElementById('category_td').innerHTML = text;
}
//------------------------------------------------------------------------//


//---------SUbscrib now news letter home page ------------------------------------------//
function subscribe_now(core_id,web_path){
    var email = trim(document.getElementById('subscriber_email').value);
	//var source = mail_source+'-Bottom'; 
	try
	{
	   var mail_source = trim(document.getElementById('mail_source').value);
	   mail_source = mail_source+'-Bottom';
	}
	catch(err)
	{
	  var mail_source = 'subscribe_now';
	}
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var act = 'subscribe_now';
	if(email=='' || email=='Email Id'){
       alert('Please enter email address.\nE.g. email@domain.com');
		document.getElementById('subscriber_email').focus();	
		return false;
	}else
    if(reg.test(email) == false)
	{
		alert('Your email address seems incorrect.\n Please enter valid email address.\n E.g. email@domain.com');
		document.getElementById('subscriber_email').focus();	
		return false;
	}else{
		document.getElementById('subscribe-td').innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="'+web_path+'images/loading-bar.gif"></td><td class="ver11blue">subscribing...&nbsp;&nbsp;</td></tr></table>';
		var bodyVars = {
			action : act,
			email : email,
			product_id : core_id,
			mail_source : mail_source
		}
		var URLVars = ''; 
		ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, SubscribeNowResponse, false, null);
	}
}
function SubscribeNowResponse(text, headers, callingContext) {
   
   text = trim(text);
   var response = text.split("~");
   if(response[0] == 'succ'){
		//document.getElementById('subscribe-td').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue">Thank you for subscribing to Rupeetalk’s free newsletter.</td></tr></table>';
		var ref_id = response[1];
		var web_path = response[2];
		window.location = web_path+'thankyou.php?ref_id='+ref_id+'&dis_msg=newsalert';
   }
   if(response[0] == 'duplicate'){
	  document.getElementById('subscribe-td').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue">You are already subscribed.</td></tr></table>';
   }
   if(response[0] != 'duplicate' && response[0] != 'succ' ){
      document.getElementById('subscribe-td').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue" style="color:red">Error occured .Please try latter!</td></tr></table>' ;
   }
}
//--------------------------------------------------------------------------//


//---------------- Subscribe now RATE ALERT home page ------------------------------------//
function subscribe_now2(core_id,web_path){
    //var sub_mobile = 'sub_mobile'+core_id;  
    var sub_email = 'sub_email'+core_id;
	//var mobile = (document.getElementById(sub_mobile).value);
	var email = (document.getElementById(sub_email).value);
	var c = 1;   
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(email=='' || email=='E-mail'){
		if(email!='E-mail'){
			if(reg.test(email) == false)
			{
				alert('1Your email address seems incorrect.\n Please enter valid email address.\n E.g. email@domain.com');
				document.getElementById(sub_email).focus();	
			}
		}
		return false;
	}
	if(email!='' && email!='E-mail'){
			if(reg.test(email) == false)
			{
				alert('Your email address seems incorrect.\n Please enter valid email address.\n E.g. email@domain.com');
				document.getElementById(sub_email).focus();	
				return false;
			}
	}

 		if(email=='E-mail'){ email='';}
		if(email==''){
				alert('Please enter your email address.');
				document.getElementById(sub_mobile).focus();	
				return false;
		}else{
			var td = 'rate-alerts'+core_id;
			document.getElementById(td).innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="'+web_path+'images/loading-bar.gif"></td><td class="ver11blue">subscribing...&nbsp;&nbsp;</td></tr></table>';
			var act = 'subscribe_now_multi';
			var bodyVars = {
				action : act,
				product_id : core_id,
				email : email,
				mobile: mobile
          	}
			var URLVars = ''; 
			ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, SubscribeNowMultiResponse, false, null);
			return false;  
	}
	
   return false;
}


function SubscribeNowMultiResponse(text, headers, callingContext) {
 
   t = trim(text);
   var text = t.split("~");
   var core_id = text[1];
   var ref_id = text[2];
   var td =  'rate-alerts'+core_id;
   if(text[0] == "succ"){
     //document.getElementById(td).innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue">Thank you for subscribing to our free alerts.</td></tr></table>';
	  window.location = text[4]+'subscrib-thankyou.php?ref_id='+ref_id+'&dis_msg=ratealert&source='+text[3];
   }else
   if(text[0] == "duplicate"){
	  document.getElementById(td).innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue">You are already subscribed.</td></tr></table>';
   }else
   {
      document.getElementById(td).innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue" style="color:red">Error occured .Please try latter!</td></tr></table>' ;
   }
}
//---------------------------------------------------------------------------------//

//----------------------- Subscrib now newsletter home page -----------------------//
function subscribe_news(core_id,web_path){

    var email = trim(document.getElementById('news_subscriber_email').value);
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(email=='' || email=='Enter E-mail'){
       alert('Please enter email address.\nE.g. email@domain.com');
		document.getElementById('news_subscriber_email').focus();	
		return false;
	}else
    if(reg.test(email) == false)
	{
		alert('Your email address seems incorrect.\n Please enter valid email address.\n E.g. email@domain.com');
		document.getElementById('news_subscriber_email').focus();	
		return false;
	}else{
		document.getElementById('subscribenews-td').innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="'+web_path+'images/loading-bar.gif"></td><td class="ver11blue">subscribing...&nbsp;&nbsp;</td></tr></table>';
		var act = 'subscribe_now';
		var bodyVars = {
			action : act,
			product_id : core_id,
			email : email
		}
		var URLVars = ''; 
		ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, SubscribeNewsResponse, false, null);
	}

}
function SubscribeNewsResponse(text, headers, callingContext) {
   
   text = trim(text);
   var response = text.split("~");
   if(response[0] == 'succ'){
		//document.getElementById('subscribenews-td').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue">Thank you for subscribing to our free alerts.</td></tr></table>';
		var ref_id = response[1];
		window.location = response[2]+'subscrib-thankyou.php?ref_id='+ref_id+'&dis_msg=newsalert';
   }
   if(response[0] == 'duplicate'){
	  document.getElementById('subscribenews-td').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue">You are already subscribed.</td></tr></table>';
   }
   if(response[0] != 'duplicate' && response[0] != 'succ' ){
      document.getElementById('subscribenews-td').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue" style="color:red">Error occured .Please try latter!</td></tr></table>' ;
   }
  // pageTracker._trackPageview('/Subscribe/Email_Alert');
}




//------------ Cookie functions ------------------------//
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
} 
//------------ Cookie functions  end------------------------//

//-------------------Motor Insurance validation ---------------//
function policy_type_control(){
	var policy_type = document.getElementsByName('policy_type');
	if(policy_type[0].checked==true) document.getElementById('prev_insurer').disabled = true;
	else document.getElementById('prev_insurer').disabled = false; 
}

function  validate_car_insurance(){

	var fname = document.getElementById('fname').value;
	var mobile = document.getElementById('mobile').value;
	var email = document.getElementById('email').value;
	var city = document.getElementById('city').value;
	var policy_type = document.getElementsByName('policy_type');
	var make = document.getElementById('make').value;
	var mod = document.getElementById('mod').value;
	var eng_cc = document.getElementById('eng_cc').value;
	var yom = document.getElementById('yom').value;
	var st = document.getElementById('st').value;
	var prev_insurer = document.getElementById('prev_insurer').value;
	var renew_date = document.getElementById('renew_date').value;
	
	

	if(fname==''){
        alert("Please enter your full name.");
        document.getElementById('fname').focus();  
		return false;
	}
	if(mobile==''){
        alert("Please enter your mobile number.");
        document.getElementById('mobile').focus();  
		return false;
	}
	if(ValidateContact(document.getElementById('mobile'))==false){
	    return false;
	}
	if(email==''){
        alert("Please enter your email.");
        document.getElementById('email').focus();  
		return false;
 	}
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(email) == false)
	{
		alert('Your email address seems incorrect.\n Please enter valid email address.\n E.g. email@domain.com');
		document.getElementById('email').focus();	
		return false;
	}
    if(city==''){
        alert("Please select your city.");
        document.getElementById('city').focus();  
		return false;
	}
	if(policy_type[0].checked==false && policy_type[1].checked==false){
		alert("Please select policy type.");
		policy_type[0].focus();
		return false;
	}
    if(make==''){
        alert("Please select make.");
        document.getElementById('make').focus();  
		return false;
	}
	if(mod==''){
        alert("Please select model.");
        document.getElementById('mod').focus();  
		return false;
	}
	if(eng_cc==''){
        alert("Please select engine cc.");
        document.getElementById('eng_cc').focus();  
		return false;
	}
    if(yom==''){
        alert("Please select year of manufacture.");
        document.getElementById('yom').focus();  
		return false;
	}
	if(st==''){
        alert("Please select state where car is registered .");
        document.getElementById('st').focus();  
		return false;
	}
	if(renew_date==''){
        alert("Please select policy renewal date.");
        document.getElementById('renew_date').focus();    
		return false;
	}
	return true; 
}

//------------ top banner----------------//
function validate_top_banner_form(frm){

  var name = trim(frm.txtName.value);
  var contact = trim(frm.txtcontact.value);
  if(name=='' || name=='Name') {
     alert("Please enter your name.")
     frm.txtName.focus();
	 return false
  }
  if(contact == '' || contact == 'Mobile') {
     alert("Please enter your contact number.")
     frm.txtcontact.focus();
	 return false
  }
  if(ValidateContact(frm.txtcontact)==false){
       return false;
  }
  
}
//-----------------------------------------//

function fnLoading(caption, object , showimg){
	var picsrc = "";
	var data = "";
	if(showimg){
		picsrc = "<img src='"+showimg+"' align=absmiddle border=0>";
	}
	data = "<table border='0' class='clsGeneralText' width='100%'><tr><td align=center valign=middle>" + picsrc + "&nbsp; &nbsp;<br> " + caption + "</td></tr></table>";
	document.getElementById(object).innerHTML = data;
}

function fnLoading_rate_alerts(caption, object , showimg){
	var picsrc = "";
	var data = "";
	if(showimg){
		picsrc = "<img style='padding:3px 0px 0px 10px' src='"+showimg+"' align=absmiddle border=0>";
	}
	data = "<table border='0' class='clsGeneralText' width='100%'><tr height='30px'><td align=center valign=middle>" + picsrc + "&nbsp; &nbsp;<br> " + caption + "</td></tr></table>";
	document.getElementById(object).innerHTML = data;
}

function RemoveDuplicates(arr)
{
	//get sorted array as input and returns the same array without duplicates.
	var result=new Array();
	var lastValue="";
	for (var i=0; i<arr.length; i++)
	{
	var curValue=arr[i];
	if (curValue != lastValue)
	{
	result[result.length] = curValue;
	}
	lastValue=curValue;
	}
	return result;
}

function highlight_toprated(product,web_path){
	var arr = new Array('hl','pl','li','hi','cc','da');
	for(var i=0;i<6;i++){
		var div = arr[i]+'-div';
		var highlight_div = 'nav-'+arr[i];
		var link_a = arr[i]+'-link-a';
		  if(product ==  arr[i]){

			 document.getElementById(highlight_div).className = 'menu-active css-sprite-class menu-active-link-class';
			 document.getElementById(link_a).className = 'menu-active-link-class';
			document.getElementById(div).style.display ='block';
		  }else{
			 document.getElementById(div).style.display ='none';
			 document.getElementById(highlight_div).className = 'menu-white css-sprite-class';
			 document.getElementById(link_a).className = 'menu-link-part';
		  }
	}
	//var div = product+'-div';
	//var img = web_path+'images/load.gif'; 
	//var div = div; 
	//fnLoading('Please wait..',div,img);
	//var act = product;
	//var bodyVars = {
	//	action : product
	//}
	//var URLVars = ''; 
	//ajaxCaller.postVars(web_path+"ajax-top-rated.php", bodyVars,URLVars, TopRatedResponse, false, null);
	return false;
}

function TopRatedResponse(text, headers, callingContext){
	var arr = new Array('hl','pl','li','hi','cc','da','cl','el');
	var res = text.split("~");
	div = res[0]+'-div';
	for(var i=0;i<8;i++){
		 var div1 = arr[i]+'-div';
		 document.getElementById(div1).style.display = 'none';
	}
	//alert(res[1]);
	document.getElementById(div).innerHTML = res[1];
	document.getElementById(div).style.display = '';
    return false;
	//window.location = res[1]+'thankyou.php?dis_msg=order&product_id='+res[2]+'&quick_lead_id='+res[3]; 
}


function show_top_provider(tdName,web_path){
    alert(tdName);
	var arr = new Array('hl','pl','li','hi','cc','da');
	for(var i=0;i<6;i++){
      var td = 'home-'+arr[i]+'-td';  
      var div = 'home-'+arr[i]+'-div';
	  if(td == tdName){
		  alert(div)
	      document.getElementById(div).style.display ='block';
		  document.getElementById(td).className ='home-tab-active hand';
			var img = web_path+'images/load.gif'; 
			var div = div; 
			document.getElementById(div).style.border = '10px solid lightblue';
			fnLoading('Please wait..',div,img);
			var act = tdName;
			var bodyVars = {
				action : act
			}
			var URLVars = ''; 
			ajaxCaller.postVars(web_path+"ajax-top-rated.php", bodyVars,URLVars, TopRatedResponse, false, null);
			return false;

	  }else{
		  document.getElementById(div).style.display ='none';
		  document.getElementById(td).className ='home-tab-nonactive hand';
	  }
    }//for


}



/*function show_top_provider(tdName){
    
	var arr = new Array('hl','pl','li','hi','cc','da');
	for(var i=0;i<6;i++){
      var td = 'home-'+arr[i]+'-td';  
      var div = 'home-'+arr[i]+'-div';
      var cal = 'home-'+arr[i]+'-cal';
	  if(td == tdName){
	      document.getElementById(div).style.display ='block';
	      document.getElementById(cal).style.display ='block';
		  document.getElementById(td).className ='home-tab-active hand';
	  }else{
		  document.getElementById(div).style.display ='none';
		  document.getElementById(cal).style.display ='none';
		  document.getElementById(td).className ='home-tab-nonactive hand';
	  }
    }//for

}*/

function show_sg_provider(tdName){
   // alert(tdName);
	var arr = new Array('hl','pl','li','hi');
	for(var i=0;i<4;i++){
      var td = 'home-'+arr[i]+'-td1';  
      var div = 'home-'+arr[i]+'-div1';
	  if(td == tdName){
	      document.getElementById(div).style.display ='block';
		  document.getElementById(td).className ='home-tab-active hand';
	  }else{
		  document.getElementById(div).style.display ='none';
		  document.getElementById(td).className ='home-tab-nonactive hand';
	  }
    }//for

}


function home_loan_consultations(web_path){
		$(function() {
		var height = $(document).height();
		var width = $(document).width();
		var left_pos = (width-450)/2;
		//$('#fade_hl_consl').fadeIn(700);
		document.getElementById('fade_hl_consl').style.height = height+'px';
		document.getElementById('fade_hl_consl').style.display='block';

		document.getElementById('light_hl_consl').style.left = left_pos+'px';
		document.getElementById('fade_hl_consl').style.width = width+'px';
		$('#light_hl_consl').fadeIn(500);
		//document.getElementById('light_hl_consl').style.display='block';
		document.getElementById('light_hl_consl').innerHTML = document.getElementById('hidden_hl_cons').innerHTML;
		document.getElementById('hidden_hl_cons').innerHTML = "";
		window.location.hash = "#";	
		});
}

function close_lightbox(){
	if(document.getElementById('light') != null)
		document.getElementById('light').style.display='none';

	if(document.getElementById('fade') != null)
		document.getElementById('fade').style.display='none';
	if(document.getElementById('light_apply') != null)
		document.getElementById('light_apply').style.display='none';
	if(document.getElementById('fade_apply') != null)
		document.getElementById('fade_apply').style.display='none';
	if(document.getElementById('comment_light') != null)
		document.getElementById('comment_light').style.display='none';
	if(document.getElementById('comment_fade') != null)
		document.getElementById('comment_fade').style.display='none';
	if(document.getElementById('fade_forum') != null)
		document.getElementById('fade_forum').style.display='none';
	if(document.getElementById('light_forum') != null)
		document.getElementById('light_forum').style.display='none';
	if(document.getElementById('fade_expert') != null)
		document.getElementById('fade_expert').style.display='none';
	if(document.getElementById('light_expert') != null)
		document.getElementById('light_expert').style.display='none';
	
	document.body.style.overflowY = 'scroll';
}

function comment_close_lightbox(){
	document.getElementById('comment_light').style.display='none';
	document.getElementById('comment_fade').style.display='none';
	document.body.style.overflowY = 'scroll';
}

function close_lightbox_2(){
	document.getElementById('light_apply').style.display='none';
	document.getElementById('fade_apply').style.display='none';
	document.body.style.overflowY = 'scroll';
}

function hl_close_lightbox(){
	//document.getElementById('light_hl_consl').style.display='none';
	$('#light_hl_consl').fadeOut(500);
	setTimeout("document.getElementById('fade_hl_consl').style.display='none'", 300 );
	document.body.style.overflowY = 'scroll';
	document.getElementById('hidden_hl_cons').innerHTML = document.getElementById('light_hl_consl').innerHTML;
	document.getElementById('light_hl_consl').innerHTML = "";
}

function show_ajax_home_search(web_path,product_id){
	//var core_id = document.getElementById('product_type').value;
	//alert(product_id);
	//document.getElementById('home_search_div').innerHTML = document.getElementById('default_home_search_div').innerHTML;
	var act = 'show_ajax_home_search';
	var bodyVars = {
		action : act,
		product_id : product_id
	}
   	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax-home-search.php", bodyVars,URLVars, show_home_search_response, false, null);
}

function show_home_search_response(text, headers, callingContext) {
    text = trim(text);
    document.getElementById('default_home_search_div').innerHTML = text;
	return true;
}


function show_product_review_category(web_path){
	var main_peice_product_id = document.getElementById('main_peice_product_id').value;
	//alert(main_peice_product_id);
	//document.getElementById('ajax_products_div').innerHTML = document.getElementById('default_products_div').innerHTML;
	document.getElementById('ajax_company_div').innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="'+web_path+'images/loading-bar.gif"></td></tr></table>';

	var act = 'show_product_review_category';
	var bodyVars = {
		action : act,
		main_peice_product_id : main_peice_product_id
	}
	//document.getElementById('product_type').disabled = true;
   	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, show_product_review_category_response, false, null);
}

function show_product_review_category_response(text, headers, callingContext) {
    text = trim(text);
	//alert(text);
	//document.getElementById('product_type').disabled = false;
    document.getElementById('ajax_company_div').innerHTML = text;
	return true;
}

function get_review_rating(product_review){

	if(product_review.main_peice_product_id.value == ''){
		alert('Please select product');
		product_review.main_peice_product_id.focus();
		return false;
	} else if(product_review.company_name.value == ''){
		alert('Please select company');
		product_review.company_name.focus();
		return false;
	} else {
		window.location = product_review.company_name.value;
	}
}



function show_ajax_banks(web_path,bank_id){
	var core_id = document.getElementById('product_type').value;
	document.getElementById('ajax_products_div').innerHTML = document.getElementById('default_products_div').innerHTML;
	var act = 'show_ajax_banks';
	var bodyVars = {
		action : act,
		bank_id : bank_id,
		product_id : core_id
	}
	document.getElementById('product_type').disabled = true;
   	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, show_ajax_banks_response, false, null);
}

function show_ajax_banks_response(text, headers, callingContext) {
    text = trim(text);
	document.getElementById('product_type').disabled = false;
    document.getElementById('ajax_banks_div').innerHTML = text;
	return true;
}


function show_ajax_bank_products(web_path,product_id,bank_id1,product_item_id){
	var bank_id = document.getElementById('ajax_banks').value;
	//alert(bank_id);
	var act = 'show_ajax_bank_products';
	var bodyVars = {
		action : act,
		bank_id : bank_id,
		bank_id1 : bank_id1,
		product_item_id : product_item_id,
		product_id : product_id
	}
	document.getElementById('ajax_products').disabled = true;
   	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, show_ajax_bank_products_response, false, null);
}

function show_ajax_bank_products_response(text, headers, callingContext) {
    text = trim(text);
	document.getElementById('ajax_products').disabled = false;
    document.getElementById('ajax_products_div').innerHTML = text;
	return true;
}

function submit_user_comments(web_path){
		
		//alert(content);
		//exit;

		var user_name = document.getElementById('user_name');
		var r_id = document.getElementById('r_id');
		//alert(r_id);
		var user_commnets = document.getElementById('user_commnets');
		var txtCaptcha2 = document.getElementById('txtCaptcha2');


		//alert(user_commnets);

		if(user_name.value ==''){
			alert("Please enter your Name.");
			 user_name.focus();
			return false;
		} else if(user_commnets.value ==''){
			alert("Please enter Comments.");
			 user_commnets.focus();
			return false;
			
		} else {

			
			var act = 'submit_usercomment_frm';
			var bodyVars = {
				action : act ,
				user_name :user_name.value,
				r_id :r_id.value,
				txtCaptcha :txtCaptcha2.value,
				user_commnets :user_commnets.value
			}
			var URLVars = ''; 
			ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, submit_user_commentsResponse, false, null);
			return false;

		}

}


function submit_user_commentsResponse(text, headers, callingContext){
	//comment_form
	//alert(text)

	if(text == '1'){
		close_lightbox();
		alert("Thank you for your comment. Keep reviewing other products");
		
		if(document.getElementById('comment_form') != null)
			document.getElementById('comment_form').style.display='none';

	} else {
		document.getElementById('result_captcha2').innerHTML = "Invalid code plese try again !!!"
	}	
	
	//alert(text);
}


function clear_express(value,value1){
	var name = 'express_'+value
		//alert(name)
	if(value == value1){
		document.getElementById(name).value = '';
	}
}


function rebuild_express(name){
	var express_name = 'express_'+name
	if(document.getElementById(express_name).value == ''){
		document.getElementById(express_name).value = name;
	}
}

function validate_express_form(){
	if(document.getElementById('express_Name').value == '' || document.getElementById('express_Name').value == 'Name'){
		alert("Please Enter your Name");	
		document.getElementById('express_Name').value = '';
		document.getElementById('express_Name').focus();
		return false;
	}
	if(document.getElementById('express_Mobile').value == '' || document.getElementById('express_Mobile').value == 'Mobile'){
		alert("Please Enter your Contact number");	
		document.getElementById('express_Mobile').value = '';
		document.getElementById('express_Mobile').focus();
		return false;
	}
	var contact = document.getElementById('express_Mobile').value;
	var contact_obj = document.getElementById('express_Mobile');
	var len = document.getElementById('express_Mobile').value.length;
	var first_char = document.getElementById('express_Mobile').value.substr(0,1);
		if(IsNumeric(contact)===false) {
			alert("Please enter numeric value for contact number.\nFor mobile, E.g., 9892xxxxxx.\nFor landline, E.g., 022xxxxxxxx");
			contact_obj.focus();
			return false;
		}
		//alert(first_char+"="+len);
	//mobile number can not start with zero
	if(first_char == 0 || first_char == ""){
		alert("Please enter a correct 10-digit contact number. Mobile number can not start with zero.");
		contact_obj.focus();
		return false;
	}

	if(len != 10){
		alert("Please enter a correct 10-digit contact number.\nE.g. 9892xxxxxx.");
		contact_obj.focus();
		return false;
	}

	if(document.getElementById('express_Email').value == '' || document.getElementById('express_Email').value == 'Email'){
		alert("Please Enter your Email address");	
		document.getElementById('express_Email').value = '';
		document.getElementById('express_Email').focus();
		return false;
	}
	if(checkEmail(document.getElementById('express_Email').value) == false){
		alert("Please enter valid email-Id.\n Eg. example@domain.com");
		document.getElementById('express_Email').focus();
		return false;
	}
	if(document.getElementById("express_product_id").value == ''){
		alert("Please select the product.");
		document.getElementById("express_product_id").focus();
		return false;        
	}
	if(document.getElementById("express_city").value == ''){
		alert("Please select your city.");
		document.getElementById("express_city").focus();
		return false;        
	}
}


function light_box_general(white,black){
	document.getElementById(black).style.display = 'block';	
	document.getElementById(white).style.display = 'block';	
	return false;
}

function general_close(white,black){
	document.getElementById(white).style.display = 'none';	
	document.getElementById(black).style.display = 'none';	
}

function email_this_fetch(value){
	image = 'email-'+value+'.gif';
	div = 'div-'+value;
	var divs_array=new Array("div-gmail","div-yahoo","div-hotmail","div-rediff","div-orkut","div-indiatimes"); 
	for(var i=0;i<6;i++){
		if(div == divs_array[i]){
			document.getElementById(div).style.display = 'block';
		}else{
			document.getElementById(divs_array[i]).style.display = 'none';		
		}
	}
	document.getElementById(div).style.marginLeft = '5px';		
	document.getElementById('email-this-2').style.display = 'block';		
	document.getElementById('email-this-back-span').style.display = 'block';		
	document.getElementById(div).style.borderRight = '1px solid #dadada';		
	document.getElementById('domain').value = value;		
}

function email_this_initial_stage(){
	
}

function fetch_contacts(web_path){
	var domain = document.getElementById('domain').value;	
	var email = document.getElementById('email-this-email').value;	
	var password = document.getElementById('email-this-pass').value;	

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(email=='' || email=='E-mail'){
		if(email!='E-mail'){
			if(reg.test(email) == false)
			{
				alert('Your email address seems incorrect.\n Please enter valid email address.\n E.g. email@domain.com');
				document.getElementById('email-this-email').focus();	
			}
		}
		return false;
	}
	document.getElementById('email-this-back-span').style.display = 'none';	
	var td = 'email-this-2';
	document.getElementById(td).innerHTML = '<table border="0" width="100%"><tr><td align="right"><img src="'+web_path+'images/loader-big.gif"></td><td class="ver11blue">Fetching...</td></tr></table>';
	var act = 'fetch_contacts';
	var bodyVars = {
		action : act,
		domain : domain,
		email : email,
		pass: password
	}
	var URLVars = ''; 
	ajaxCaller.postVars(web_path+"ajax_common.php", bodyVars,URLVars, email_this_fetch_response, false, null);
	return false;  
}


function email_this_fetch_response(text, headers, callingContext) {
   t = trim(text);
      document.getElementById('email-this-2').innerHTML = '<table border="0" width="100%"><tr><td align="center" class="ver11blue" style="color:red">'+text+'</td></tr></table>';
}


function checkAllemail(){
	var field  = document.getElementsByName("check_email[]");
	if(document.getElementById("check_all").checked == true) {
		for (var i = 0; i < field.length; i++){
			field[i].checked = true ;
		}
	} else {
			for (i = 0; i < field.length; i++){
			field[i].checked = false ;
			}
	}
}


function send_contacts_to_textarea(hl_cons_form,email){
	//alert(email)
	var field  = document.getElementsByName("check_email[]");
	var teztarea_val = "";
		for (var i = 0; i < field.length; i++){
			//field[i].checked = true ;
			if(field[i].checked == true){
			teztarea_val += field[i].value + ","
			}
		}
	document.getElementById('email-this-email-1').value = email;
	document.getElementById('friends_email').value = teztarea_val;
	document.getElementById('email-this-div').style.display = "none";
	document.getElementById('email-this-or-statement').style.display = "none";
}

function update_total_selected(a){
var row = trim(document.getElementById('row').value);
var c = parseInt(row);
	if(document.getElementById(a).checked==true){c++}
	if(document.getElementById(a).checked==false){c--}
	document.getElementById("total_selected").innerHTML="<strong>"+c+"</strong> Contacts Selected</span>";
	document.getElementById('row').value = c;
}

function count_total_selected(){
	var c = 0;
	var field  = document.getElementsByName("check_email[]");
	if(document.getElementById("check_all").checked == true){
	    for (var i = 0; i < field.length; i++){
			if(field[i].checked == true)c++;
		}
	}
	if(document.getElementById("check_all").checked == false){
		document.getElementById('row').value = 0;
		c = 0;
	}
	document.getElementById('row').value = c;
	document.getElementById("total_selected").innerHTML="<strong>"+c+"</strong> Contacts Selected</span>";
	
}

function update_list(){
var email_str = "";
var field  = document.getElementsByName('check_email[]');
	for (var i = 0; i < field.length; i++){
		if(field[i].checked == true){
		  if(email_str=="") email_str = field[i].value;
		   else email_str = email_str+","+field[i].value;
		}
	}
document.getElementById('email_str').value = email_str;
var name = document.getElementById('name');
if(trim(document.getElementById('name').value) == ""){
	alert("Please enter your name");
	document.getElementById('name').focus();
	return false;
	}
if(trim(document.getElementById('email_str').value) == ""){
	alert("Please select at least one friend to refer to");
	return false;
	}
}

function validate_email_this_form(){
	var name = document.getElementById('email-this-name');
	var email = document.getElementById('email-this-email-1');
	var friends_email = document.getElementById('friends_email');

	if(name.value ==''){
		alert("Please enter your Name.");
		 name.focus();
		return false;
	}else if(email.value ==''){
		alert("Please enter your email address.");
		email.focus();
		return false;
	}else if(checkEmail(email.value) == false){
    alert("Please enter valid email-Id.\n Eg. example@domain.com");
	email.focus();
	return false;
	}else if(friends_email.value ==''){
		alert("Please enter your Friends email address.");
		friends_email.focus();
		return false;
	}else{
		return true;
	}
}


function Comma(nStr)
{
 nStr += '';
 x = nStr.split('.');
 x1 = x[0];
 x2 = x.length > 1 ? '.' + x[1] : '';
 var rgx = /(\d+)(\d{3})/;
 var z = 0;
 var len = String(x1).length;
 var num = parseInt((len/2)-1);

  while (rgx.test(x1))
  {
	if(z > 0)
	{
	  x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	else
	{
	  x1 = x1.replace(rgx, '$1' + ',' + '$2');
	  rgx = /(\d+)(\d{2})/;
	}
	z++;
	num--;
	if(num == 0)
	{
	  break;
	}
  }
 return x1 + x2;
}

function removeCommas(aNum) {
aNum=aNum.replace(/,/g,"");
aNum=aNum.replace(/\s/g,"");
return aNum;
}


/* ALL JQUERY GLOW BOX CALLS */



/* END OF JQUERY GLOW BOX CALLS */

//Function for validate features box in health insurance
function validate_health_insurance_feature()
{
	var filed_name = document.getElementById('filed_name').value;
	
	if((filed_name == 'individual') || (filed_name == 'family-floater'))
	{
		var maturity_benifit = document.getElementById('meaturity_benifit').checked;
		var eyes = document.getElementById('eyes').checked;
		var new_born = document.getElementById('new-born').checked;
		var dental = document.getElementById('dental').checked;
		var ambulance = document.getElementById('ambulance').checked;
		var special_treatment = document.getElementById('special_treatment').checked;
		var assistance_services = document.getElementById('assistance_services').checked;

		if((maturity_benifit == true) || (eyes == true) || (new_born == true) || (dental == true) || (ambulance == true) || (special_treatment == true) || (assistance_services == true)) return true;
		else return false;
	}
	else if(filed_name == 'critical-illness')
	{
		var payout_benefit = document.getElementById('payout_benefit').checked;
		var health_checkUp = document.getElementById('health_checkUp').checked;

		if((payout_benefit == true) || (health_checkUp == true)) return true;
		else return false;
	}
	else if(filed_name == 'senior-citizen')
	{
		var maturity_benifit = document.getElementById('meaturity_benifit').checked;
		var eyes = document.getElementById('eyes').checked;
		var pre_existing = document.getElementById('pre_existing').checked;
		var dental = document.getElementById('dental').checked;
		var ambulance = document.getElementById('ambulance').checked;
		var special_treatment = document.getElementById('special_treatment').checked;
		var assistance_services = document.getElementById('assistance_services').checked;

		if((maturity_benifit == true) || (eyes == true) || (pre_existing == true) || (dental == true) || (ambulance == true) || (special_treatment == true) || (assistance_services == true)) return true;
		else return false;
	}
}
