var isNav, isIE;
var checked=0;
var globalMaxAmount=0;
var numberOfHediye=0;
var hediyeTipi=1;
var user_agent = navigator.userAgent;
var isOpera = user_agent.indexOf("Opera") >= 0;
var isFirefox = user_agent.indexOf("Firefox") >= 0;
var isWin32up = user_agent.indexOf("Win32") >= 0 
	|| user_agent.indexOf("Win64") >= 0
	|| user_agent.indexOf("Windows NT") >= 0;

// disallow Opera faking IE
var isIE = !isOpera && user_agent.indexOf("MSIE") >= 0;
var isIE55up = isIE && isWin32up && user_agent.match(/MSIE ((5\.5)|[6789])/);
var isIE55dn = isIE && !isIE55up;
var browser = "other";

if (isFirefox)
	browser = "firefox";
else if (isOpera) 
	browser = "opera";
else if (isIE55up) 
	browser = "ie55p";
else if (isIE55dn) 
	browser = "ie55d";
/** returns a browser specific alpha image layer.
* - imgPNG - PNG with alpha channel
* - imgGIF - failsafe transparent GIF image
* - imgSpacer - transparent spacer GIF image
*/
function alphaImgLayer( width, height, imgSpacer,imgPNG,imgGIF,href) {
	var divStyle = 'padding:0px;margin:0px;width: ' + width + 'px; height: ' + height + 'px;'+(href?'cursor:pointer;':'');
	var html;
	
	if (isIE55up) {
		// use directX filters
		// ak ie 
		var len = imgPNG.length;
		var img = imgPNG.substring(0,len-4);
		var ext = imgPNG.substring(len-4,len);
		
		img = img + "_ie" + ext;//alert(img);
		html = '<div style="' + divStyle + ' filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + img + '\',sizingMethod=\'scale\');\">';
		html +=	(href?'<a href="'+href+'">':'')+'<img src="' + imgPNG + '" width="' + width + '" height="' + height + '" border="0" alt="">'+(href?'</a>':'')+'</div>';
	} else if (isOpera || isFirefox) {//alert("png ff");
		// use PNGs directly
		html = '<div style="' + divStyle + '"><img src="' + imgPNG + '" width="' + width + '" height="' + height + '" border="0" style="border: 0px solid #ffee00;" alt=""></div>';
	} else {//alert("gif");
		// use failsafe GIF images
		html = '<div style="' + divStyle + '"><img src="' + imgPNG + '" width="' + width + '" height="' + height + '" border="0" alt=""></div>';
	}
	
	document.write(html);
}

if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape")
		isNav = true;
	else 
		isIE = true;
}

function AddOption(SelectBox,Text,Value,index){
	var oOption = document.createElement("OPTION");
	oOption.text=Text;
	oOption.value=Value;
	SelectBox.options.add(oOption,index);
}

function FillSeries(lst,start,end){
	var menu_lst = document.getElementById('lst') ;
	
	for (var i=start;i<=end;i++) {
		var op=document.createElement("OPTION");
		var i2=(i<10)?'0'+i:''+i;
		op.text=op.value=i2;
		lst.options.add(op);
	}
}

function FillSeries_div(lst,start,end){
	var menu_lst = document.getElementById('lst') ;
	for (var i=start;i<=end;i++) {
		var op=document.createElement("OPTION");
		var i2=(i<10)?'0'+i:''+i;
		op.text=op.value=i2;
		menu_lst.options.add(op);
	}
}

function FillDays(lst){
	
	FillSeries(lst,1,31);
}

function FillMonths(lst){
	FillSeries(lst,1,12);
}

function FillYears(lst,year1,year2) {
	
	for (var i=year1;i<=year2;i++) {
		var op=document.createElement("OPTION");
		op.value=op.text=i;
		lst.options.add(op);
	}
}

function fnChkClick(sID){
	if(document.getElementById(sID).checked){
		document.getElementById("trFatura").style.display="block";
	}else{
		document.getElementById("trFatura").style.display="none";
	}
}

function  fnrdClick(sName){
	if (document.getElementsByName(sName)[0].checked) {
		document.getElementById("trSirket").style.display = "none";
		document.getElementById("trBaskasi").style.display = "block";
	}
	else {
		document.getElementById("trSirket").style.display = "block";
		document.getElementById("trBaskasi").style.display = "none";
	}
}

var isIE = document.all ? true : false;
var submitcount=0;

function Gonder( thisForm )
{
	if (submitcount == 0)
	{
		submitcount++;
		
		if (KontrolEt(thisForm))
		{
			if (isIE) 
			{
				document.all.expfield.outerHTML = '<font id=expfield class=kirmizi_uyari> Bilgileriniz yollanıyor.Lütfen bekleyiniz... </font>';
			}
			document.forms["order"].submit();
			return true;
		}
		else
		{
			submitcount = 0;
			return false;
		}
	}
	else
	{
		if (isIE) 
		{
			document.all.expfield.outerHTML = '<font id=expfield face=Verdana size=2 color=#800000> Bilgileriniz sisteme ulaşmak üzere. Lütfen bekleyiniz... </font>';
		}
	}
}

