﻿var xmlHttp
function addRate(ContentID,points)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ajax.asp?ajaxaction=addrate";
url=url+"&ContentID="+ContentID;
url=url+"&Rating="+points;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=function(){
     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
            document.getElementById("vote").innerHTML=xmlHttp.responseText;}
            };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function addComment(ContentTypeID,ParentContentID,CatID,Comments)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ajax.asp?ajaxaction=addcomment";
url=url+"&LongDesc="+Comments;
url=url+"&ContentTypeID="+ContentTypeID;
url=url+"&ParentContentID="+ParentContentID;
url=url+"&CatID="+CatID;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=function(){
     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
            document.getElementById("comments").style.display = 'none';
document.getElementById("quote_on").style.display = 'none';
document.getElementById("quote_off").style.display = 'block';
document.getElementById("comments_return").style.display = 'block';
document.getElementById("comments_return").innerHTML=xmlHttp.responseText;
        }
     };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function subscribe(email,mailing_list)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ajax.asp?ajaxaction=subscribe";
url=url+"&email="+email;
url=url+"&mailing_list="+mailing_list;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=function(){
     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
            document.getElementById("subscribe_result").innerHTML=xmlHttp.responseText;}
            };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function calculateshipcost(method, weight) {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "ajax.asp?ajaxaction=calculateshipcost";
    url = url + "&method=" + method;
    url = url + "&weight=" + weight;
    url = url + "&sid=" + Math.random();
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {

            if (xmlHttp.responseText == "Call") {
                document.getElementById("shipresult").style.display = 'block';
                document.getElementById("shipresult").innerHTML = "Call";
                document.getElementById("ShippingCost").value = 0.00;
                document.getElementById("shipcostdiv").style.display = 'none';
                document.getElementById("ordertotaldiv").innerHTML = document.getElementById("NetTotal").value + "&nbsp;€";



            } else {
                
                document.getElementById("shipresult").style.display = 'none';
                document.getElementById("shipcostdiv").style.display = 'block';
                document.getElementById("ShippingCost").value = parseFloat((xmlHttp.responseText).replace(",", ".")).toFixed(2);
                document.getElementById("OrderTotal").value = (parseFloat((document.getElementById("NetTotal").value).replace(",", ".")) + parseFloat((xmlHttp.responseText).replace(",", "."))).toFixed(2);
                document.getElementById("ordertotaldiv").innerHTML = document.getElementById("OrderTotal").value + "&nbsp;€";





            }
        }
    };
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function deleteproduct(id) {
    alert("Your browser does not support AJAX!");
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "ajax.asp?ajaxaction=deleteproduct";
    url = url + "&sid=" + Math.random();
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
            document.getElementById("minicart_div").value = xmlHttp.responseText;
        }
    };
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("comments").style.display = 'none';
document.getElementById("quote_on").style.display = 'none';
document.getElementById("quote_off").style.display = 'block';
document.getElementById("comments_return").style.display = 'block';
document.getElementById("comments_return").innerHTML=xmlHttp.responseText;
}
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}



