//function createRequestObject()
/*-------------------------------------------xhr-----------------------------------------------*/
var xmlHttp = new Array();
var dt = new Date();
try 
{
	xmlHttp[dt] = new XMLHttpRequest();
} 
catch (ms)
{
	try 
	{
		xmlHttp[dt] = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (nonms) 
	{
		try 
		{
			xmlHttp[dt] = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (ms) 
		{
			//xmlHttp[dt] = false;
		}  
	}
}
function oxmlHttp()
{
	var xmlHttp = new Array();
	var dt = new Date();
	try 
	{
		xmlHttp[dt] = new XMLHttpRequest();
	} 
	catch (ms)
	{
		try 
		{
			xmlHttp[dt] = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (nonms) 
		{
			try 
			{
				xmlHttp[dt] = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (ms) 
			{
				//xmlHttp[dt] = false;
			}  
		}
	}
	return xmlHttp[dt];
}

//-----------konfigurasyon----------//
function fiyatVer(alan, altalan)
{	
	var alan1= 'f_' +alan; 
	var alan2= 'f_t_' +alan;
	var val1=  document.getElementById('ctl00_ctl00_sut2_c600_conf_' +alan).value;	
	var div01 = document.getElementById(alan1);
	var div02 = document.getElementById(alan2);
	if (val1 != "-")
	{
		var val2=  document.getElementById('ctl00_ctl00_sut2_c600_conf_m_' +alan).value;
		var splVal= val1.split("|||");
		var url = "/ashx/server.ashx?conf=0&confpid=fiyat&prid=" + splVal[0];
		var xmlHttp= oxmlHttp();
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4) 
			{	
				if (xmlHttp.status == 200 || xmlHttp.status == 304) 
				{
					div01.innerHTML= xmlHttp.responseText;
					div02.innerHTML= parseFloat(xmlHttp.responseText)*parseFloat(val2);
					listeVer(alan, altalan);
					gtVer();
				}
			}
		}
		xmlHttp.send(null);
	}
	else
	{
		div01.innerHTML= '0';
		div02.innerHTML= '0';
		gtVer();
	}
	document.getElementById('imgBox').style.display= 'none';
	
}
function toplamVer(alan)
{ 	
	var alan1= 'f_' +alan; 
	var alan2= 'f_t_' +alan; 
	var val=  document.getElementById('ctl00_ctl00_sut2_c600_conf_m_' +alan).value;
	var div01 = document.getElementById(alan1);
	var div02 = document.getElementById(alan2);
	var topf=String(parseFloat(div01.innerHTML)*parseFloat(val));
	div02.innerHTML= topf;
	gtVer();
}
function resimGoster(alan)
{
	var val1=  document.getElementById('ctl00_ctl00_sut2_c600_conf_' +alan).value;
	if (val1 != "-")
	{
		var div= document.getElementById('imgBox');
		var img=document.getElementById('imgures');
		$.blockUI({ message: $('#imgBox'), css: { width: '400px' } });  
		$('.blockOverlay').attr('title','Resmi Kapat').click($.unblockUI); 
		document.getElementById('imgures').setAttribute("src", "rsm/site/bekle.gif");
		var splVal= val1.split("|||");
		var url = "/ashx/server.ashx?conf=0&confpid=resim&prid=" + splVal[0];
		var xmlHttp= oxmlHttp();
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4) 
			{	
				if (xmlHttp.status == 200 || xmlHttp.status == 304) 
				{
					document.getElementById('imgures').setAttribute("src", xmlHttp.responseText);
				}
			}
		}
		xmlHttp.send(null);
	}
}
function listeGoster(alan)
{
	var val1=  document.getElementById('ctl00_ctl00_sut2_c600_conf_' +alan).value;
	if (val1 != "-")
	{
		$.blockUI({ message: $('#listBox'), css: {  width: '600px', top:'200px'} });  
		$('.blockOverlay').attr('title','Kapat').click($.unblockUI); 
		var splVal= val1.split("|||");
		$.ajax({
			  url: '/ashx/server.ashx',
			  data: 'conf=config&confpid=detay&prid=' + splVal[0],
			  dataType: 'json',
			  success: function(JSON) {
						$('#div1').html(JSON.liste);
						$('#div2').html(JSON.aciklama);
						$('div#div2').fadeOut("slow"); 
						$('div#div1').fadeIn("slow");
			  },
			  error: function(xhr, ajaxOptions, thrownError){
							mesajVer('Bir hata olustu. Lütfen yeniden deneyiniz.');
			  }
			})
		
	};
}
function mesajVer(mesaj)
{
	var m_div = document.createElement('div');//line
	m_div.setAttribute('id', 'mView');
	m_div.setAttribute('style', 'text-align:left;  font-family:Tahoma, Geneva, sans-serif; color:#fff; font-size:14px; font-weight:bold');
	document.body.appendChild(m_div);
	document.getElementById('mView').innerHTML= mesaj;
					$.blockUI({ 
								message: $('div#mView'), 
								fadeIn: 700, 
								fadeOut: 700, 
								timeout: 2000, 
								showOverlay: false, 
								centerY: false, 
								css: { 
									 
									top: '10px', 
									left: '', 
									right: '10px', 
									border: 'none', 
									padding: '5px',
									backgroundColor: '#000',
									'-webkit-border-radius': '10px', 
									'-moz-border-radius': '10px', 
									opacity: .6, 
									color: '#fff' 
									}
								})
	}
