var xmlHttp;
var rootpath;

rootpath = document.location.href.substring( 0,document.location.href.indexOf('/',8)+1 ) + '_ajax/'; 
 
//--------------------------
function userComment(c,p)
{
	var xc = c.replace(/\n/g,'|||||');
    var urlUserComment = rootpath + 'comment.asp?c=' + xc + '&p=' + p + '&nocache=' + Math.floor(Math.random()*16000);;
   	ReqUserComment=GetXmlHttpObject(scUserComment);
    ReqUserComment.open("GET", urlUserComment, true)
    ReqUserComment.send(null)
}
function scUserComment()
{
    if (ReqUserComment.readyState==4 || ReqUserComment.readyState=="complete")
    {
        document.getElementById("comment_area").style.display='none';
        document.getElementById("comment_status").style.display='block';
        document.getElementById("comment_status").innerHTML = ReqUserComment.responseText;
    }
}

 
//--------------------------
function DoOGContact(n,e,pa,pn,m)
{
	var xm = m.replace(/\n/g,'|||||');
    var urlOGContact = rootpath + 'contact.asp?n=' + n + '&e=' + e + '&p=' + pa + '.' + pn + '&m=' + xm + '&nocache=' + Math.floor(Math.random()*16000);;
   	ReqOGContact=GetXmlHttpObject(scOGContact);
    ReqOGContact.open("GET", urlOGContact, true)
    ReqOGContact.send(null)
}
function scOGContact()
{
    if (ReqOGContact.readyState==4 || ReqOGContact.readyState=="complete")
    {
        document.getElementById("form_button").style.display = 'none';
        document.getElementById("form_status").style.display = 'none';
        document.getElementById("form_result").style.display = '';
        document.getElementById("form_result").innerHTML = ReqOGContact.responseText;
    }
}

//--------------------------


function userVote(v,p)
{
    var urlUserVote = rootpath + 'vote.asp?v=' + v + '&p=' + p + '&nocache=' + Math.floor(Math.random()*16000);;
   	ReqUserVote=GetXmlHttpObject(scUserVote);
    ReqUserVote.open("GET", urlUserVote, true)
    ReqUserVote.send(null)
}
function scUserVote()
{
    if (ReqUserVote.readyState==4 || ReqUserVote.readyState=="complete")
    {
        document.getElementById("vote_status").innerHTML = ReqUserVote.responseText;
        document.getElementById("RankTotalDiv").innerHTML = document.getElementById("AJAXTheRankTotalDiv").value;
    }
}


//--------------------------


function setgetParaPuan(p)
{
    var urlParaPuan = rootpath + 'parapuan.asp?p=' + p + '&nocache=' + Math.floor(Math.random()*16000);;
   	ReqParaPuan=GetXmlHttpObject(scParaPuan);
    ReqParaPuan.open("GET", urlParaPuan, true)
    ReqParaPuan.send(null)
}
function scParaPuan()
{
    if (ReqParaPuan.readyState==4 || ReqParaPuan.readyState=="complete")
    {
        document.getElementById('ParaPuanInfoDiv').innerHTML = ReqParaPuan.responseText;
        document.getElementById('CurrentPoints').innerHTML = document.getElementById('AUsablePoints').value + ' TL';
        document.getElementById('UsedPoints').innerHTML = document.getElementById('AUsePoints').value + ' TL';
        document.getElementById('AfterUsedPoints').innerHTML = document.getElementById('AAfterPoints').value + ' TL';
        
        document.getElementById('Instalment_0_1').innerHTML = document.getElementById('Instalment0_1').value + '';
        document.getElementById('Instalment_3_0').innerHTML = document.getElementById('Instalment3_0').value + '';
        document.getElementById('Instalment_3_1').innerHTML = document.getElementById('Instalment3_1').value + '';
        document.getElementById('Instalment_6_0').innerHTML = document.getElementById('Instalment6_0').value + '';
        document.getElementById('Instalment_6_1').innerHTML = document.getElementById('Instalment6_1').value + '';
        document.getElementById('Instalment_9_0').innerHTML = document.getElementById('Instalment9_0').value + '';
        document.getElementById('Instalment_9_1').innerHTML = document.getElementById('Instalment9_1').value + '';
        document.getElementById('Instalment_12_0').innerHTML = document.getElementById('Instalment12_0').value + '';
        document.getElementById('Instalment_12_1').innerHTML = document.getElementById('Instalment12_1').value + '';
        
        document.getElementById('BeforeCardPoints').innerHTML = 'ParaPuan öncesi siparş tutarı ' + document.getElementById('BeforeCardPointsValue').value;
        document.getElementById('UseCardPoints').innerHTML = 'Kullanılan ParaPuan: ' + document.getElementById('AUsePoints').value + ' TL';
        document.getElementById('AfterCardPoints').innerHTML = 'Ödeme tutarı ' + document.getElementById('Instalment0_1').value + '';
        
        if (document.getElementById('AUsePoints').value == '0' || document.getElementById('AUsePoints').value == '0.00'){
        	document.getElementById('ParaPuanSummary').style.display = 'none';
        }else{
        	document.getElementById('ParaPuanSummary').style.display = '';
        }

		document.getElementById('ShowPoint').style.display='';
		document.getElementById('ChangePoint').style.display='none';
		document.getElementById('ChangeCardBtn1').style.display='';
		document.getElementById('ChangeCardBtn2').style.display='none';
				
    }
}




//--------------------------


function ProcessOrder(Param0, Param1, Param2, Param3, Param4, Param5, Param6, Param7)
{
    var urlProcessOrder = rootpath + 'processorder.asp?Param0=' + Param0 + '&Param1=' + Param1 + '&Param2=' + Param2 + '&Param3=' + Param3 + '&Param4=' + Param4 + '&Param5=' + Param5 + '&Param6=' + Param6 + '&Param7=' + Param7 + '&nocache=' + Math.floor(Math.random()*16000);;
   	ReqProcessOrder=GetXmlHttpObject(scProcessOrder);
    ReqProcessOrder.open("GET", urlProcessOrder, true)
    ReqProcessOrder.send(null)
}
function scProcessOrder()
{
    if (ReqProcessOrder.readyState==4 || ReqProcessOrder.readyState=="complete")
    {
    	var ResponseStr = ReqProcessOrder.responseText
    	if (ResponseStr == 'SessionTimeout'){top.document.location.href = '/goodbye.asp';}
    	else if (ResponseStr == 'WrongArgs' || ResponseStr == 'OrderNotFound'){
    		alert('Lütfen bilgilerinizi kontrol ediniz.');
			document.getElementById('buttonrow').style.display='';
			document.getElementById('pleasewaitrow').style.display='none';
			document.getElementById('SendOrder').disabled = false;
			$("#xCloseButton").trigger('click');
			document.getElementById('processformdiv').style.display='none';
    	}else{
			$("#xCloseButton").trigger('click');
			document.getElementById('processformdiv').style.display='none';
			top.document.location.href = '/basket-result.asp';
    	}
    }
}













 
 
function GetXmlHttpObject(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest();
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp;

    }
} 



