/********************************************************************************************************************************
*																																*
*	Author   : Asif D. Khalyani																									*
*	Filename : general-funcation.js - General Funcation call here																*		
*	Date     : 18, September 2008																								*
*	Email    : asif.khalyani@msn.com																							*
*********************************************************************************************************************************/
/****** START IFRAME STATE ID & CITY ID VALUE FETCH THIS PAGE ************************************************************************/
function getIframe(){
	if (parent.iframe_region_cpl2_state.document.form_region_cpl2) 	
		document.getElementById('state_id').value=parent.iframe_region_cpl2_state.document.form_region_cpl2.elements[0].value;
	if (parent.iframe_region_cpl2_city.document.form_region_cpl2) 	
		document.getElementById('city_id').value = parent.iframe_region_cpl2_city.document.form_region_cpl2.elements[0].value;
}
function changeState(val)
{
	var country_code	=	val;
	if(country_code=="UK" || country_code=="EI" || country_code=="Sco" || country_code=="wls" || country_code=="EU") {
		document.form_register.action			=	"http://www.adultxdating.co.uk/registration.html?userid=axdcom&from=non";
		document.form_register.submit();
	} else if(country_code=="AS") {
		document.form_register.action			=	"http://www.adultxdating.com.au/registration.html?userid=axdcom&from=non";
		document.form_register.submit();
	} else if(country_code=="NZ") {
		document.form_register.action			=	"http://www.adultxdating.co.nz/registration.html?userid=axdcom&from=non";
		document.form_register.submit();
	}
	else if(country_code=="IN") {
		document.form_register.action			=	"http://www.yahoopersonals.co.in/registration.html";
		document.form_register.submit();
	}else
	{
	parent.document.getElementById("iframe_region_cpl2_state").src="state_cpl2.php?country_master_id="+ val+"&action=reg";
	parent.document.getElementById("iframe_region_cpl2_city").src="city_cpl2.php?state_master_id=0&action=reg";
	}
}
function changeState_search(val)
{
	parent.document.getElementById("iframe_region_cpl2_state").src="state_cpl2.php?country_master_id="+ val+"&action=search";
	parent.document.getElementById("iframe_region_cpl2_city").src="city_cpl2.php?state_master_id=0&action=search";
}
function autotab1(){ 
    parent.iframe_region_cpl2_state.document.form_region_cpl2.elements[0].focus();
}
/****** END IFRAME STATE ID & CITY ID VALUE FETCH THIS PAGE *************************************************************************/

/****** START IFRAME STATE ID & CITY ID VALUE FETCH THIS PAGE ************************************************************************/
	function getIframe(){
		if (parent.iframe_region_cpl2_city.document.form_region_cpl2) 	
			document.getElementById('city_id').value = parent.iframe_region_cpl2_city.document.form_region_cpl2.elements[0].value;
		//document.register_form.city_id.value=parent.iframe_region_cpl2_city.document.form_region_cpl2.elements[0].value;
	}
/****** END IFRAME STATE ID & CITY ID VALUE FETCH THIS PAGE *************************************************************************/

/**** START TEXT PAD COUNTER PAGE DEVELOPED BY Asif Khalyani on 6, October 2008 *************************************************/
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}else{
		cntfield.innerHTML = maxlimit - field.value.length;
	}
}
/**** END TEXT PAD COUNTER PAGE DEVELOPED BY Asif Khalyani on 6, October 2008 ***************************************************/

/****** START USER MASTER PAGE CHANGE REGISTER TYPE  ********************************************************************************/
	function change_reg_status(user_id1, user_id2, val, selectedVal)
	{
		if(val == 3 || val == 4 || val == 5 )
		{
			$(user_id1).show('show');
			$(user_id1+'1').show('show');
			menuSelect					=	$(user_id2);
			menuSelect.options.length	=	0;
			menuSelect.options[0]		=	new Option("Select Maritial","0");
			var l =1;
			for (var i=8; i<couple_maritial_status.length; i++) 
			{
				menuSelect.options[l]	=	new Option(couple_maritial_status[i],i,false, false);
				if (val==selectedVal) 
				{
					menuSelect.options[l].selected=true;
				}
				l++;
			}
		}	
		else if(val == 1 || val == 2  || val == 0)
		{
			$(user_id1).hide('hide');
			$(user_id1+'1').hide('hide');
			menuSelect					=	$(user_id2);
			menuSelect.options.length	=	0;
			menuSelect.options[0]		=	new Option("Select Maritial","0");
			var l =1;
			for (var i=1; i<maritial_status.length; i++) 
			{
				menuSelect.options[l]	=	new Option(maritial_status[i],i,false, false);
				if (i==selectedVal) 
				{
					menuSelect.options[l].selected=true;
				}
				l++;
			}	
		}	
	}
