var image_host="../Uploads/ProductsImages/"

function fillForm()
{
	for(i=0;i<xmlDoc.documentElement.childNodes.length;i++)
	{
	
	//alert(xmlDoc.documentElement.childNodes.item(i).attributes.item(0).value);
		urun_cat_kod=xmlDoc.documentElement.childNodes.item(i).attributes.item(0).value;
		var satir=0;
		switch(urun_cat_kod){
			case "CPU":
				satir=0;				
				AddOption(frm_sistemtopla.stok_kod[satir],"İşlemci Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);
				break;
			case "ANA":
				satir=1;
				AddOption(frm_sistemtopla.stok_kod[satir],"Anakart Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "RAM":
				satir=2;
				AddOption(frm_sistemtopla.stok_kod[satir],"RAM Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "HDD":
				satir=3;
				AddOption(frm_sistemtopla.stok_kod[satir],"Harddisk Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "CRT":
				satir=4;
				AddOption(frm_sistemtopla.stok_kod[satir],"Ekran Kartı Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "CAS":
				satir=5;
				AddOption(frm_sistemtopla.stok_kod[satir],"Kasa Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "FDD":
				satir=6;
				AddOption(frm_sistemtopla.stok_kod[satir],"Floppy Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;	
			case "CDR":
				satir=7;
				AddOption(frm_sistemtopla.stok_kod[satir],"CD-ROM Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "CDW":
				satir=8;
				AddOption(frm_sistemtopla.stok_kod[satir],"CD-ReWriter Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "DVD":
				satir=9;
				AddOption(frm_sistemtopla.stok_kod[satir],"DVD-ROM Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "DVW":
			satir=10;
			AddOption(frm_sistemtopla.stok_kod[satir],"DVD-ReWriter Seçiniz","",0,0);
			AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
			frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "SES":
				satir=11;
				AddOption(frm_sistemtopla.stok_kod[satir],"Ses Kartı Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;	
			case "TVK":
				satir=12;
				AddOption(frm_sistemtopla.stok_kod[satir],"TV Kartı Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);				
				break;	
			case "EKR":
				satir=13;
				AddOption(frm_sistemtopla.stok_kod[satir],"Monitör Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "KLV":
				satir=14;
				AddOption(frm_sistemtopla.stok_kod[satir],"Klavye Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "MOU":
				satir=15;
				AddOption(frm_sistemtopla.stok_kod[satir],"Mouse Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;			
			case "SPK":
				satir=16;
				AddOption(frm_sistemtopla.stok_kod[satir],"Speaker Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;					
			case "FAX":
				satir=17;
				AddOption(frm_sistemtopla.stok_kod[satir],"Modem Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;
			case "WCA":
				satir=18;
				AddOption(frm_sistemtopla.stok_kod[satir],"Web Cam Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;																				
			case "YAZ":
				satir=19;
				AddOption(frm_sistemtopla.stok_kod[satir],"Printer Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;	
			case "UPS":
				satir=20;
				AddOption(frm_sistemtopla.stok_kod[satir],"UPS Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;				
			case "PRG":
				satir=21;
				AddOption(frm_sistemtopla.stok_kod[satir],"İşletim Sistemi Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;	
			case "OFS":
				satir=22;
				AddOption(frm_sistemtopla.stok_kod[satir],"Ofis Uygulaması Seçiniz","",0,0);
				AddRecord(i,frm_sistemtopla.stok_kod[satir]);		
				frm_sistemtopla.stok_kod[satir].setAttribute('title',urun_cat_kod);					
				break;																																										
		}//end switch
		
	}//end for
}
//----------------------------------------------------
function resetForm()//bütün Form Resetleniyor.
{

}
//-------------------------
function AddRecord(i,obj) // Comboboxlara Değerleri Yazar
{	

	for(j=0;j<xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("ad").length;j++)
	{
		
		//alert(xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("kod").item(j).firstChild.nodeValue);
		stok_kod=xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("kod").item(j).firstChild.nodeValue;				
		//alert(stok_kod);
		stok_ad=xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("ad").item(j).firstChild.nodeValue;
		urun_fiyati=xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("fiyat").item(j).firstChild.nodeValue;
		urun_fiyati=urun_fiyati.replace(",",".");
		urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama);
		para_birimi=xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("para").item(j).firstChild.nodeValue;								
		tlurun_fiyati=xmlDoc.documentElement.childNodes.item(i).getElementsByTagName("tlfiyat").item(j).firstChild.nodeValue;
		tlurun_fiyati=tlurun_fiyati.replace(",",".");
		tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama);

		AddOption(obj,stokAdDuzenle(stok_ad,urun_fiyati,para_birimi), stok_kod,urun_fiyati,tlurun_fiyati);
	}
}
//-------------------------
function AddOption(SelectBox,Text,Value,Label,TLLabel){
	
	var oOption = document.createElement("OPTION");
  //alert(Label);
    oOption.text=Text;
    oOption.value=Value;
    
	oOption.setAttribute('lang',Label);
	oOption.setAttribute('title',TLLabel);
	
	if(Text.indexOf("Seçiniz")>0)
	{
	oOption.style.color="gray"; 
	}
	else
	{
	oOption.style.color="black";  
	}
		     
    SelectBox.options.add(oOption);
    //alert(oOption); 
}
//-------------------------
function stokAdDuzenle(stok_ad,urun_fiyati,para_birimi)
{
	stok_ad=stok_ad.toUpperCase(); 
	var uzatma="";
	for(k=1;k<(60-stok_ad.length+(6-(urun_fiyati+" "+para_birimi).length));k++)
	{uzatma=uzatma +" ";}
	stok_ad=stok_ad+uzatma;
	stok_ad=stok_ad+urun_fiyati+" "+para_birimi;
	return(stok_ad);	
}
//-------------------------
function stokKodChanged(Obj,satir)
{
	if(Obj.options[Obj.selectedIndex].lang=="" || Obj.options[Obj.selectedIndex].lang=="0")
		{//eğer yeni kategori eklenmiş ve boş bir ürün seçmişse
			//alert("2");
			frm_sistemtopla.st_adet[satir].selectedIndex=0;
			frm_sistemtopla.fiyat[satir].value="";
			frm_sistemtopla.tlfiyat[satir].value="";
			frm_sistemtopla.tltutar[satir].value="";
			frm_sistemtopla.tutar[satir].value="";
		}
	else
		{
		
			frm_sistemtopla.st_adet[satir].selectedIndex=1;
			frm_sistemtopla.fiyat[satir].value=Obj.options[Obj.selectedIndex].lang;
			frm_sistemtopla.tlfiyat[satir].value=Obj.options[Obj.selectedIndex].title;
			frm_sistemtopla.tltutar[satir].value=frm_sistemtopla.st_adet[satir].value*frm_sistemtopla.tlfiyat[satir].value;
			frm_sistemtopla.tutar[satir].value=frm_sistemtopla.st_adet[satir].value*frm_sistemtopla.fiyat[satir].value;
			
		}
	hesapla()
}
//-------------------------
function degisim(Obj,satir)
{
	liste_duzenle(Obj);
	stokKodChanged(Obj,satir);
}
//-------------------------
function degisim_ekstra(Obj,satir)
{
	stokKodChanged(Obj,satir);
}
//-------------------------
var sql2="";
var sql4="";
var sql6="";
var sql8="";
function liste_duzenle(Obj)
{


	var stok_kod=Obj.options[Obj.selectedIndex].value;
	var urun_cat_kod=Obj.title;
//	var urun_cat_kod=stok_kod.substring(0,3);

	switch(urun_cat_kod)
	{
		case "CPU":
				//frm_sistemtopla.st_adet(0).readOnly=true;
				//alert(xmlDoc.selectNodes("/Liste/category[@kod='CPU']/urun[kod='" + stok_kod + "']"));
			//alert("c");
			//xmlDoc.documentElement.childNodes.item(i).attributes.item(0).value
			var islemci=xmlDoc.selectNodes("/Liste/category[@kod='CPU']/urun[kod='" + stok_kod + "']");
				//alert(islemci);				
			
			if(Obj.options[Obj.selectedIndex].text.indexOf("Seçiniz")>0)
				{
				
				islemci_socket=""
				islemci_fsb=""
				islemci_dual=""
				}
				else
				{				
				islemci_socket=islemci[0].childNodes.item(6).firstChild.nodeValue;
				//islemci_fsb=islemci.item(0).childNodes.item(7).text
				islemci_fsb=islemci[0].childNodes.item(12).firstChild.nodeValue;
				
				if (islemci[0].childNodes.item(8).firstChild != null)
				{islemci_dual=islemci[0].childNodes.item(8).firstChild.nodeValue;}
				else
				{islemci_dual=""}
				}	
							
				if(islemci_socket=="")
				{
					islemci_socket="?"
					alert("Seçtiğiniz İşlemcinin Özelliği Girilmemiş! Anakartlar Listelenmeyecek!")
					
				}								
				if(islemci_dual=="1")
				sql1="/Liste/category[@kod='ANA']/urun[socket='"+islemci_socket+"' and FSB='"+islemci_fsb+"' and dual='1']"
				else
				sql1="/Liste/category[@kod='ANA']/urun[socket='"+islemci_socket+"' and FSB='"+islemci_fsb+"']"
				
				if(sql1!=sql2)
				{
					sql2=sql1;
					var anakartlar=xmlDoc.selectNodes(sql1);
					frm_sistemtopla.stok_kod[1].length=1;					
					frm_sistemtopla.st_adet[1].selectedIndex=0;													
					frm_sistemtopla.fiyat[1].value="";
					frm_sistemtopla.tlfiyat[1].value="";
					frm_sistemtopla.tltutar[1].value="";
					frm_sistemtopla.tutar[1].value="";

					for(i=0;i<anakartlar.length;i++)
					{
					
						for(j=0;j<anakartlar[i].getElementsByTagName("ad").length;j++)
						{	
						
							stok_kod=anakartlar[i].getElementsByTagName("kod").item(j).firstChild.nodeValue;	
									
							stok_ad=anakartlar[i].getElementsByTagName("ad").item(j).firstChild.nodeValue;
							urun_fiyati=anakartlar[i].getElementsByTagName("fiyat").item(j).firstChild.nodeValue;
							
							urun_fiyati=urun_fiyati.replace(",",".")
							urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)											
							
							para_birimi=anakartlar[i].getElementsByTagName("para").item(j).firstChild.nodeValue;
							
							tlurun_fiyati=anakartlar[i].getElementsByTagName("tlfiyat").item(j).firstChild.nodeValue;
							tlurun_fiyati=tlurun_fiyati.replace(",",".")
							tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)											
							AddOption(frm_sistemtopla.stok_kod[1],stokAdDuzenle(stok_ad,urun_fiyati,para_birimi),stok_kod,urun_fiyati,tlurun_fiyati);
							}
					}
				}
				break;	
		case "ANA":
		
			frm_sistemtopla.st_adet[1].readOnly=true;
			var anakart=xmlDoc.selectNodes("/Liste/category[@kod='ANA']/urun[kod='"+stok_kod+"']")
		//alert(stok_kod>0);
			if(stok_kod>0)
			{
			//stok_kod=anakartlar[i].getElementsByTagName("kod").item(j).firstChild.nodeValue
			//alert(anakart[0].childNodes.item(6).firstChild.nodeValue);
			var anakart_socket=anakart[0].childNodes.item(6).firstChild.nodeValue;
			var anakart_ram=anakart[0].childNodes.item(7).firstChild.nodeValue;
			var anakart_ram_adet=anakart[0].childNodes.item(8).firstChild.nodeValue
			
			var anakart_agp_port
			if (anakart[0].childNodes.item(9).firstChild != null)
			{anakart_agp_port=anakart[0].childNodes.item(9).firstChild.nodeValue}
			else
			{anakart_agp_port=""}
			
			var anakart_pci_port
			if (anakart[0].childNodes.item(10).firstChild != null)
			{anakart_pci_port=anakart[0].childNodes.item(10).firstChild.nodeValue}
			else
			{anakart_pci_port=""}
						
			var anakart_agp_support
			if (anakart[0].childNodes.item(11).firstChild != null)
			{anakart_agp_support=anakart[0].childNodes.item(11).firstChild.nodeValue}
			else
			{anakart_agp_support=""}
			
			var anakart_fsb
			if (anakart[0].childNodes.item(12).firstChild != null)
			{anakart_fsb=anakart[0].childNodes.item(12).firstChild.nodeValue}
			else
			{anakart_fsb=""}
			
			var anakart_sata_support
			if (anakart[0].childNodes.item(13).firstChild != null)
			{anakart_sata_support=anakart[0].childNodes.item(13).firstChild.nodeValue}
			else
			{anakart_sata_support=""}
			
			var anakart_vga_ob
			if (anakart[0].childNodes.item(14).firstChild != null)
			{anakart_vga_ob=anakart[0].childNodes.item(14).firstChild.nodeValue}
			else
			{anakart_vga_ob=""}
			
			var anakart_ses_ob
			if (anakart[0].childNodes.item(15).firstChild != null)
			{anakart_ses_ob=anakart[0].childNodes.item(15).firstChild.nodeValue}
			else
			{anakart_ses_ob=""}
			
			var anakart_lan_ob
			if (anakart[0].childNodes.item(16).firstChild != null)
			{anakart_lan_ob=anakart[0].childNodes.item(16).firstChild.nodeValue}
			else
			{anakart_lan_ob=""}
			
			var resim
			if (anakart[0].childNodes.item(4).firstChild != null)
			{resim=anakart[0].childNodes.item(4).firstChild.nodeValue}
			else
			{resim=""}
			
			}
			else
			{
			var anakart_socket=""
			var anakart_ram=""
			var anakart_ram_adet=""
			var anakart_agp_port=""
			var anakart_pci_port=""
			var anakart_agp_support=""
			var anakart_fsb=""
			var anakart_sata_support=""
			var anakart_vga_ob=""
			var anakart_ses_ob=""
			var anakart_lan_ob=""
			var resim=""
			}
			if(resim!="")
			{			
				frm_sistemtopla.img1.src=image_host+resim
				frm_sistemtopla.img1.style.display="block"				
			}
			else
			{
				frm_sistemtopla.img1.style.display="none"
				frm_sistemtopla.img1.src=""
			}				
			//------------Anakart-Ram İlişkisi----------------------
			var ramfilt = anakart_ram.replace('Mhz','');
			if(anakart_ram.indexOf("DDR2")>=0)
			{
			
				sql3="/Liste/category[@kod='RAM']/urun[(bellek_turu > 'DDR2') and (bellek_turu < '" + ramfilt + "' or bellek_turu = '" + anakart_ram + "' )]"
			}
			else if(anakart_ram.indexOf("DDR")>=0)
			{
				sql3="/Liste/category[@kod='RAM']/urun[bellek_turu > 'DDR 001' and bellek_turu<'DDR 999' ]"
			}
			else if(anakart_ram.indexOf("SD")>=0)
			{
				sql3="/Liste/category[@kod='RAM']/urun[bellek_turu > 'SD 001' and bellek_turu<'SD 999' ]"
			}
			else if(anakart_ram.indexOf("RD")>=0)	
			{
				sql3="/Liste/category[@kod='RAM']/urun[bellek_turu='RD']"
			}
			else if(anakart_ram=="")	
			{
				if(stok_kod>0)
				{
				alert("Seçtiğiniz Anakartın Özelliği Girilmemiş!")	
				}					
				return false;
			}			
			frm_sistemtopla.st_adet[2].length=3
			
			for(j=3;j<=anakart_ram_adet;j++)
			{	
			AddOption(frm_sistemtopla.st_adet[2],""+j+"",""+j+"","");
			}
			
			if(sql3!=sql4)
			{
				sql4=sql3
					//alert(xmlDoc.selectNodes(sql3));
				
				var ramlar =xmlDoc.selectNodes(sql3);
				//alert(ramlar[0]);
				frm_sistemtopla.stok_kod[2].length=1
				frm_sistemtopla.st_adet[2].value=""
				frm_sistemtopla.fiyat[2].value=""
				frm_sistemtopla.tlfiyat[2].value="";
				frm_sistemtopla.tltutar[2].value=""	
				frm_sistemtopla.tutar[2].value=""	
			
				for(i=0;i<ramlar.length;i++)
				{
				
					for(j=0;j<ramlar(i).getElementsByTagName("ad").length;j++)
					{
					//alert(ramlar[i].getElementsByTagName("kod").item(j).firstChild.nodeValue);
						stok_kod=ramlar[i].getElementsByTagName("kod").item(j).firstChild.nodeValue;	
						stok_ad=ramlar[i].getElementsByTagName("ad").item(j).firstChild.nodeValue;
						urun_fiyati=ramlar[i].getElementsByTagName("fiyat").item(j).firstChild.nodeValue;
						urun_fiyati=urun_fiyati.replace(",",".")				
						urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)						
						para_birimi=ramlar[i].getElementsByTagName("para").item(j).firstChild.nodeValue;
						tlurun_fiyati=ramlar[i].getElementsByTagName("tlfiyat").item(j).firstChild.nodeValue;
						tlurun_fiyati=tlurun_fiyati.replace(",",".")	
						tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)						
					//	alert("s");
						AddOption(frm_sistemtopla.stok_kod[2],stokAdDuzenle(stok_ad,urun_fiyati,para_birimi),stok_kod,urun_fiyati,tlurun_fiyati);
					//	alert("s");
					}//end for
				}//end for
				}//end if
			//------------Anakart-HDD İlişkisi----------------------
			
						
			if(anakart_sata_support.indexOf("var1")>=0 )
			{
			sql5="/Liste/category[@kod='HDD']/urun[ sata = 'var' or sata = 'yok' ]"
			}			
			else if (anakart_sata_support.indexOf("yok")>=0)
			{
			sql5="/Liste/category[@kod='HDD']/urun[ sata = 'yok'  ]"
			}
			else if (anakart_sata_support.indexOf("var")>=0)
			{
			sql5="/Liste/category[@kod='HDD']/urun[ sata = 'var'  ]"
			}	
				if(sql5!=sql6)
				{
				sql6=sql5
				frm_sistemtopla.stok_kod(3).length=1
				frm_sistemtopla.st_adet(3).value=""
				frm_sistemtopla.fiyat(3).value=""
				frm_sistemtopla.tlfiyat(3).value="";
				frm_sistemtopla.tltutar(3).value=""	
				frm_sistemtopla.tutar(3).value=""				
				var hddlar=xmlDoc.selectNodes(sql5)
				for(i=0;i<hddlar.length;i++)
				{
					for(j=0;j<hddlar.item(i).getElementsByTagName("ad").length;j++)
					{
						stok_kod=hddlar.item(i).getElementsByTagName("kod").item(j).text;				
						stok_ad=hddlar.item(i).getElementsByTagName("ad").item(j).text;
						urun_fiyati=hddlar.item(i).getElementsByTagName("fiyat").item(j).text;
						urun_fiyati=urun_fiyati.replace(",",".")		
						urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)								
						para_birimi=hddlar.item(i).getElementsByTagName("para").item(j).text;
						tlurun_fiyati=hddlar.item(i).getElementsByTagName("tlfiyat").item(j).text;
						tlurun_fiyati=tlurun_fiyati.replace(",",".")		
						tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)								
						AddOption(frm_sistemtopla.stok_kod(3),stokAdDuzenle(stok_ad,urun_fiyati,para_birimi),stok_kod,urun_fiyati,tlurun_fiyati);
					}//end for
				}//end for				
				}
				
			//------------Anakart-VGA İlişkisi----------------------
			if(anakart_agp_port=="1" || anakart_agp_support=="16X")
			{
				frm_sistemtopla.stok_kod(4).disabled=false;
				if(anakart_agp_support=="16X")
				{

					sql7="/Liste/category[@kod='CRT']/urun[ agp_support = '16X'  ]"
				}
				else
				{
					sql7="/Liste/category[@kod='CRT']/urun[ agp_support = '8X'  ]"
				}	
					if(sql7!=sql8)
					{

					sql8=sql7
					frm_sistemtopla.stok_kod(4).length=1
					frm_sistemtopla.st_adet(4).value=""
					frm_sistemtopla.fiyat(4).value=""
					frm_sistemtopla.tlfiyat(4).value="";
					frm_sistemtopla.tltutar(4).value=""	
					frm_sistemtopla.tutar(4).value=""				
					var vgalar=xmlDoc.selectNodes(sql7)
					for(i=0;i<vgalar.length;i++)
					{
						for(j=0;j<vgalar.item(i).getElementsByTagName("ad").length;j++)
						{
							stok_kod=vgalar.item(i).getElementsByTagName("kod").item(j).text;				
							stok_ad=vgalar.item(i).getElementsByTagName("ad").item(j).text;
							urun_fiyati=vgalar.item(i).getElementsByTagName("fiyat").item(j).text;
							urun_fiyati=urun_fiyati.replace(",",".")				
							urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)							
							para_birimi=vgalar.item(i).getElementsByTagName("para").item(j).text;
							tlurun_fiyati=vgalar.item(i).getElementsByTagName("tlfiyat").item(j).text;
							tlurun_fiyati=tlurun_fiyati.replace(",",".")				
							tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)							
							AddOption(frm_sistemtopla.stok_kod(4),stokAdDuzenle(stok_ad,urun_fiyati,para_birimi),stok_kod,urun_fiyati,tlurun_fiyati);
						}//end for
					}//end for				
					}
			}
			else
			{			
				frm_sistemtopla.stok_kod(4).selectedIndex=0;
				frm_sistemtopla.st_adet(4).selectedIndex=0;								
				frm_sistemtopla.fiyat(4).value=""
				frm_sistemtopla.tlfiyat(4).value=""
				frm_sistemtopla.tltutar(4).value=""	
				frm_sistemtopla.tutar(4).value=""			
				frm_sistemtopla.stok_kod(4).disabled=true
			}
			
						
			break;
	case "CAS":
			var kasa=xmlDoc.selectNodes("/Liste/category[@kod='CAS']/urun[kod='"+stok_kod+"']")			
			if(stok_kod>0)
			resim=kasa.item(0).childNodes.item(4).text;
			else
			resim=""
			
			if(resim!="")
			{				
				frm_sistemtopla.img2.src=image_host+resim
				frm_sistemtopla.img2.style.display="block"			
			}
			else
			{
				frm_sistemtopla.img2.style.display="none"
				frm_sistemtopla.img2.src=""
			}	
			break;
	case "EKR":
			var ekran=xmlDoc.selectNodes("/Liste/category[@kod='EKR']/urun[kod='"+stok_kod+"']")			
			if(stok_kod>0)
			resim=ekran.item(0).childNodes.item(4).text;
			else
			resim=""
			if(resim!="")
			{				
				frm_sistemtopla.img3.src=image_host+resim
				frm_sistemtopla.img3.style.display="block"			
			}
			else
			{
				frm_sistemtopla.img3.style.display="none"
				frm_sistemtopla.img3.src=""
			}	
			break;			
	case "KLV":
			var klavye=xmlDoc.selectNodes("/Liste/category[@kod='KLV']/urun[kod='"+stok_kod+"']")			
			if(stok_kod>0)
			resim=klavye.item(0).childNodes.item(4).text;
			else
			resim=""
			if(resim!="")
			{				
				frm_sistemtopla.img4.src=image_host+resim
				frm_sistemtopla.img4.style.display="block"			
			}
			else
			{
				frm_sistemtopla.img4.style.display="none"
				frm_sistemtopla.img4.src=""
			}	
			break;
	case "MOU":
			var mouse=xmlDoc.selectNodes("/Liste/category[@kod='MOU']/urun[kod='"+stok_kod+"']")			
			if(stok_kod>0)
			resim=mouse.item(0).childNodes.item(4).text;
			else
			resim=""
			if(resim!="")
			{				
				frm_sistemtopla.img5.src=image_host+resim
				frm_sistemtopla.img5.style.display="block"			
			}
			else
			{
				frm_sistemtopla.img5.style.display="none"
				frm_sistemtopla.img5.src=""
			}	
			break;
	}//end switch
}
function adet_degisim(satir)
{
	frm_sistemtopla.tltutar[satir].value=frm_sistemtopla.st_adet[satir].value*frm_sistemtopla.tlfiyat[satir].value;
	frm_sistemtopla.tutar[satir].value=frm_sistemtopla.st_adet[satir].value*frm_sistemtopla.fiyat[satir].value;
	hesapla()
}
function hesapla()
{

	ara_toplam=0;
	var kur=frm_sistemtopla.ddlCur.value;
	kur=kur.replace(",",".");
	var qty=frm_sistemtopla.txtQty.value;
	
	for(i=0;i<frm_sistemtopla.tltutar.length;i++)
	{
		if(frm_sistemtopla.tltutar[i].value!="")
		{
		ara_toplam=eval(ara_toplam)+eval(((frm_sistemtopla.tltutar[i].value*qty))/kur);
		//Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama);				
		}
	}	
	ara_toplam=eval(ara_toplam) + eval( (ara_toplam)*(yuzde/100) );	
	frm_sistemtopla.ara_toplam.value=Math.round((ara_toplam)*100)/100;
	frm_sistemtopla.ara_toplam.value=Math.round( (eval(ara_toplam) )*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama);				
	frm_sistemtopla.kdv.value=Math.round(ara_toplam*0.18*100)/100;
	genel_toplam=eval(frm_sistemtopla.ara_toplam.value)+eval(frm_sistemtopla.kdv.value);
	frm_sistemtopla.genel_toplam.value=Math.round(genel_toplam*100)/100;	
}

function setDetail()
{
//alert(frm_sistemtopla.chkDetail.checked)
}
function kaydet(tip)
{
//Links
var qty =	frm_sistemtopla.txtQty.value
var qstr ="&detail=" + frm_sistemtopla.chkDetail.checked + "&qty=" + qty + "&Kar=" + yuzde + "&Cur=" + document.frm_sistemtopla.ddlCur.options[document.frm_sistemtopla.ddlCur.selectedIndex].text + "&Products="
	for(i=0;i<frm_sistemtopla.stok_kod.length;i++)
	{
		if(frm_sistemtopla.stok_kod(i).value!="")
		{		
		qstr=qstr + frm_sistemtopla.stok_kod(i).value + "-" + frm_sistemtopla.st_adet(i).value  + "," ;
		}
	}
	
	//frm_sistemtopla.lnkExcell.href = "ProductWizardExport.aspx?Type=xls" + qstr
      //document.frm_sistemtopla.lnkWord.href = "ProductWizardExport.aspx?Type=doc" & qstr
       //document.frm_sistemtopla.lnkHtml.href = "ProductWizardExport.aspx?Type=html" & qstr
	
//document.location.href='ProductWizardExport.aspx?Type=' + tip + qstr
//var PopUpWin =
if (tip=="htm")
{
window.open('ProductWizardExport.aspx?Type=' + tip +  qstr)
}
else
{
document.location.href='ProductWizardExport.aspx?Type=' + tip + qstr
}


}

function detay_ac(stok_kod)
{
		window.open('ProductDetails.aspx?ProductId='+stok_kod);
}


function yeni_sisteme_basla()
{


	a=confirm("Yeni Sisteme Başlamadan Önce Bu Sistemi Kaydetmek İster misiniz?")
	
	if(a)
	{
		kaydet("excel");
		frm_sistemtopla.reset();
	}
	else
	{
		frm_sistemtopla.reset();	
	}

}

function platform_sec(obj)
{	
obj.checked=true;
socket=obj.value

if(socket=="*")
	sqlx="/Liste/category[@kod='CPU']/urun"
else
	sqlx="/Liste/category[@kod='CPU']/urun[socket='"+socket+"']"

		var islemciler=xmlDoc.selectNodes(sqlx)
		frm_sistemtopla.stok_kod(0).length=1
		frm_sistemtopla.st_adet(0).selectedIndex=0;					
		
		frm_sistemtopla.fiyat(0).value=""
		frm_sistemtopla.tutar(0).value=""								
		for(i=0;i<islemciler.length;i++)
		{
			for(j=0;j<islemciler.item(i).getElementsByTagName("ad").length;j++)
			{
				stok_kod=islemciler.item(i).getElementsByTagName("kod").item(j).text;				
				stok_ad=islemciler.item(i).getElementsByTagName("ad").item(j).text;
				urun_fiyati=islemciler.item(i).getElementsByTagName("fiyat").item(j).text;
				urun_fiyati=urun_fiyati.replace(",",".")
				urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)				
				para_birimi=islemciler.item(i).getElementsByTagName("para").item(j).text;
				tlurun_fiyati=islemciler.item(i).getElementsByTagName("tlfiyat").item(j).text;
				tlurun_fiyati=tlurun_fiyati.replace(",",".")
				tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)				
				AddOption(frm_sistemtopla.stok_kod(0),stokAdDuzenle(stok_ad,urun_fiyati,para_birimi),stok_kod,urun_fiyati,tlurun_fiyati);
			}
		}
		
		if(socket=="*")
			sqlx="/Liste/category[@kod='ANA']/urun"
		else
			sqlx="/Liste/category[@kod='ANA']/urun[socket='"+socket+"']"
		
		var anakartlar=xmlDoc.selectNodes(sqlx)
		frm_sistemtopla.stok_kod(1).length=1
		frm_sistemtopla.st_adet(1).selectedIndex=0;					
		
		frm_sistemtopla.fiyat(1).value=""
		frm_sistemtopla.tlfiyat(1).value=""
		frm_sistemtopla.tutar(1).value=""								
		for(i=0;i<anakartlar.length;i++)
		{
			for(j=0;j<anakartlar.item(i).getElementsByTagName("ad").length;j++)
			{
				stok_kod=anakartlar.item(i).getElementsByTagName("kod").item(j).text;				
				stok_ad=anakartlar.item(i).getElementsByTagName("ad").item(j).text;
				urun_fiyati=anakartlar.item(i).getElementsByTagName("fiyat").item(j).text;
				urun_fiyati=urun_fiyati.replace(",",".")
				urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)				
				para_birimi=anakartlar.item(i).getElementsByTagName("para").item(j).text;
				tlurun_fiyati=anakartlar.item(i).getElementsByTagName("tlfiyat").item(j).text;
				tlurun_fiyati=tlurun_fiyati.replace(",",".")
				tlurun_fiyati=Math.round( (eval(tlurun_fiyati) + eval( (tlurun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama)				
				
				AddOption(frm_sistemtopla.stok_kod(1),stokAdDuzenle(stok_ad,urun_fiyati,para_birimi),stok_kod,urun_fiyati,tlurun_fiyati);
			}
		}
			
}

function defaultFiyatlar()
	{
		yuzde=0
		for(i=0;i<frm_sistemtopla.stok_kod.length;i++)
		{		
			for(j=0;j<frm_sistemtopla.stok_kod[i].length;j++)
			{
				if(frm_sistemtopla.stok_kod[i].options(j).value!="")
				{	
				sqldefault="/Liste/category/urun[(kod = '"+frm_sistemtopla.stok_kod[i].options(j).value+"')]"
				var defaultFiyat=xmlDoc.selectNodes(sqldefault)
				

				stok_kod=defaultFiyat.item(0).getElementsByTagName("kod").item(0).text;				
				stok_ad=defaultFiyat.item(0).getElementsByTagName("ad").item(0).text;
				urun_fiyati=defaultFiyat.item(0).getElementsByTagName("fiyat").item(0).text;	
				urun_fiyati=urun_fiyati.replace(",",".");
				urun_fiyati=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama);

				frm_sistemtopla.stok_kod[i].options(j).lang=urun_fiyati
				frm_sistemtopla.stok_kod[i].options(j).text=stokAdDuzenle(stok_ad,frm_sistemtopla.stok_kod[i].options(j).lang,"$")																			
			
				}
			}

			if(frm_sistemtopla.fiyat[i].value>0)
			{
			frm_sistemtopla.fiyat[i].value=frm_sistemtopla.stok_kod[i].options(frm_sistemtopla.stok_kod[i].selectedIndex).lang
			frm_sistemtopla.tutar[i].value=frm_sistemtopla.fiyat[i].value*frm_sistemtopla.st_adet[i].options(frm_sistemtopla.st_adet[i].selectedIndex).value
			}	
		}
		hesapla()		
	}
	function karEkle()
	{
		yuzde=frm_sistemtopla.txtKar.value
		
	/* bütün listelerin labellerini güncelle*/

		for(i=0;i<frm_sistemtopla.stok_kod.length;i++)
		{
			for(j=0;j<frm_sistemtopla.stok_kod[i].length;j++)
			{
			
				urun_fiyati=frm_sistemtopla.stok_kod[i].options(j).lang;
				urun_fiyati=urun_fiyati.replace(",",".");			
			//	frm_sistemtopla.stok_kod[i].options(j).lang=Math.round( (eval(urun_fiyati) + eval( (urun_fiyati)*(yuzde/100) ))*Math.pow(10, fiyat_yuvarlama) )/Math.pow(10, fiyat_yuvarlama);				
				if(j>0){
			//	stok_ad=frm_sistemtopla.stok_kod[i].options(j).text
			//	stok_ad=stok_ad.replace(urun_fiyati+" $","")				
			//	frm_sistemtopla.stok_kod[i].options(j).text=stokAdDuzenle(stok_ad,frm_sistemtopla.stok_kod[i].options(j).lang,"$")
				}
			}
			
			if(frm_sistemtopla.fiyat[i].value>0)
			{
			frm_sistemtopla.fiyat[i].value=frm_sistemtopla.stok_kod[i].options(frm_sistemtopla.stok_kod[i].selectedIndex).lang
			frm_sistemtopla.tutar[i].value=frm_sistemtopla.fiyat[i].value*frm_sistemtopla.st_adet[i].options(frm_sistemtopla.st_adet[i].selectedIndex).value
			}			
		}
		hesapla()
		
	}

function AddProductsToCart(s)
{
	var Qty =	frm_sistemtopla.txtQty.value
	if(Qty == "" || Qty <= 0)
	{
	Qty=1
	}
	var Cart =frm_sistemtopla.ddlSepet
	var products=""
	for(i=0;i<frm_sistemtopla.stok_kod.length;i++)
	{
		if(frm_sistemtopla.stok_kod(i).value!="")
		{		
		products=products + frm_sistemtopla.stok_kod(i).value + "," + frm_sistemtopla.st_adet(i).value  + "|" ;
		}
	}
	ASPNetPortal.ProductWizard.AddToCart(products,Cart.value,Qty,AddProductsToCart_CallBack);
}
function AddProductsToCart_CallBack(response)
{
	if (response.error != null)
	{
	return;
	}
	if (response.value == null)
	{
	return;
	}
document.location.href= response.value ;
}

/////////////////////////////7