function imgBorderPoints(wid, hgt, colorNW, colorNE, colorSW, colorSE) 
{
	if (colorNE == null) colorNE = colorNW;
	if (colorSW == null) colorSW = colorNW;
	if (colorSE == null) colorSE = colorNW;

	var img = "<img width=\"1\" height=\"1\" border=\"0\" alt=\"\" src=\"/i/1pix.gif\">";
	//img = "";

	document.write(
		'<div style="position: absolute; left: 0px; top: 0px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorNW + '">' + img + '</div>' +
		'<div style="position: absolute; left: 0px; top: ' + (hgt - 1) + 'px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorSW + '">' + img + '</div>' +
		'<div style="position: absolute; left: ' + (wid - 1) + 'px; top: 0px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorNE + '">' + img + '</div>' +
		'<div style="position: absolute; left: ' + (wid - 1) + 'px; top: ' + (hgt - 1) + 'px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorSE + '">' + img + '</div>'
	);

	document.write(
		'<div style="position: absolute; left: 0px; top: 0px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorNW + '">' + img + '</div>' +
		'<div style="position: absolute; left: 0px; bottom: 0px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorSW + '">' + img + '</div>' +
		'<div style="position: absolute; right: 0px; top: 0px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorNE + '">' + img + '</div>' +
		'<div style="position: absolute; right: 0px; bottom: 0px; width: 1px; height: 1px; z-index: 100; background-color: ' + colorSE + '">' + img + '</div>'
	);
}

/* login functions */
function validateLogin() {
	var form = __getForm();
	
	var message = "";
	/*form.user.value = trim(form.user.value);
	form.password.value = trim(form.password.value);*/
	
	if (form.user.value == "") {
		message = message + "\n" + '* Kullanıcı Adı giriniz:';
	}

	if (form.password.value == "") {
		message = message + "\n" + '* Şifre giriniz:';
	}

	if (message !== '') {
		alert('Aşağıda belirtilen eksikleri tamamlayıp tekrar deneyin;\n' + message + '\n\n');
	} else {
		__doPostBack("login");
	}
}

function loginKeyPress(evt) {
	var keyValue;

	if (isNav)
		keyValue = evt.which;
	else
		keyValue = window.event.keyCode;

	if (keyValue == 13) {
		validateLogin();
	}
}

function RpopUp( URL, W, H, L, T ) {
	var id = 1;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + W + ",height=" + H + ",left="+L+",top="+T+"');");
}

function PopUpFixed( URL, name, W, H, L, T ) {
	var wnd = window.open(URL, name, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + W + ',height=' + H + ',left='+L+',top='+T);
	wnd.focus();
}

function strICompare(str1, str2) {
	if (str1.toLocaleUpperCase) {
		str1 = str1.toLocaleUpperCase();
		str2 = str2.toLocaleUpperCase();
	} else {
		str1 = str1.toUpperCase();
		str2 = str2.toUpperCase();
	}
		
	if (str1 < str2)
		return -1;
	else if (str1 > str2)
		return 1;
	else
		return 0;
}
function loadXMLDoc(object,url)
{
       
        try
        {
                req = new ActiveXObject("Msxml2.XMLHTTP");
        }

        catch(e)
        {
                try
                {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                }

                catch(oc) { req = null; }
        }

     
        if (req == null && typeof XMLHttpRequest != "undefined")
        {
                req = new XMLHttpRequest();

        }

       
        if (req != null)
        {
                req.onreadystatechange = eval(object);
				req.open("GET", url, true);
                req.send(null);
        }
}
function hediye_items(evt)
{
        if (req.readyState == 4)
        {
                if (req.status == 200)
				{
					document.getElementById("image_container").style.display="block";
					document.getElementById("image_container").innerHTML=req.responseText;
				}
		}
}
function checkAmount(maxAmount)
{
	checked=0;
	globalMaxAmount=maxAmount;
	numberOfHediye=document.getElementById("hediyeAmount").value;
	for(i=0;i<numberOfHediye;i++)
	{
		if(document.getElementById("hediye_items_sec"+i).checked==true )
			checked++;
	}
}

///////////////////////sms icin
var isNN = document.layers ? true : false;
var isIE = document.all ? true : false;


function goster(mesaj,evt){
	var d = document.getElementById("popdiv");
	d.innerHTML = mesaj;
 	scr=document.body.scrollTop;
	Y=20+scr+(isNN ? evt.pageY : evt.clientY);
	X=(isNN ? evt.pageX : evt.clientX);

	if(X+150>screen.availWidth){
		X=screen.availWidth-150;
	}
	locateDiv(d,X,Y);
	d.style.display =  "block";
}
function locateDiv(obj,X,Y){
	if(isIE){
		obj.style.pixelTop=Y;
		obj.style.pixelLeft=X;
	}
	else{
		obj.style.top=Y+'px';
		obj.style.left=X+'px';
	}

}
function gizle(){
	var d = document.getElementById("popdiv");
	d.style.display =  "none";
}
function popdetaygoster(id){
	ajax("POST",'sms.php',"smsid=" + id , "popgoster",false);
}
function popgoster(){
	var d = document.getElementById("popdetaydiv");
	d.innerHTML = responseText;
	//return overlib(responseText,STICKY);
	d.style.display = "block";
}
function popdetaygizle(){
	var d = document.getElementById("popdetaydiv");
	d.style.display =  "none";
	document.getElementById("ucretlendirmediv").style.display = "none";	
}
function ucretleriGoster(id){
	if(id == 0) popdetaygizle();
	ajax("POST",'ucretlendirme.php',"smsid=" + id , "ucretleriGoster2",false);
}
function ucretleriGoster2(){
	var d = document.getElementById("ucretlendirmediv");
	d.innerHTML = responseText;	
	document.getElementById("ucretlendirmediv").style.display = "block";	
}