function FormSubmit()
{
	var ostan = document.forms.orderList.id_ostan.value;
	var shahr = document.forms.orderList.id_shahr.value;
	if ((ostan > 0) && (shahr > 0))
	{
		document.forms.orderList.step.value = 2;
		document.forms.orderList.submit();
	}
	else 
		alert("استان و شهر محل اقامت خود را انتخاب کنید");
}

function FormSubmit2()
{
	var ostan = document.forms.orderList.id_ostan.value;
	var shahr = document.forms.orderList.id_shahr.value;
	if ((ostan > 0) && (shahr > 0))
	{
		document.forms.orderList.action = 'index.php?do=submit';
		document.forms.orderList.submit();
	}
	else 
		alert("استان و شهر محل اقامت خود را انتخاب کنید");
}

function formCheck(formobj)
{		
	var fieldRequired = Array("fld_1", "fld_2", "fld_4", "fld_7");
	var fieldDescription = Array("نام", "نام خانوادگی", "تلفن منزل", "آدرس پستی");
	var alertMsg = "لطفا قسمت های زیر را تکمیل فرمایید:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].value == 0){
					obj.style.background = "#FFFFCF";
					obj.style.barder = "1px solid #ddd";
					alertMsg += " - " + fieldDescription[i] + "\n";
				} else {
					obj.style.background = "#FFF";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += "  " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
			case "password":
				if (obj.value == "" || obj.value == null){
					obj.style.background = "#FFFFCF";
					obj.style.barder = "1px solid #ddd";
					alertMsg += " " + fieldDescription[i] + "\n";
				} else {
					obj.style.background = "#FFF";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " [ " + fieldDescription[i] + " ]\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg)
	{
		return true;
	}
	else
	{
		alert(alertMsg);
		return false;
	}
}

function SetCity(id_ostan)
{
	var indx = 0;
	var ctar = new Array(0, 41, 44, 45, 31, 84, 77, 21, 38, 56, 51, 58, 61, 24, 23, 54, 71, 28, 25, 87, 34, 83, 74, 17, 13, 66, 15, 86, 76, 81, 35);
	for (i=0; i<ctar.length; i++)
	{
		if (id_ostan == ctar[i])
			indx = i;
	}
	return indx;
}

function SelectCity(id_shahr)
{
	var len = document.getElementById('shahr').options.length;
	for (i=0; i<len; i++)
	{
		if (document.getElementById('shahr').options[i].value == id_shahr)
		{
			document.getElementById('shahr').options[i].selected = "1";
		}
	}
}


jQuery(document).ready( function()
{
	if (document.forms.formcheck.fld_9.value)
	{
		ldMenu(document.forms.formcheck.fld_9.value); 
		SelectCity(jQuery('#id_shahr_h').val());
	}
});
