﻿//popup
function OpenWindow(theURL,winName,size) {
			strwinName = window.open(theURL,winName,size);}
			
//number control
var XLCheck = function(k,type){
var keynum;
var keychar;
var regExMyEx;
if(window.event){ // IE
    keynum = k.keyCode;
}else if(e.which){ // Netscape/Firefox/Opera
    keynum = k.which;
}
keychar = String.fromCharCode(keynum);    
switch(type){
    case "alpha":
        regExMyEx = /^[a-zA-Z\s]+$/;
        return regExMyEx.test(keychar);
    break;
    case "alphanum":
        regExMyEx = /^[\w\s]+$/;
        return regExMyEx.test(keychar);
    break;    
    case "integer":
        regExMyEx = /^[+]?\d+$/;
        var result = regExMyEx.test(keychar);
        return result;
    break;
    }
};
//number control


// city county list
function City_Change(ParentList, ChildList) 
{
	var ind, strDeger, arrDeger, newOption, newArrDeger;

	while(ChildList !=null && ChildList.length !=null && ChildList.length>1)
		ChildList.options[ChildList.length-1]= null;

	ind = ParentList.options[ParentList.selectedIndex].value;
	if (ind != -1) 
	{
		strDeger = arrListe[ind];
		arrDeger= strDeger.split(";");

		for (i=0; i<arrDeger.length; i++)
		{
			if(arrDeger[i] != "")
			{
				newArrDeger= arrDeger[i].split("|");
				newOption = new Option(newArrDeger[0],newArrDeger[0]);
				ChildList.options[i+1]= newOption;
			}
		}			
	}
	
	ChildList.options[0].selected=true;      
}

function City_Change_Locate(ParentList, ChildList, county_value) 
{
	var ind, strDeger, arrDeger, newOption, newArrDeger, county_value_deger;
	var selected_ind=0;
	
	if(county_value != null && county_value != "")
	{
		county_value_deger = county_value.split(",");		
	}

	if(ParentList != null && ChildList != null)
	{
		while(ChildList !=null && ChildList.length !=null && ChildList.length>1)
			ChildList.options[ChildList.length-1]= null;

		ind = ParentList.options[ParentList.selectedIndex].value;
		
		if (ind != -1) 
		{
			strDeger = arrListe[ind];
			arrDeger= strDeger.split(";");		
			for (i=0; i<arrDeger.length; i++)
			{
				newArrDeger= arrDeger[i].split("|");
				if (newArrDeger[0] == county_value_deger[0])
				{
					selected_ind = i+1;
				}
				if(newArrDeger[0] != "")
				{
					newOption = new Option(newArrDeger[0],newArrDeger[0]);
					ChildList.options[i+1]= newOption;
				}
			}			
		}

		ChildList.options[selected_ind].selected=true;	      
	}
}
// city county list


//charCounter
function charCounter(field, maxlimit){
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	}
}
//charCounter

//Show Hide Area
function ShowHideArea(selectedValue,controlValue,areaId, areaVisible) {
    if (selectedValue == controlValue) {
    document.getElementById(areaId).style.display = areaVisible;
    }
    else {
        if(areaVisible == "none")
        {
            areaVisible = "block"
        }
        else
        {
            areaVisible = "none"
        }
    document.getElementById(areaId).style.display = areaVisible;
    }
}

function ShowHideArea2(areaId) {
    if (document.getElementById(areaId).style.display == "none")
        document.getElementById(areaId).style.display = "block";
    else 
        document.getElementById(areaId).style.display = "none";
}

//Show Hide Area