function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}


function numaraYapma(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}	
	textBox.value = trim(textBox.value);
}

function secBirak(grpStr, button) {
 var form, el, e, f = 0;
 var unbuttoned = (button.value.substring(0,2).toLowerCase() == 'un');
 while (form = document.forms[f++]) {
   e = 0;
   while (el = form.elements[e++])
   if (el.type == 'checkbox' && el.name.indexOf(grpStr) != -1)
      el.checked = !unbuttoned;
 }
 button.value = unbuttoned ? button.value.substring(2) : 'un' + button.value;
}

function teslimataKopyala(isChecked)
{
	with (window.document.siparisFormu) {
		if (isChecked) {
			tesad.value = fatad.value;
			tesmail.value = fatmail.value;
			testel.value = fattel.value;
			tesadr.value = fatadr.value;
			tessehr.value = fatsehr.value;
			
			tesad.readOnly  = true;
			tesmail.readOnly   = true;
			testel.readOnly   = true;
			tesadr.readOnly   = true;
			tessehr.readOnly      = true;	
		} else {
			tesad.readOnly  = false;
			tesmail.readOnly   = false;
			testel.readOnly   = false;
			tesadr.readOnly   = false;
			tessehr.readOnly      = false;
		}
	}
}

function hepsiniSec(x, checked) {
  forms = document.forms;
  for(j=0; j<forms.length;j++) {
    f = forms[j];
    elems = f.elements;
    for(i=0; i<elems.length; i++) {
      elem = elems[i];
      if (elem.name==x && elem.type=='checkbox') {
        elem.checked = checked;  
      }
    }
  }  
}

function sepetSilKontrol(sepet) {
  if (!document.sepet.sil.length) {
  		if (sepet.sil.checked) {
		document.sepet.action="?d=sepet&spt=sil"; 
		document.sepet.submit();
		} else {
		alert("Bu işlem için sipariş seçmelisiniz!");
		return(false)
		}
  } else {
  	var tiklanmislar = 0;
  	for (var i=0; i<document.sepet.sil.length; i++) {
    	if (sepet.sil[i].type == 'checkbox' && sepet.sil[i].checked)
      	tiklanmislar++;
  	}
  	if(document.sepet.sil.length<1) { return(true); }
	else if(tiklanmislar < 1){ alert("Bu işlem için en az bir sipariş seçmelisiniz!"); return(false); }
	else {  document.sepet.action="?d=sepet&spt=sil"; document.sepet.submit(); }
	return(false);
  }
}

function sepetformnuyol()
{
  document.sepetimFormu.submit();
}

function sepetGncKontrol(sepet) {
	document.sepet.action="?d=sepet&spt=gnc"; 
	document.sepet.submit();
}

function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}

function sepetFormKontrol(theForm)
{
if(theForm.miktar.value=="") {
    alert("Sipariş miktarını giriniz!");
    theForm.miktar.focus();
    return(false);
} else {
    acPencereyi("?d=sepet&spt=ekle&urun="+theForm.miktar.value, "pencere");
    return true;
  }
}

function acPencereyi(sayfa,gen,uz,x,y) {
	x = (640 - gen)/2, y = (480 - uz)/2;

    if (screen) {
        y = (screen.availHeight - uz)/2;
        x = (screen.availWidth - gen)/2;
    }

    pencerem = window.open(sayfa,'windowRef','width=' + gen + ',height=' + uz +'scrollbars=1,status=1,top='+ y +',left='+ x +',screenX='+ x +',screenY='+ y);
    if (!pencerem.opener) pencerem.opener = self;
}

function bultenFormKontrol(theForm)
{
  if (theForm.bulteneposta.value == ""||theForm.bulteneposta.value == "adres@e-posta.com")
  {
    alert('Geçerli bir e-posta adresi yazınız!');
    theForm.bulteneposta.value='';
    theForm.bulteneposta.focus();
    return (false);
  }
  return (true);
}

function kontakFormKontrol(theForm)
{
  if (theForm.defad.value == "")
  {
    alert('Lütfen isminizi yazınız!');
    theForm.defad.focus();
    return (false);
  }
  if (theForm.defmail.value == "")
  {
    alert('Lütfen e-posta adresinizi yazınız!');
    theForm.defmail.focus();
    return (false);
  }
  if (theForm.defdef.value == "")
  {
    alert('Lütfen yorumunuzu yazınız!');
    theForm.defdef.focus();
    return (false);
  }
  return (true);
}

function fiyt() {;}

function toggleVisibility(me){
	if (me.style.visibility=='hidden'){
			me.style.visibility='visible';
			}
		else {
			me.style.visibility='hidden';
			}
		}
	
/* Win IE 5.5 & 6 için png düzeltmesi */
function correctPNG() 
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function change() {
    var color1 = '#ccffff';
    var color2 = '#dd00ff';
    if (document.layers)
        window.document.layers[i].bgColor = color1;
    else if (document.all)
        window.document.all[i].style.background = color2;
}
