invalidaddress=new Array();
invalidaddress[0]="afsfa";
invalidaddress[1]="fsadfa";
invalidaddress[2]="daef";invalidaddress[3]="sfasef";
var testresults;
//////////
function Trim(s) 
{

	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
		{
			s = s.substring(1,s.length);
		}

	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
		{
			s = s.substring(0,s.length-1);
		}
	return s;
}
////////////////*
function checkbae(mailadres){
	//if (document.layers||document.getElementById||document.all)
		return checkemail(mailadres);
	//else
	//	return true;
}
function checkemail(mailadres){
	var invalidcheck=0;
	//var str=document.getElementById('txtEmail').value;
	var str = mailadres;
	//var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var filter=(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
	if (filter.test(str)){
		var tempstring=str.split("@");
		tempstring=tempstring[1].split(".");
		for (i=0;i<invalidaddress.length;i++){
			if (tempstring[0]==invalidaddress[i])
				invalidcheck=1;
		}
		if (invalidcheck!=1)
			testresults=true;
		else{
			//alert("Please input a more official email address!")
			testresults=false;
		}
	}
	else{
		//alert("Please input a valid email address!")
		testresults=false;
	}
	return (testresults)
}
//////////////////////////////////
function isCurrency(ch,key) 
{
	if (!(ch >= '0' && ch <= '9') && key != 8 && key!=45 && key!=46) 
	{
		return false;
	}
	return true;
}

function getkey(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
		return e.which;
	else
		return null;
}


function keyCheck(e, obj)
{
	var key, ch;
	key = getkey(e);
//alert(key);
	if (key == null) return true;
	ch = String.fromCharCode(key);

	if (!isCurrency(ch,key)) 
	{
		if (window.event)
			window.event.returnValue = false;
		else
			e.preventDefault();
	}
	return true;
}
//////////////////////////
function ValidateCreditCard(kartno,karttip)
{
	var cardNumber = kartno;
	var cardType = karttip;
	var isValid = false;
	var ccCheckRegExp = /[^\d ]/;
	isValid = !ccCheckRegExp.test(cardNumber);

	if (isValid)
	{
		var cardNumbersOnly = cardNumber.replace(/ /g,"");
		var cardNumberLength = cardNumbersOnly.length;
		var lengthIsValid = false;
		var prefixIsValid = false;
		var prefixRegExp;

		switch(cardType)
		{
			case "MASTERCARD":
				lengthIsValid = (cardNumberLength == 16);
				prefixRegExp = /^5[1-5]/;
				break;

			case "VISA":
				lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
				prefixRegExp = /^4/;
				break;
	
			case "AMERICANEXPRESS":
				lengthIsValid = (cardNumberLength == 15);
				prefixRegExp = /^3(4|7)/;
				break;

			default:
				prefixRegExp = /^$/;
				alert("Card type not found");
		}

		prefixIsValid = prefixRegExp.test(cardNumbersOnly);
		isValid = prefixIsValid && lengthIsValid;
	}

	if (isValid)
	{
		var numberProduct;
		var numberProductDigitIndex;
		var checkSumTotal = 0;

		for (digitCounter = cardNumberLength - 1; digitCounter >= 0; digitCounter--)
		{
			checkSumTotal += parseInt (cardNumbersOnly.charAt(digitCounter));
			digitCounter--;
			numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
			for (var productDigitCounter = 0;productDigitCounter < numberProduct.length; productDigitCounter++)
			{
				checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter));
			}
		}

		isValid = (checkSumTotal % 10 == 0);
	}

	return isValid;
}

////////////////////////////////////////////////////////
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}
function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}
function displayItem(key){
	if(queryString(key)=='false') 
	{
		//result.innerHTML="you didn't enter a ?name=value querystring item.";
		return "";
	}else{
		//result.innerHTML+=queryString(key)+"<BR>";
		return queryString(key);
	}
}
////////////////////////////////////////////////////////

function bigac(imgname)
{
	window.open('productPhoto.aspx?p='+imgname,'','top=10,left=10,width=100,height=100');
}
////////////////////////////////////////////////////////

String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}

////////////////////////////////////////////////////////

