// JavaScript Document
var xmlhttpPreview
var xmlhttpLightBoxPreview
var xmlhttpOrderPreview
var xmlhttpOrderDetailPreview
var xmlhttpGuidePreview
var xmlhttpLightboxToBasket
// -------------------------------------------------------------------------
// Gestione del Preview
// -------------------------------------------------------------------------

function getPreview(MyId)
{
xmlhttpPreview=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttpPreview=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttpPreview=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttpPreview!=null)
  {
  document.body.style.cursor = "wait";
  oldId = ReadCookie("BasketSelectedRow");
  document.getElementById('BasketRow' + oldId).className = "riga";
  document.getElementById('BasketRow' + MyId).className = "rigaselected";
  oldId = SetCookie("BasketSelectedRow", MyId);
  xmlhttpPreview.onreadystatechange = state_Change_Preview;
  xmlhttpPreview.open("GET",'/services/generate-preview.asp?ID=' + MyId  + '&rand=' + escape(Math.random()),true);
  xmlhttpPreview.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change_Preview()
{
// if xmlhttpPreview shows "loaded"
if (xmlhttpPreview.readyState==4)
  {
  // if "OK"
  if (xmlhttpPreview.status==200)
    {
    document.getElementById('BasketPreviewBox').innerHTML=xmlhttpPreview.responseText
    document.body.style.cursor = "default";
    }
  else
    {
    alert("Problem retrieving data")
    }
  }
}



function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
	var now = new Date();
	then = now.getTime() + (d * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
} // function SetCookie()

function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
	var cookiename = n+ '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
return unescape(cookiecontent);
} // function ReadCookie()



