// JavascriptStore

function OpenDialogWindow(url, name, w, h)
{
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	win = window.open(url, name, 'toolbar=0, status=1, menubar=0, location=0, resizable=1, scrollbars=auto, dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
	win.focus();
}

function GetDialogResult(command, parameter)
{
	FindObject('DialogResultCommand').value=command;
	FindObject('DialogResultParameter').value=parameter;
	FindObject('DialogResultIsReceipt').value='1';
	FindObject('Form1').submit();
}

function Popup(url,w,h,rs,sc){
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	window.open(url,'','toolbar=0, status=1, menubar=0, location=0, resizable= ' + rs + ', scrollbars=' + sc + ' , dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
}

// End Javascript store




var isNS = (navigator.appName.indexOf("Netscape")!=-1); 

function FindObject(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=FindObject(n,d.layers[i].document);
  if(!x && document.getElementById) 
		x=document.getElementById(n); 
	return x;
}

function onlyNumber(e) 
{
	var keyCode = (isNS) ? e.which : e.keyCode;
	if ((keyCode<48 || keyCode>57)&&keyCode!=8&&keyCode!=0){
	return false;}
}

function onlyLetter(e) 
{
	var keyCode = (isNS) ? e.which : e.keyCode;
	if (keyCode > 47 && keyCode<58){
		return false;
	}
}

function CheckEmail(TmpStr) 
{
	if (TmpStr=="")
	{
		return true;
	}
	else
	{
		var i, atPos, atPos2, InvalidChars=" üÜðÐýþÞÝçÇöÖ!#/*{[()]}";

		for (i=0; i<InvalidChars.length; i++)
			if (TmpStr.indexOf(InvalidChars.charAt(i)) != -1) {
				return false;
			}
		atPos = TmpStr.indexOf("@");
		atPos1 = TmpStr.indexOf(".");
		atPos2 = TmpStr.indexOf("@", atPos+1);
		if ((atPos < 1) || (atPos1 < 1) || (atPos2 != -1)) {
			return false;
		}
	}
}

function autoTab(input,focus, len, e) { 
	var keyCode = (isNS) ? e.which : e.keyCode; 
	if (keyCode == 13)  window.event.keyCode = 9;
	var filter = (isNS) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if(input.value.length >= len && !containsElement(filter,keyCode)) { 
		input.value = input.value.slice(0, len); 
		document.all[focus].focus();
	//	input.form[(getIndex(input)+1) % input.form.length].focus(); 
	} 
	return true; 
}

function trim(str)
{
	while(str.charAt(0)==' ')
		str=str.substring(1,str.length);
	while(str.charAt(str.length-1)==' ')
		str=str.substring(0,str.length-1);
	return str;
}

function isNumber(theElement)
{
	var s = Math.abs(theElement.value);
	var filter=/(^\d+$)/;
	if (s.length == 0 ) return true;
	if (isNaN(theElement)) return true;
	if (filter.test(s))
		return true;
	else {
		return false;
	}
}

function PressTabInsteadOfEnter(elementIDToFocus, doPostBackForElement){
		keyCode=(document.layers)?e.which:window.event.keyCode;
		if (keyCode == 13){
			window.event.keyCode = 9;
			FindObject(elementIDToFocus).focus();
			if (doPostBackForElement)
				__doPostBack(elementIDToFocus,'');
		}
		return true;
}

function Flash(objID)
{
		var obj  = FindObject(objID);
		
		if (obj.style.visibility == 'hidden')
			obj.style.visibility = 'visible';
		else
			obj.style.visibility = 'hidden';
		
		window.setTimeout("Flash('"+objID +"')", 500);
}

/*
function CheckRadio(obj)
{
	//if(obj.checked)
	//{
		var frm = document.forms[0];
		for(i=0;i<frm.lenght;i++)
		{
			if(frm.elements[i].id.indexof('radio')!=-1)
			{
				if(frm.elements[i].accesskey!=obj.accesskey && frm.elements[i].checked)
				{
					frm.elements[i].checked=false;
				}
			}
		}
	//}
}
*/


function calc(txtgenislik,txtyukseklik)
{
	var yukseklik = document.getElementById('CustommmProductSizeUC21_txtyukseklik');

	var genislik = document.getElementById('CustommmProductSizeUC21_txtgenislik');
	var birimfiyat = document.getElementById('CustommmProductSizeUC21_hdnbirimfiyat');
	var sonuc = document.getElementById('CustommmProductSizeUC21_hdnsonuc');
	var lbltoplamm2 = document.getElementById('CustommmProductSizeUC21_lblm2top');
	var lbltoplam = document.getElementById('CustommmProductSizeUC21_lblsonuc');
	var birimci = document.getElementById('ProductInformationUC1_lblPrice');
	

	intOnly(genislik);
	intOnly(yukseklik);
	
	
	toplamfiyat = 0;
	toplamm2 = 0;
	
	if(yukseklik.value != '' & genislik.value != '')
	{
		
		yuks = parseFloat(yukseklik.value);
		gens = parseFloat(genislik.value);
		oran = 1;
		/* if(birimfiyat.value != '')*/
		var degeroran = birimci.innerHTML.replace('TL','')
			oran = parseFloat(degeroran.replace(',','.'));
			
		toplamm2 = (yuks * gens) / 10000 ;	
		toplamfiyat = toplamm2 * oran;
		
		if(!isNaN(toplamm2))
		{
			lbltoplamm2.innerHTML = toplamm2.toFixed(2);
			lbltoplam.innerHTML = toplamfiyat.toFixed(2) + ' TL';
			enableTxts();
			sonuc.value = toplamm2 + '-' + toplamfiyat + '-' + yuks + '-' + gens;
			
		}
	}
	else
	{
		lbltoplamm2.innerHTML = '';
		lbltoplam.innerHTML = '';
		disableTxts();
	}
}

function disableTxts()
{
	document.getElementById('CustommmProductSizeUC21_txtadsoyad').disabled = true;
	document.getElementById('CustommmProductSizeUC21_txtmail').disabled = true;
	document.getElementById('CustommmProductSizeUC21_txttelno').disabled = true;
	document.getElementById('CustommmProductSizeUC21_addtobasket').disabled = true;
	
	document.getElementById('CustommmProductSizeUC21_txtadsoyad').style.backgroundColor = 'Gray';
	document.getElementById('CustommmProductSizeUC21_txtmail').style.backgroundColor = 'Gray';
	document.getElementById('CustommmProductSizeUC21_txttelno').style.backgroundColor = 'Gray';
	document.getElementById('CustommmProductSizeUC21_addtobasket').style.backgroundColor = 'Gray';
}
function enableTxts()
{
	document.getElementById('CustommmProductSizeUC21_txtadsoyad').disabled = false;
	document.getElementById('CustommmProductSizeUC21_txtmail').disabled = false;
	document.getElementById('CustommmProductSizeUC21_txttelno').disabled = false;
	document.getElementById('CustommmProductSizeUC21_addtobasket').disabled = false;
	
	document.getElementById('CustommmProductSizeUC21_txtadsoyad').style.backgroundColor = 'White';
	document.getElementById('CustommmProductSizeUC21_txtmail').style.backgroundColor = 'White';
	document.getElementById('CustommmProductSizeUC21_txttelno').style.backgroundColor = 'White';
	document.getElementById('CustommmProductSizeUC21_addtobasket').style.backgroundColor = 'White';
}

function intOnly(i)
{
	if(i.value.length>0) 
	{  
		i.value = i.value.replace(/[^\d]+/g, ''); 
	}
	
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



