function select_drstination(id_select)
{
	document.getElementById(id_select).value='';
}


var xmlHttp, xmlHttp1, xmlHttp2, xmlHttp3, xmlHttp4, xmlHttp5, xmlHttp6, xmlHttp7, xmlHttp11 ,xmlHttp111;
var  xmlHttp1_1, xmlHttp2_1, xmlHttp3_1, xmlHttp4_1, xmlHttp5_1, xmlHttpBankAccount, xmlHttpshowClients, xmlHttpShowProduct_div;
var intCntRows=1;

////////////////////////////////////////////////////////
/*
function URLencode(sStr)
{
    return escape(sStr).replace(/\+/g, '%2B')
    						.replace(/\"/g,'%22').
                   				replace(/\'/g, '%27').
                     				.replace(/\//g,'%2F');
}
*/
function showCustomer(str,name)
{ 
//	alert('vlezna');
	var url="ajax/getcustomer.php?what=mol&sid=" + Math.random() + "&q=" + str + "&name=" + name;
	xmlHttp=GetXmlHttpObject(stateChanged1);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	
//	alert(url);
	
	var url="ajax/getcustomer.php?what=d_number&sid=" + Math.random() + "&q=" + str + "&name=" + name;
	xmlHttp2=GetXmlHttpObject(stateChanged2);
	xmlHttp2.open("GET", url , true);
	xmlHttp2.send(null);
		
//	alert(url);
	
	var url="ajax/getcustomer.php?what=b_stat_egn&sid=" + Math.random() + "&q=" + str + "&name=" + name;
	xmlHttp3=GetXmlHttpObject(stateChanged3);
	xmlHttp3.open("GET", url , true);
	xmlHttp3.send(null);
	
	var url="ajax/getcustomer.php?what=address&sid=" + Math.random() + "&q=" + str + "&name=" + name;
	xmlHttp4=GetXmlHttpObject(stateChanged4);
	xmlHttp4.open("GET", url , true);
	xmlHttp4.send(null);

	var url="ajax/getcustomer.php?what=mol&sid=" + Math.random() + "&q=" + str + "&name=" + name;
	xmlHttp5=GetXmlHttpObject(stateChanged5);
	xmlHttp5.open("GET", url , true);
	xmlHttp5.send(null);
//	alert(url);
	           
} 