/****** END USER MASTER PAGE CHANGE REGISTER TYPE  **********************************************************************************/

/****** START City Value Fetch Using XML File Read & Reply XML File ************************************************************/
function getstates(url, state_id, city_id)
{
	var combo_id	=	'city_id';
	var combo_opt	=	"Waiting......";

	var data;
		data="state_id="+state_id+"&city_id="+city_id;
	
	menuSelect					=	$(combo_id);
	menuSelect.options.length	=	0;
	menuSelect.options[0]		=	new Option(combo_opt,"-1");
		
	var myAjax = new Ajax.Request(url,{method:'post', parameters: data, onComplete: processcity} );
	return false;
}

function processcity(transport)
{
    if (transport.readyState == 4) {
        if (transport.status == 200) {
           	response  = 	transport.responseXML.documentElement;
//alert(transport.responseText);
			var combo_id	=	'city_id';
			var default_option	=	'Select City';
			var combo_opt	=	""+default_option;	
			
			menuSelect					=	$(combo_id);
			menuSelect.options.length	=	0;
			menuSelect.options[0]		=	new Option(combo_opt,"-1");

			var selected_city_id = response.getElementsByTagName('select_city')[0].getElementsByTagName('city_id')[0].firstChild.nodeValue;

			for(var i=1;i<=response.getElementsByTagName('city_name').length;i++) 
			{
				var city_id = response.getElementsByTagName('city_master')[i-1].getElementsByTagName('city_master_id')[0].firstChild.nodeValue;
				var city_name = response.getElementsByTagName('city_master')[i-1].getElementsByTagName('city_name')[0].firstChild.nodeValue;
			  	if(selected_city_id==city_id)
					menuSelect.options[i]=new Option(city_name,city_id,false,true);
				else
					menuSelect.options[i]=new Option(city_name,city_id,false,false);
			}
			if(old_city_id=="0") {
				menuSelect.options[i]	=	new Option("Other","0",false,true);
			} else {
				menuSelect.options[i]	=	new Option("Other","0",false,false);
			}
        } else {
            alert("There was a problem retrieving the XML data:\n" + originalRequest.statusText);
        }
    }
}
/****** END City Value Fetch Using XML File Read & Reply XML File ************************************************************/
/****** START IFRAME STATE ID & CITY ID VALUE FETCH THIS PAGE ************************************************************************/
function getIframe(){
	if (parent.iframe_region_cpl2_state.document.form_region_cpl2) 	
		document.getElementById('state_id').value=parent.iframe_region_cpl2_state.document.form_region_cpl2.elements[0].value;
	if (parent.iframe_region_cpl2_city.document.form_region_cpl2) 	
		document.getElementById('city_id').value = parent.iframe_region_cpl2_city.document.form_region_cpl2.elements[0].value;
}
function changeState(val)
{
	var country_code	=	val;
	if(country_code=="UK" || country_code=="EI" || country_code=="Sco" || country_code=="wls" || country_code=="EU") {
		document.form_register.action			=	"http://www.adultxdating.co.uk/registration.html?userid=axdcom&from=non";
		document.form_register.submit();
	} else if(country_code=="AS") {
		document.form_register.action			=	"http://www.adultxdating.com.au/registration.html?userid=axdcom&from=non";
		document.form_register.submit();
	} else if(country_code=="NZ") {
		document.form_register.action			=	"http://www.adultxdating.co.nz/registration.html?userid=axdcom&from=non";
		document.form_register.submit();
	}
	else if(country_code=="IN") {
		document.form_register.action			=	"http://www.yahoopersonals.co.in/registration.html";
		document.form_register.submit();
	}else
	{
	parent.document.getElementById("iframe_region_cpl2_state").src="state_cpl2.php?country_master_id="+ val+"&action=reg";
	parent.document.getElementById("iframe_region_cpl2_city").src="city_cpl2.php?state_master_id=0&action=reg";
	}
}
function changeState_search(val)
{
	parent.document.getElementById("iframe_region_cpl2_state").src="state_cpl2.php?country_master_id="+ val+"&action=search";
	parent.document.getElementById("iframe_region_cpl2_city").src="city_cpl2.php?state_master_id=0&action=search";
}
function autotab1(){ 
    parent.iframe_region_cpl2_state.document.form_region_cpl2.elements[0].focus();
}
/****** END IFRAME STATE ID & CITY ID VALUE FETCH THIS PAGE *************************************************************************/