function submitform(pressbutton,formName){
	var form = eval('document.'+formName);
	if (pressbutton) {
		form.task.value=pressbutton;
	}
	try {
		form.onsubmit();
		}
	catch(e){}
	form.submit();
}
function getValueByAjax(location,to,str){ 
		var	rnd = Math.random()*10000;
		var	location =location+'&sx='+rnd+'&'+str;
	//	alert(location);
 	//	MM_openBrWindow(location,'Anket','resizable=yes,status=yes,width=300,height=400')
		var	objout =document.getElementById(to);
		var	objdef =document.getElementById(to+'_def');
		var req = null; 

		objout.innerHTML="Started...";
 
		if (window.XMLHttpRequest)
		{
 			req = new XMLHttpRequest();
			if (req.overrideMimeType) 
			{
				req.overrideMimeType('asp');
			}
		} 
		else if (window.ActiveXObject) 
		{
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
        	}


		req.onreadystatechange = function()
		{ 
			objout.innerHTML="Wait server...";
			if(req.readyState == 4)
			{

   				hazir = req.responseText.split("<?script/?>");
				
				if(req.status == 200)
				{
					objout.innerHTML="" + hazir[0];
		//			alert (hazir[1])
		//			document.write (hazir[0])
					if(objdef!=null){objdef.style.display="none";}
					if(hazir[1]!=null){eval(hazir[1]);}
		//			window.location='#'+to;
				}	
				else	
				{
					objout.innerHTML="<strong>HATA!!!</strong>" + req.status + " " + req.statusText+req.responseText; ///<?php TXT_815?>		
					
					if(objdef!=null){objdef.style.display="block";}
				}	
			} 
		}; 
		req.open("get", location, true); 
		req.send(str); 
	} 
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}	

function getSelectedValue( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].value;
	} else {
		return null;
	}
}

function getSelectedRadio( srcGroupName,formName ) {
	var form = eval('document.'+formName);
	var srcGroup = eval( 'form.' + srcGroupName );
	return radioGetCheckedValue( srcGroup );
}		

function radioGetCheckedValue(radioObj) {
	if (!radioObj) {
		return '';
	}
	var n = radioObj.length;
	if (n == undefined) {
		if (radioObj.checked) {
			return radioObj.value;
		} else {
			return '';
		}
	}
	for (var i = 0; i < n; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}

	return '';
}
		
function findObj(n, d) {
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function sec(x){
	if(x!=''){
		_root ='' 
		var form = document.siparisForm ;
		getValueByAjax(_root+'/sehirler.asp?field=sehir','gidecekIlce','i='+gidecekSehir[x-1]); 
		getValueByAjax(_root+'/sehirler.asp?field=ilce','gidecekSemt','i='+gidecekIlce[x-1]);
		form.saklamaAdi.value 		= saklamaAdi[x-1];
		form.aliciAdi.value 		= aliciAdi[x-1];
		form.aliciTelKodu.value 	= aliciTelKodu[x-1];
		form.aliciTelefon.value 	= aliciTelefon[x-1];
		form.aliciGsmKodu.value 	= aliciGsmKodu[x-1];
		form.aliciGsm.value 		= aliciGsm[x-1];
		form.gidecekAdres.value 	= gidecekAdres[x-1];
		form.gidecekSehir.value 	= gidecekSehir[x-1];
		setTimeout("var form = document.siparisForm ;form.gidecekIlce.value = gidecekIlce["+(x-1)+"];form.gidecekSemt.value = gidecekSemt["+(x-1)+"];",1000)
		nakliye_ekle();
		nakliye_ekle_semt();
	}
}
function sehirSemtSec(x){
 var form = document.siparisForm ;
 form.gidecekIlce.value 		= gidecekIlce[x-1];
 form.gidecekSemt.value 		= gidecekSemt[x-1];
}
	
/*	function fatura_adresi_ekle(){
	var form = document.siparisForm ;
	var ulke = getSelectedValue( "siparisForm", 'USER_ulke');
	var sehir = getSelectedValue( "siparisForm", 'USER_sehir');
	var ilce = findObj('USER_ilce').value;
	var semt = findObj('USER_semt').value;
	var postakodu = findObj('USER_postakodu').value;
	var fatura_adresi = findObj('USER_adres').value;
	var vergid = findObj('USER_vergid').value;
	var vergin = findObj('USER_vergin').value;
	var firmaunvani = findObj('USER_name').value;
	
	if (postakodu){ fatura_adresi = fatura_adresi + ' pk:' + postakodu ;}
	if (semt){ fatura_adresi = fatura_adresi + '/' + semt ;}
	if (ilce){ fatura_adresi = fatura_adresi + '\n' + ilce ;}
	if (sehir){ fatura_adresi = fatura_adresi + '/' + sehir  ;}
	if (ulke){ fatura_adresi = fatura_adresi + ' - ' + ulke  ;}
	findObj('Firma_Adres').value = fatura_adresi ;
	findObj('Firma_VergiD').value = vergid ;
	findObj('Firma_VergiN').value = vergin ;
	findObj('Firma_Unvani').value = firmaunvani ;
	}
*/
/**
 * Verifies if the string is in a valid email format
 * @param	string
 * @return	boolean
 */	
function isEmail( text )
{
	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp( pattern );
	return regex.test( text );
}


function setss(no,val) {
	getValueByAjax(_root+'/country.asp?field=sehir','ajx0','i='+(val));
	
}
function sets(no,val) {
	_root ='' 
	if(no==0){
	getValueByAjax(_root+'/country.asp?field=sehir','ajx0','i='+(val));
	getValueByAjax(_root+'/country.asp?field=ilce','ajx1','i=-10');
	getValueByAjax(_root+'/country.asp?field=semt','ajx2','i=-10');
	} else if(no==1){
	getValueByAjax(_root+'/country.asp?field=ilce','ajx1','i='+(val));
	getValueByAjax(_root+'/country.asp?field=semt','ajx2','i=-10');
	} else if(no==2){
	getValueByAjax(_root+'/country.asp?field=semt','ajx2','i='+(val));
	}
}