function listeVer(ustalan, alan)
{
	var csel= document.getElementById('ctl00_ctl00_sut2_c600_conf_' +ustalan); //kontrol
	var tsel= document.getElementById('ctl00_ctl00_sut2_c600_conf_' +alan); //hedef	
	var url= "/ashx/server.ashx?conf=0&confpid=fillcb&";
	//document.write();
	if(csel.value != '-' && tsel && tsel.options.length == 0)
	{
		switch (alan)
		{
			case 'mb':
				url+= "l1=OEM&";		
				var sval= csel.value.split('|||');

				if(sval[1]=='INTEL')
				{
					url+= "l2=OEMMBDINT";
				}
				if(sval[1]=='AMD')
				{
					url+= "l2=OEMMBDAMD";
				}//300609'da kategorilerde yapilan degisikliklere karsi degisiklikler 
				//url+= "l1=OEM&l2=OEMMBD";
			break;
			case 'ram':
				url+= "l1=OEM&l2=OEMMEMDR2*OEMMEMPC_";
			break;
			case 'hdd':
				url+= "l1=OEM&l2=OEMHDDINT";
			break;
			case 'vga':
				url+= "l1=OEM&l2=OEMVGAPCX";
			break;
			case 'opt':
				url+= "l1=OEM&l2=OEMOPTDVR*OEMOPTDVW";
			break;
			case 'chs':
				url+= "l1=OEM&l2=OEMCAS*OEMCASNOR";
			break;
			case 'mon':
				url+= "l1=OEM&l2=OEMMONLCD";
			break;
			case 'klv':
				url+= "l1=OEM&l2=OEMKBDCAB*OEMKMSCAB*OEMKMSWRL";
			break;
			case 'mou':
				url+= "l1=OEM&l2=OEMMOUCAB*OEMMOUWRL";
			break;
			case 'fdd':
				url+= "l1=OEM&l2=OEMCRD";
			break;
			case 'cam':
				url+= "l1=OEM&l2=OEMCAM";
			break;
			case 'spk':
				url+= "l1=OEM&l2=OEMSPK1_1*OEMSPK2_1*OEMSPK4_1";
			break;
			case 'prn':
				url+= "l1=PRI&l2=PRIMULINK*PRIMULLAS*PRIINKINK*PRILASMON*PRILASCOL";
			break;
			
		}
		var xmlHttp= oxmlHttp();
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4) 
			{	
				if (xmlHttp.status == 200 || xmlHttp.status == 304) 
				{
					var rows= xmlHttp.responseText.split('///nv///');
					tsel.options.length= 0;
					for(i=0; i<rows.length-1; i++)
					{
						var pair= rows[i].split('///v-t///');
						var oOption = document.createElement("OPTION");
						oOption.value = pair[0];
						oOption.text = pair[1]
						tsel.options.add(oOption);
					}
				}
			}
		}
		xmlHttp.send(null);
	}
}
function gtVer()
{
	var divs = document.getElementsByTagName('div');
	var gt= 0;
	for (var i = 0; i < divs.length; i++) 
	{
		var div = divs[i];
		if (div.id.indexOf('f_t_') == 0 &&  div.innerHTML !='undefined')
		{
			gt+= parseInt(div.innerHTML); 
		}
	}
	document.getElementById('gt').innerHTML= String(gt);
}
function prPreview()
{
	document.getElementById('eView').style.display='none';
	var divs = document.getElementsByTagName('div');
	var pdiv = document.getElementById('pView');
	var gt= 0;
	var ident;
	var ddl;
	if(document.getElementById('printdiv'))
	{
		pdiv.removeChild(document.getElementById('printdiv'));
	}
	var mdiv = document.createElement('div');
	mdiv.setAttribute('id', 'printdiv');
	pdiv.appendChild(mdiv);
	for (var i = 0; i < divs.length; i++) 
	{
		var div = divs[i];
		if (div.id.indexOf('satir_') == 0)
		{
			var l_div = document.createElement('div');//line
			l_div.setAttribute('id', 'ldiv');
			l_div.setAttribute('style', 'width:99%; height:25px; clear:both; ');
			mdiv.appendChild(l_div);
			ident= div.id.substring(6, div.id.length);
			var h_div = document.createElement('div'); //header
			h_div.setAttribute('id', 'hdiv');
			h_div.setAttribute('style', 'width:10%; font-family: Arial, Helvetica, sans-serif;font-size: 11px;font-style: normal;font-weight: bold;color: #000000; float:left;');
			h_div.innerHTML= document.getElementById('hdr_' +ident).innerHTML;
			l_div.appendChild(h_div);
			var i_div = document.createElement('div');//i ? ama seçilen donanim bu...
			i_div.setAttribute('id', 'idiv');
			ddl= document.getElementById('ctl00_ctl00_sut2_c600_conf_' +ident);
			try
			{
				i_div.innerHTML=  ddl.options[ddl.selectedIndex].text=='Seçiniz'?'-':ddl.options[ddl.selectedIndex].text;
			}
			catch(e){i_div.innerHTML="-";}
			i_div.setAttribute('style', 'font-family:Tahoma, Geneva, sans-serif, sans-serif;font-size: 12px;font-style: normal;color: #000000; width:70%; float:left; text-align:center;');
			l_div.appendChild(i_div);
			var f_div = document.createElement('div');//fiyat
			f_div.setAttribute('id', 'fdiv');
			f_div.setAttribute('style', 'font-family: Arial, Helvetica, sans-serif;font-size: 11px;font-style: normal;color: #000000; width:7%; float:left');
			f_div.innerHTML= document.getElementById('f_' +ident).innerHTML;
			l_div.appendChild(f_div);
			var m_div = document.createElement('div');//miktar
			m_div.setAttribute('id', 'mdiv');
			m_div.setAttribute('style', 'font-family: Arial, Helvetica, sans-serif;font-size: 11px;font-style: normal;color: #000000; width:30px; float:left');
			ddl= document.getElementById('ctl00_ctl00_sut2_c600_conf_m_' +ident);
			m_div.innerHTML= f_div.innerHTML=='0'?'x  0':'x  ' +ddl.options[ddl.selectedIndex].text;
			l_div.appendChild(m_div);
			var f_t_div = document.createElement('div');// birimfiyat x miktar
			f_t_div.setAttribute('id', 'ftdiv');
			f_t_div.setAttribute('style', 'font-family: Arial, Helvetica, sans-serif;font-size: 11px;font-style: normal;color: #000000; width:50px; float:left; font-weight:bold; text-align:right');
			f_t_div.innerHTML= document.getElementById('f_t_' +ident).innerHTML +' TL';
			l_div.appendChild(f_t_div);
		}
	}
	var gt_div = document.createElement('div');
	gt_div.setAttribute('id', 'ldiv');
	mdiv.appendChild(gt_div);
	var gtdiv = document.createElement('div');
	gtdiv.setAttribute('id', 'gtdiv');
	gtdiv.innerHTML= 'TOPLAM: ' +document.getElementById('gt').innerHTML + ' TL';
	gt_div.appendChild(gtdiv);	
	document.getElementById('eView').style.display='none';
}
function printOut()
{
	if(!document.getElementById('printdiv'))
	{
		prPreview();
	}	
	document.getElementById('eView').style.display='none';
	window.print();
}
function cEdit()
{
	var pdiv = document.getElementById('pView');
	if(document.getElementById('printdiv'))
	{
		pdiv.removeChild(document.getElementById('printdiv'));
	}	
	document.getElementById('eView').style.display='block';

}	
/*------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------FormControl---------------------------------*/
	$(document).ready(function(){
	  $("#firma").focus();
	});
    $("input, select, textarea").focus(function () {
         $(this).css('border','1px solid #930');
    });
	$("input, select, textarea").blur(function () {
         $(this).css('border','1px solid #CCC'); 
    });	