function getOrderPreview(MyId)
{
xmlhttpOrderPreview=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttpOrderPreview=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttpOrderPreview=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttpOrderPreview!=null)
  {
  document.body.style.cursor = "wait";
  oldId = ReadCookie("OrdersSelectedRow");
  document.getElementById('OrdersRow' + oldId).className = "riga";
  document.getElementById('OrdersRow' + MyId).className = "rigaselected";
	oldId = SetCookie("OrdersSelectedRow", MyId)
  xmlhttpOrderPreview.onreadystatechange=state_Change_OrderPreview
  xmlhttpOrderPreview.open("GET",'/services/generate-OrdersPreview.asp?ID=' + MyId  + '&rand=' + escape(Math.random()),true)
  xmlhttpOrderPreview.send(null)
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change_OrderPreview()
{
// if xmlhttpOrderPreview shows "loaded"
if (xmlhttpOrderPreview.readyState==4)
  {
  // if "OK"
  if (xmlhttpOrderPreview.status==200)
    {
    document.getElementById('Panel-2-2-BC').innerHTML=xmlhttpOrderPreview.responseText
    document.body.style.cursor = "default";
    }
  else
    {
    alert("Problem retrieving data")
    }
  }
}


//---------------------------------------------


function getOrderDetailPreview(MyId)
{
xmlhttpOrderDetailPreview=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttpOrderDetailPreview=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttpOrderDetailPreview=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttpOrderDetailPreview!=null)
  {
  document.body.style.cursor = "wait";
  oldId = ReadCookie("OrdersDetailSelectedRow");
  document.getElementById('DetailRow' + oldId).className = "DetailRow";
  document.getElementById('DetailRow' + MyId).className = "DetailRowSelected";
	oldId = SetCookie("OrdersDetailSelectedRow", MyId)
  xmlhttpOrderDetailPreview.onreadystatechange=state_Change_OrderDetailPreview
  xmlhttpOrderDetailPreview.open("GET",'/services/generate-OrderDetailPreview.asp?ID=' + MyId  + '&rand=' + escape(Math.random()),true)
  xmlhttpOrderDetailPreview.send(null)
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change_OrderDetailPreview()
{
// if xmlhttpOrderDetailPreview shows "loaded"
if (xmlhttpOrderDetailPreview.readyState==4)
  {
  // if "OK"
  if (xmlhttpOrderDetailPreview.status==200)
    {
    document.getElementById('OrderDetailPreviewBox').innerHTML=xmlhttpOrderDetailPreview.responseText
    document.body.style.cursor = "default";
    }
  else
    {
    alert("Problem retrieving data")
    }
  }
}




// -------------------------------------------------------------------------
// Gestione della visualizzazione della guida....
// -------------------------------------------------------------------------

function getGuidePreview(MyFile)
{
xmlhttpGuidePreview=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttpGuidePreview=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttpGuidePreview=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttpGuidePreview!=null)
  {
  xmlhttpGuidePreview.onreadystatechange=state_Change_Guide_Preview
  xmlhttpGuidePreview.open("GET",MyFile  + '&rand=' + escape(Math.random()),true)
  xmlhttpGuidePreview.send(null)
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change_Guide_Preview()
{
// if xmlhttpGuidePreview shows "loaded"
if (xmlhttpGuidePreview.readyState==4)
  {
  // if "OK"
  if (xmlhttpGuidePreview.status==200)
    {
    document.getElementById('Panel-Guide-Bottom').innerHTML=xmlhttpGuidePreview.responseText
    document.body.style.cursor = "default";
    }
  else
    {
    alert("Problem retrieving data")
    }
  }
}


// -------------------------------------------------------------------------
// Gestione del Preview
// -------------------------------------------------------------------------

function getLightBoxPreview(MyId)
{
xmlhttpLightBoxPreview=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttpLightBoxPreview=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttpLightBoxPreview=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttpLightBoxPreview!=null)
  {
  document.body.style.cursor = "wait";
  oldId = ReadCookie("LightBoxSelectedRow");
  document.getElementById('LightBoxRow' + oldId).className = "riga";
  document.getElementById('LightBoxRow' + MyId).className = "rigaselected";
  oldId = SetCookie("LightBoxSelectedRow", MyId);
  xmlhttpLightBoxPreview.onreadystatechange = state_Change_LightBoxPreview;
  xmlhttpLightBoxPreview.open("GET",'/services/generate-LightBoxPreview.asp?ID=' + MyId  + '&rand=' + escape(Math.random()),true);
  xmlhttpLightBoxPreview.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change_LightBoxPreview()
{
// if xmlhttpLightBoxPreview shows "loaded"
if (xmlhttpLightBoxPreview.readyState==4)
  {
  // if "OK"
  if (xmlhttpLightBoxPreview.status==200)
    {
    document.getElementById('LightBoxPreviewBox').innerHTML=xmlhttpLightBoxPreview.responseText
    document.body.style.cursor = "default";
    }
  else
    {
    alert("Problem retrieving data")
    }
  }
}


function LightBoxToBasket(MyId)
{
xmlhttpLightboxToBasket=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttpLightboxToBasket=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttpLightboxToBasket=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttpLightboxToBasket!=null)
  {
  oldId = SetCookie("AddedRow", MyId);
  xmlhttpLightboxToBasket.onreadystatechange=state_Change_LightBoxToBasket;
  xmlhttpLightboxToBasket.open("GET",'/services/LightBoxToBasket.asp?ID=' + MyId  + '&rand=' + escape(Math.random()),true);
  xmlhttpLightboxToBasket.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change_LightBoxToBasket()
{
// if xmlhttpLightBoxToBasket shows "loaded"
if (xmlhttpLightboxToBasket.readyState==4)
  {
  // if "OK"
  if (xmlhttpLightboxToBasket.status==200)
    {
    oldId = ReadCookie("AddedRow");
	document.getElementById("LightBoxCol" + oldId).innerHTML = "is in your basket"
    document.body.style.cursor = "default";
    }
  else
    {
    alert("Problem retrieving data")
    }
  }
}

function to_blinkBasket(MyLingua)
{
  document.getElementById("btnRefreshBasket").src = "css/images/myaccount/blinkingYourBasket_" + MyLingua + ".gif";
}