function tarihyaz()
{
    var gunler = new Array(7);
    var aylar = new Array(12);
    gunler[0]="Pazar";
    gunler[1]="Pazartesi";
    gunler[2]="Sal&#305;";
    gunler[3]="Çar&#351;amba";
    gunler[4]="Per&#351;embe";
    gunler[5]="Cuma";
    gunler[6]="Cumartesi";
    aylar[0]="01";
    aylar[1]="02";
    aylar[2]="03";
    aylar[3]="04";
    aylar[4]="05";
    aylar[5]="06";
    aylar[6]="07";
    aylar[7]="08";
    aylar[8]="09";
    aylar[9]="10";
    aylar[10]="11";
    aylar[11]="12";
    
    var date = new Date();
     
	var day = date.getDate();
	var month = aylar[date.getMonth()];
	var year = date.getYear();
	
	document.write(day+"."+month+"."+year+" - "+gunler[date.getDay()]);
}
////////////////////////////////////////////////////////
function printdiv(obj)
{
    var a = window.open('','','');
    a.document.open("text/html");
    a.document.write('<link rel="stylesheet" href="style.css" />');
    a.document.write(document.getElementById(obj).innerHTML);
    a.document.close();
    a.print();
}
////////////////////////////////////////////////////////
function hsObj(obj)
{
    document.getElementById(obj).style.display == '' ? document.getElementById(obj).style.display = 'none' : document.getElementById(obj).style.display = '';
}
////////////////////////////////////////////////////////
function validDate(bastar,bittar)
{
	//bastar = document.getElementById('BaslaTarih').value;
	//bittar = document.getElementById('BitisTarih').value;
	
	var firstDate1 = new Date(bastar.split('/')[2],bastar.split('/')[1]-1,bastar.split('/')[0]);
	//var firstDate = Date.UTC( firstDate1.getFullYear(), firstDate1.getMonth()+1, firstDate1.getDate());
	var firstDate = Date.parse( (firstDate1.getMonth()+1)+"-"+firstDate1.getDate()+"-"+ firstDate1.getFullYear());
	//alert(firstDate);
	var secondDate1 = new Date(bittar.split('/')[2],bittar.split('/')[1]-1,bittar.split('/')[0]);
	//var secondDate = Date.UTC( secondDate1.getFullYear(), secondDate1.getMonth()+1, secondDate1.getDate());
	var secondDate = Date.parse( (secondDate1.getMonth()+1)+"-"+secondDate1.getDate()+"-"+ secondDate1.getFullYear());
	//alert(secondDate);
	if(secondDate-firstDate>2592000000){return false;}
	else return true;
}
////////////////////////////////////////////////////////
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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; ad=args[i+1]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=Trim(val.value))!="") {//val.value
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+ad+' geçerli değil.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+ad+' gereklidir.\n'; }
  } if (errors) alert('Doldurulması Gereken Alanlar:\n'+errors);
  document.MM_returnValue = (errors == '');
}
////////////////////////////////////////////////////////
function frmsepgo(uid,adt,dsn,sil)
{
	document.getElementById('sepurunid').value=uid;
	document.getElementById('sepadet').value=adt;
	document.getElementById('sepdesen').value=dsn;
	document.getElementById('sepsil').value=sil;
	document.getElementById('frmSep').action='addbasket.aspx';
	document.getElementById('frmSep').submit();
}
////////////////////////////////////////////////////////
function marReq(mid)
{
	if(mid != "")
		location.href='sto.aspx?id='+mid;
}
////////////////////////////////////////////////////////
function frmButGiz(bid,sid)
{
	document.getElementById(bid).style.display = 'none';
	document.getElementById(sid).style.display = '';
}
////////////////////////////////////////////////////////
function frmAraGo()
{
	if(Trim(document.getElementById('txtSolAra').value).length<3)
	{
		alert('En az 3 karakterli bir kelime yazınız.');
		return false;
	}
	document.getElementById('frmSolAra').action='search.aspx';
	document.getElementById('frmSolAra').submit();
}
///////////////////odeme sayfaları icin/////////////////
function frmKampCk()
{
	var sayac = 0;
	for(i=1;i<6;i++)
	{
		if(Trim(document.getElementById('txtEmail'+i).value) == Trim(document.getElementById('txtSipEmail').value))		
		{
			alert('Sipariş bilgilerinin gönderildiği e-mail adresi tavsiye e-mail adresi olamaz.');
			return false;
		}
		if(Trim(document.getElementById('txtEmail'+i).value) == Trim(document.getElementById('txtFatEmail').value))		
		{
			alert('Fatura bilgilerindeki e-mail adresi tavsiye e-mail adresi olamaz.');
			return false;
		}
		for(j=i+1;j<6;j++)
		{
			if(Trim(document.getElementById('txtEmail'+i).value) == Trim(document.getElementById('txtEmail'+j).value))
			{
				alert('Tavsiye e-mail adresleri aynı olamaz.');
				return false;
			}
		}
		if(document.getElementById('hidCkEmail'+i).value == 1)
			sayac++;
	}
	if(sayac != 5)
	{
		alert('Tavsiye e-mail adreslerinin tümü geçerli e-mail adresleri olmalıdır.');
		return false;
	}
	return true;
}
///////////////////////////////////////////////////////////////////

function sbmtForm(obj)
{
	if(getkey(event) == 13)
		document.getElementById(obj).submit();
}