function stateChanged1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("customer_mol").innerHTML=xmlHttp.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
} 
function stateChanged4() 
{ 
	if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete")
	{ 
		document.getElementById("customer_address").innerHTML=xmlHttp4.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
}  

function stateChanged2() 
{ 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{ 
		document.getElementById("customer_d_number").innerHTML=xmlHttp2.responseText ;

		
//		alert("response" + xmlHttp2.responseText)
	} 
} 

function stateChanged3() 
{
//	alert('1');
	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
	{ 
//		alert('2');
		document.getElementById("customer_b_stat_egn").innerHTML=xmlHttp3.responseText ;
		
		if(document.getElementById('customer_b_stat_egn').innerHTML != '')
		{
//			alert('3');
			

			document.getElementById('input_kontact_name').disabled=false ;
//			document.getElementById('input_product1').disabled=false ;
		}
		else
		{
//			alert('4');
			if(document.getElementById('input_kontact_name').value !='' )
			{
				document.getElementById('input_kontact_name').value='';
				document.getElementById('kontact_name_div_mol').innerHTML='';
				document.getElementById('kontact_name_div1').innerHTML='';
				
			}
//			document.getElementById('input_product1').disabled=true ;
			document.getElementById('input_kontact_name').disabled=true;
//			alert('redove'+ intCntRows);
			disabled_input_product(intCntRows);
//			document.getElementById('input_client').style.display='none';
		}
//		alert("response" + xmlHttp3.responseText)
	} 
}  

function stateChanged5() 
{ 
	if (xmlHttp5.readyState==4 || xmlHttp5.readyState=="complete")
	{ 
		document.getElementById("k_lice").innerHTML=xmlHttp5.responseText ;
//		alert("response" + xmlHttp3.responseText)
	} 
} 
    

//////////////////////////////////////////////////



//////////////////////////////////////////////////


function showBank(str,login)
{ 
	var url="ajax/showbank.php?what=bank_name&sid=" + Math.random() + "&q=" + str + "&login=" + login;
	xmlHttp1_1=GetXmlHttpObject(stateChanged1_1);
	xmlHttp1_1.open("GET", url , true);
	xmlHttp1_1.send(null);
	
//	alert(url);
	
/*	var url="ajax/showbank.php?what=d_number&sid=" + Math.random() + "&q=" + str;
	xmlHttp2_1=GetXmlHttpObject(stateChanged2_1);
	xmlHttp2.open("GET", url , true);
	xmlHttp2.send(null);
		
//	alert(url);
	
	var url="ajax/showbank.php?what=b_stat_egn&sid=" + Math.random() + "&q=" + str;
	xmlHttp3_1=GetXmlHttpObject(stateChanged3_1);
	xmlHttp3_1.open("GET", url , true);
	xmlHttp3_1.send(null);
	
	var url="ajax/showbank.php?what=address&sid=" + Math.random() + "&q=" + str;
	xmlHttp4_1=GetXmlHttpObject(stateChanged4_1);
	xmlHttp4_1.open("GET", url , true);
	xmlHttp4_1.send(null);

	var url="ajax/showbank.php?what=mol&sid=" + Math.random() + "&q=" + str;
	xmlHttp5_1=GetXmlHttpObject(stateChanged5_1);
	xmlHttp5_1.open("GET", url , true);
	xmlHttp5_1.send(null);
//	alert(url);
	*/
} 

function stateChanged1_1() 
{ 
	if (xmlHttp1_1.readyState==4 || xmlHttp1_1.readyState=="complete")
	{ 
		document.getElementById("select_bank_div").innerHTML=xmlHttp1_1.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
} 

/*
function stateChanged4_1() 
{ 
	if (xmlHttp4_1.readyState==4 || xmlHttp4_1.readyState=="complete")
	{ 
		document.getElementById("customer_address").innerHTML=xmlHttp4_1.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
} 

function stateChanged2_1() 
{ 
	if (xmlHttp2_1.readyState==4 || xmlHttp2_1.readyState=="complete")
	{ 
		document.getElementById("customer_d_number").innerHTML=xmlHttp2_1.responseText ;
//		alert("response" + xmlHttp2.responseText)
	} 
} 

function stateChanged3_1() 
{ 
	if (xmlHttp3_1.readyState==4 || xmlHttp3_1.readyState=="complete")
	{ 
		document.getElementById("customer_b_stat_egn").innerHTML=xmlHttp3_1.responseText ;
//		alert("response" + xmlHttp3.responseText)
	} 
}  

function stateChanged5_1() 
{ 
	if (xmlHttp5_1.readyState==4 || xmlHttp5_1.readyState=="complete")
	{ 
		document.getElementById("k_lice").innerHTML=xmlHttp5_1.responseText ;
//		alert("response" + xmlHttp3.responseText)
	} 
} 
*/

///////////////////////////////////////////////////


//////////////////////////////////////////////////

function showBankAccount(str,login)
{ 
	var url="ajax/showbank_account.php?what=bank_name&sid=" + Math.random() + "&q=" + str + "&login=" + login;
	xmlHttpBankAccount=GetXmlHttpObject(stateChangedshowBankAccount);
	xmlHttpBankAccount.open("GET", url , true);
	xmlHttpBankAccount.send(null);
}


function stateChangedshowBankAccount() 
{ 
	if (xmlHttpBankAccount.readyState==4 || xmlHttpBankAccount.readyState=="complete")
	{ 
		document.getElementById("bank_account").innerHTML=xmlHttpBankAccount.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
} 
//////////////////////////////////////////////////////

/////////////////////////////////////////////////////

var xmlHttpBankAccountbank_account;
function showBankAccount1(str,login,bank_account)
{ 
	var url="ajax/showbank_account.php?what=bank_name&sid=" + Math.random() + "&q=" + str + "&login=" + login + "&bank_account=" + bank_account;
	xmlHttpBankAccountbank_account=GetXmlHttpObject(stateChangedshowBankAccountbank_account);
	xmlHttpBankAccountbank_account.open("GET", url , true);
	xmlHttpBankAccountbank_account.send(null);
}


function stateChangedshowBankAccountbank_account() 
{ 
	if (xmlHttpBankAccountbank_account.readyState==4 || xmlHttpBankAccountbank_account.readyState=="complete")
	{ 
		document.getElementById("bank_account").innerHTML=xmlHttpBankAccountbank_account.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
}

////////////////////////////////////////////////////


var xmlHttp1_1bank_number;
function showBank1(str,login,bank_number,bank_account)
{ 
	var url="ajax/showbank.php?what=bank_name&sid=" + Math.random() + "&q=" + str + "&login=" + login + "&bank_number=" + bank_number + "&bank_account=" + bank_account;
	xmlHttp1_1bank_number=GetXmlHttpObject(stateChanged1_1bank_number);
	xmlHttp1_1bank_number.open("GET", url , true);
	xmlHttp1_1bank_number.send(null);
}

function stateChanged1_1bank_number() 
{ 
	if (xmlHttp1_1bank_number.readyState==4 || xmlHttp1_1bank_number.readyState=="complete")
	{ 
		document.getElementById("select_bank_div").innerHTML=xmlHttp1_1bank_number.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
} 




////////////////////////////



function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;
	
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesn't work in Opera") ;
		return ;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP";
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler ;
			return objXmlHttp;
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") ;
			return ;
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler ;
		return objXmlHttp;
	}
}








/*function stateChanged5() 
{ 
	if (xmlHttp5.readyState==4 || xmlHttp5.readyState=="complete")
	{ 
		document.getElementById("mer_edinica").innerHTML=xmlHttp5.responseText ;
//		alert("response" + xmlHttp.responseText)
	} 
} 

*/
var xmlHttpShowProduct_price;

var showProductIndex;
var xmlHttpShowProduct;

function showProduct(index, str)

{ 
//	alert(index);
//alert(str);

	if(document.getElementById('product_'+index).value == '')
	{
		//alert('if');
		document.getElementById('onec_price'+index).disabled=true ;
	}
	else
	{
		//alert('else');
		document.getElementById('onec_price'+index).disabled=false ;
	} 	 
	//alert('posle');
	var url="ajax/getproduct.php?what=mer_edinica&sid=" + Math.random() + "&q=" + str+ "&index=" + index;
	showProductIndex=index;
	xmlHttpShowProduct=GetXmlHttpObject(stateChangedShowProduct);
	xmlHttpShowProduct.open("GET", url , true);
	xmlHttpShowProduct.send(null);	

///////////////////////za cenata avtomati4no	
	
	var url="ajax/getproduct.php?what=price&sid=" + Math.random() + "&q=" + str;
	showProductIndex=index;
	xmlHttpShowProduct_price=GetXmlHttpObject(stateChangedShowProduct_price);
	xmlHttpShowProduct_price.open("GET", url , true);
	xmlHttpShowProduct_price.send(null);	

//////////////////////////kari	


}				 

function stateChangedShowProduct() 
{ 
	if (xmlHttpShowProduct.readyState==4 || xmlHttpShowProduct.readyState=="complete")
	{
		if (showProductIndex>0)
			document.getElementById("mer_edinica"+showProductIndex).innerHTML=xmlHttpShowProduct.responseText ;
	} 
} 
///////////////////////za cfenata avtomati4no



var xmlHttp_marki;
//var clients_facturi='clients_facturi';

function car_marks(id_mark,lang)
{ 
	var url="/ajax/models.php?sid=" + Math.random() + "&id_mark=" + id_mark + "&lang=" + lang;
//	alert(url);
	xmlHttp_marki=GetXmlHttpObject(stateChanged_models);
	
	xmlHttp_marki.open("GET", url , true);
	xmlHttp_marki.send(null);
} 

function stateChanged_models() 
{ 
	if (xmlHttp_marki.readyState==4 || xmlHttp_marki.readyState=="complete")
	{ 
		document.getElementById('modeli').innerHTML=xmlHttp_marki.responseText ;
	} 
}