 function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
} 

/*vygenerovani odkazu na XML feed pro partnery*/
function CreateXMLFeedLink ()
{
  var sQs;
  sQs="";

  for (i=0;obj=document.getElementsByName("ncategory")[i];i++)
    {
       if (obj.checked) sQs=sQs+obj.value+",";
    }
    
  if (sQs>"") sQs="?cats="+sQs;
  
  document.getElementById("datafeedlink").innerHTML="<a href='/items.xml.asp"+sQs+"' target='_blank'>http://www.water-bongs-glass-pipes.com/items.xml.asp"+sQs+"</a>";
}

//shop.js
// KOMPATIBILITA

var Br = new BrCheck()

function BrCheck()
{
	this.VER	= navigator.appVersion;
	this.AGENT	= navigator.userAgent;
	this.DOM	= document.getElementById ? true:false;

	this.OP5	= this.AGENT.indexOf("Opera 5")>-1							?true:false;
	this.OP6	= this.AGENT.indexOf("Opera 6")>-1							?true:false;
	this.OP7	= this.AGENT.indexOf("Opera 7")>-1							?true:false;
	this.OP		= (this.OP5 || this.OP6 || this.OP7);

	this.IE4	= (document.all && !this.DOM && !this.OP)					?true:false;
	this.IE5	= (this.VER.indexOf("MSIE 5")>-1 && this.DOM && !this.OP)	?true:false; 
	this.IE6	= (this.VER.indexOf("MSIE 6")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE7	= (this.VER.indexOf("MSIE 7")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE8	= (this.VER.indexOf("MSIE 8")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE		= (this.IE4 || this.IE5 || this.IE6);

	this.NS4	= (document.layers && !this.DOM)							?true:false;
	this.NS7	= (this.DOM && parseInt(this.VER) >= 5 && this.AGENT.lastIndexOf('Netscape')<this.AGENT.lastIndexOf('7'))?true:false;
	this.NS6	= (this.DOM && parseInt(this.VER) >= 5 && !this.NS7)		?true:false;
	this.NS		= (this.NS4 || this.NS6 || this.NS7);

	return this;
}

function getE(objectID) {
	if (Br.IE)
		return document.all[objectID]?document.all[objectID]: document.getElementsByName(objectID)[0];
	else
	 {
  	return document.getElementById(objectID)?document.getElementById(objectID):document.getElementsByName(objectID)[0];
	 }
}

function getF(formName) {
	return document.forms[formName];
}

function getFEx(formName, oDocument) {
	return oDocument.forms[formName];
}

function getEEx(objectID, oDocument) {
	return oDocument.getElementById(objectID);
}


function ControlNumber() {
     if (((event.keyCode <48) || (event.keyCode >57)) && (event.keyCode!=13)) event.returnValue = false;
}
function ControlPhone() {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32)  && (event.keyCode!=40) && (event.keyCode!=41) && (event.keyCode!=43))
		event.returnValue = false;
}
function ControlPSC() {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32))
		event.returnValue = false;
}
//----------info okno-------------------------------------------------------
function InfoWindow(strAddress) {
       showModalDialog(strAddress,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450pt;dialogHeight=320pt");
}

function ControlDataOrder3(bCheckAddress, sAddress)
{
	//if (!getRadioChecked('PaymentType')){alert("Choose payment type, please.");return false;}
	
	
	if (bCheckAddress == true)
	{
	    if (getF('OrderForm').sEmail.value == "")				{alert("Fill your email, please.");getF('OrderForm').sEmail.focus();return false;}
	    if (getF('OrderForm').sEmail2.value == "")				{alert("Fill email verification field, please.");getF('OrderForm').sEmail2.focus();return false;}
	    if (getF('OrderForm').sEmail.value > "" && getF('OrderForm').sEmail2.value > "" && getF('OrderForm').sEmail2.value.toLowerCase() != getF('OrderForm').sEmail.value.toLowerCase())	 {alert("'Email' and 'Email Verification' must be the same, please repair it.");getF('OrderForm').sEmail.focus();return false;}

	    if (getF('OrderForm').DeliveryFirstName.value == "")	{alert("Fill your first name, please.");getF('OrderForm').DeliveryFirstName.focus();return false;}
	    if (getF('OrderForm').DeliveryLastName.value == "")		{alert("Fill your last name, please.");getF('OrderForm').DeliveryLastName.focus();return false;}
	    if (getF('OrderForm').DeliveryStreet.value == "")		{alert("Fill your street name, please.");getF('OrderForm').DeliveryStreet.focus();return false;}
	    //if (getF('OrderForm').HouseNr.value == "")		{alert("Fill your house number, please.");getF('OrderForm').HouseNr.focus();return false;}
	    if (getF('OrderForm').DeliveryCity.value == "")			{alert("Fil your city, please.");getF('OrderForm').DeliveryCity.focus();return false;}
	    if (getF('OrderForm').DeliveryZipCode.value == "")		{alert("Fill your zip code, please.");getF('OrderForm').DeliveryZipCode.focus();return false;}
	    //if (getF('OrderForm').Phone.value == "")				{alert("Fill your phone, please.");getF('OrderForm').Phone.focus();return false;}
	    if (getF('OrderForm').sCountry.value == "")				{alert("Choose your country, please.");getF('OrderForm').sCountry.focus();return false;}
	    if (getF('OrderForm').sStateElse.value == "" && getF('OrderForm').sCountry.value == ", * UNITED STATES")      {alert("Fill your state please.");getF('OrderForm').sStateElse.focus();return false;}
	    if (getF('OrderForm').sStateElse.value == "" && getF('OrderForm').sCountry.value == ", * CANADA")      {alert("Fill your state or province please.");getF('OrderForm').sStateElse.focus();return false;}	   
	   
//       if (getF('OrderForm').sCountry.value == ", * UNITED STATES" && getF('OrderForm').sStateUSA)
//         {          
//          if (getF('OrderForm').sStateUSA.value == "") {alert("Choose your state, please.");getF('OrderForm').sStateUSA.focus();return false;}
//         }
//       
//      if (getF('OrderForm').sCountry.value == ", * CANADA" && getF('OrderForm').sProvinceCA)
//         {          
//          if (getF('OrderForm').sProvinceCA.value == "") {alert("Choose your state or province, please.");getF('OrderForm').sProvinceCA.focus();return false;}
//         }
        
	  //  if (EmailControl(getF('OrderForm').sEmail.value)==false) {getF('OrderForm').sEmail.focus();return false;}

		//kontrola, esli si vybral typ karty
// 		if (getF('OrderForm').PaymentType)
// 		{
//   
//   		if (getF('OrderForm').PaymentType.value == '36')
//   		{
//   			getE('OrderForm').action = 'https://' + sAddress + '/order.asp';
//   		}
//   		else
//   		{
//   			getE('OrderForm').action = 'http://' + sAddress + '/order.asp';
//   		}
// 		
// 		}
  
    var sGiftCode
    
    for (x=0;document.getElementsByName('gift')[x];x++)
    {
     // alert (document.getElementsByName('gift')[x].checked)
      if (document.getElementsByName('gift')[x].checked)
        {sGiftCode=document.getElementsByName('gift')[x].value}
    }
   // alert (sGiftCode);

	  if (getF('OrderForm').control) {getF('OrderForm').control.value='dFsew23XDPdsR';}
    return true;
	  
	}
	return true;
}


function EmailControl(f){
	if ((f=='' || f=='Váš@email.cz') ||(f.indexOf('@') < 1 || f.indexOf('@') != f.lastIndexOf('@') || f.lastIndexOf('.') < f.lastIndexOf('@')+2  || f.lastIndexOf('.') > (f.length-3) || f.lastIndexOf('.') < (f.length-4))){
		alert('Wrong email format - check it.');
		return false;
		}
	return true;
}

function wndTst()
{
    var wndObj = window.open("/testWnd.asp", "myWnd", "");
    if (wndObj == null)
    {
        getE("wndTstResult").style.display = "";
        return false
    }
    else
    {
        getE("wndTstResult").style.display = "none";
        return true
    }
}

String.prototype.trim = function()
{    
     return this.replace(/(^\s*)|(\s*$)/g, "");
}

function controlNumNumberNew(str){
    var s=str.trim();    
    if(s.length <1){    
        alert("Please, enter min. 1 character!");
        return false
    }else{    
        return true;
    }
}

function EmailControlNew(f){
	if (f.replace(/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/,"")=="") {
		return true
	} else {
	    alert("Wrong e-mail format!");
		return false;
	}
}

function ControlDataRegistration(bCheckAddress, bCheckLogin)
{
	if (bCheckAddress == true)
	{
	    if (getF('OrderForm').DeliveryFirstName.value == "")    {alert("Fill your first name, please.");getF('OrderForm').DeliveryFirstName.focus();return false;}
	    if (getF('OrderForm').DeliveryLastName.value == "")   {alert("Fill your last name, please.");getF('OrderForm').DeliveryLastName.focus();return false;}
	    if (getF('OrderForm').DeliveryStreet.value == "")            {alert("Fill your address, please.");getF('OrderForm').DeliveryStreet.focus();return false;}
	    if (getF('OrderForm').DeliveryCity.value == "")                {alert("Fil your city, please.");getF('OrderForm').DeliveryCity.focus();return false;}
	    if (getF('OrderForm').DeliveryZipCode.value == "")       {alert("Fill your zip code, please.");getF('OrderForm').DeliveryZipCode.focus();return false;}
	    if (getF('OrderForm').sEmail.value == "")                          {alert("Fill your email, please.");getF('OrderForm').sEmail.focus();return false;}
	    if (getF('OrderForm').Phone.value == "") {alert("Fill your phone, please.");getF('OrderForm').Phone.focus();return false;}
	    if (getF('OrderForm').sCountry.value == "") {alert("Choose your country, please.");getF('OrderForm').sCountry.focus();return false;}
	    if (getF('OrderForm').sCountry.value == ", United States" && getF('OrderForm').sStateUSA.value == "") {alert("Choose your state, please.");getF('OrderForm').sStateUSA.focus();return false;}
	    if (EmailControlNew(getF('OrderForm').sEmail.value)==false) {getF('OrderForm').sEmail.focus();return false;}
	}

	if (bCheckLogin == true)
	{
	    if (getF('OrderForm').sUsername.value == "")    {alert("Fill your username, please.");getF('OrderForm').sUsername.focus();return false;}
	    if (getF('OrderForm').sPassword.value == "")    {alert("Fill your password, please.");getF('OrderForm').sPassword.focus();return false;}
	}
	getF('OrderForm').submit();
	return true;
}


function generatebanner(idaff)
{
  var scat, sbannercode; 
  scat='';sbannercode='';
  for(i=0;i<document.getElementsByName('ncategory').length;i++)
  {
  if (document.getElementsByName('ncategory')[i].checked==true)
    {
    scat=scat+document.getElementsByName('ncategory')[i].value+',';
    }
  }
  sbannercode='<link rel="stylesheet" type="text/css" media="screen" href="/ascript/style.css" />\n<div id="excellentpipes_affiliate_banner" class="excellent_banner">Loading...</div>\n</div>\n<script type="text/javascript">\nexcellentpipes_getImages(\''+document.getElementById('orientation').value+'\','+document.getElementById('noprods').value+',\''+scat+'\','+idaff+');\n</script>\n';
  
  excellentpipes_getImages(document.getElementById('orientation').value,document.getElementById('noprods').value, scat, idaff);
 
  document.getElementById('bannercode').innerHTML=sbannercode;
}

function fn_cust_recount(osource,svalue,oresult,nmaxlength,opricesum,oprice,nletterprice,nbaseprice,scurrency)
{
  var s, n, nprice, npricesum
  
  s=svalue.replace(/[\., ']/g,"");
  
  oresult.innerHTML=(nmaxlength-s.length).toString()+'x';
  n=parseInt(s.length);
  if (n>nmaxlength) {n=nmaxlength;osource.value=svalue.substring(0,svalue.length-1);oresult.innerHTML='0x';}
  oprice.innerHTML=scurrency+(nletterprice*n).toFixed(2).toString();
  opricesum.innerHTML=scurrency+(nbaseprice+(nletterprice*n)).toFixed(2).toString();
  
  fn_dtShowFree();
}

function fn_cust_reset(ovalue,oletters,osumprice,oprice,nprice,scurrency,nmaxlength)
{
ovalue.value='';
oletters.innerHTML=nmaxlength.toString()+'x';
osumprice.innerHTML=scurrency+nprice.toString();
oprice.innerHTML=scurrency+'0';

fn_dtShowFree();
}

function fn_cust_show()
{
  var obj
  if (obj=document.getElementById('dt_customize')) {obj.className='Customize';} 

}

function fn_cust_hide()
{
  var obj
  if (obj=document.getElementById('dt_customize')) {obj.className='Customize nodis';} 
}

var fn_show_teritories_teritory

function fn_show_teritories(svalue)
{
  var oobj
  
  if(fn_show_teritories_teritory) {fn_show_teritories_teritory.style.display='none';}
  
  if (svalue==', * CANADA') oobj=document.getElementById('canada_provinces');
    
  if (svalue==', * UNITED STATES') oobj=document.getElementById('usa_states');
  
  if (document.getElementById('else_states'))
  {
  if ((svalue==', * UNITED STATES' || svalue==', * CANADA')) 
  {document.getElementById('else_states').style.display='none';}
  else
  {document.getElementById('else_states').style.display='';}
  }
  
  if (oobj)
  {  
  oobj.style.display='';
  fn_show_teritories_teritory=oobj;
  }

}

function fn_check_delivery()
{

  if (document.OrderForm.sCountry.value != ', * UNITED STATES' && document.OrderForm.sCountry.value != ', * CANADA')
    {
    document.OrderForm.DeliveryType[0].checked='checked';document.OrderForm.DeliveryType[1].disabled='disabled';
    }
  else
    {
    document.OrderForm.DeliveryType[1].disabled='';
    }
}

function setFormActionType(objPaymentType, sAddress)
{
	if (objPaymentType.value == 36)
	{
		getE('OrderForm').action = 'https://' + sAddress + '/order.asp';
	}
	else
	{
		getE('OrderForm').action = 'http://' + sAddress + '/order.asp';
	}
}
function setFormActionType2(objPaymentType, sAddress)
{
	if (objPaymentType.value == 36)
	{
		getE('OrderForm').action = 'https://' + sAddress + '/order.asp';
		getE('showErsteCards').style.display = "";
	}
	else
	{
		getE('OrderForm').action = 'http://' + sAddress + '/order.asp';
		getE('showErsteCards').style.display = "none";
	}
}

function fn_show_gift(giftid)
{
  var ohide, oshow, svalue
  
  for (x=0;document.getElementsByName('giftimages')[x];x++)
  {
  document.getElementById(document.getElementsByName('giftimages')[x].value).style.display='none';
  }
  
  oshow=document.getElementById(giftid);
  oshow.style.display='';
}

function fn_show_selected_gift(giftid)
{
  document.getElementById(giftid).style.display='none';
  
//   for (x=0;document.getElementsByName('giftimages')[x];x++)
//   {
//   alert(document.getElementsByName('giftimages')[x]);
//   document.getElementsByName('giftimages')[x].style.display='none';
//   }
  var p
  p=0;
  for (x=0;document.getElementsByName('gift')[x];x++)
  {
    if (document.getElementsByName('gift')[x].checked)
      {document.getElementById('gift_img_'+document.getElementsByName('gift')[x].value).style.display='';p=1;}
  }
  
 
  if (p==0) document.getElementById('gift_img_0000D').style.display='';
  
}


//xmenu.js
function fn_chColor(oform)
{
octype=oform.sCustomType; 
for(oradio in octype)
  {
  
  alert(octype[oradio].checked);
      if(octype[oradio].checked && octype[oradio].nextSibling)
      {
      octype[oradio].nextSibling.className=octype[oradio].id;
      } 
      else if (octype[oradio].nextSibling) 
      {
      octype[oradio].nextSibling.className='g'+octype[oradio].id;
      }
  }
}

// rotace velkeho banneru

function fn_rotate_big_banner(x)
{
 if (oBanner=getE("big_banner1"))
 {
 if (x==-450){x=0;}
 oBanner.style.backgroundPosition="0px "+x.toString()+"px";
 oBanner.className="BBanners ChangeB"+x.toString();
 otmr=window.setTimeout("fn_rotate_big_banner("+(x-150).toString()+");",4000);
 }  
}

// zjisteni stavu objednavku AJAX
function fn_checkorder(sorder, semail)
{
window.scrollTo(0,0);
  if (sorder!=getE("conm").defaultValue && semail!=getE("coem").defaultValue)
  {
    if(!getE('Shade')) 
      {
        oStatusW=document.createElement('div');
        oStatusW.id='Shade';
        oStatusW.className='Shade';
        oStatusW.onclick=function(){fn_hideStatus()};
        document.body.appendChild(oStatusW);
      }
      else
      {
       getE('Shade').style.display="block";
      }
      
      nHeight= fn_getBodyHeight();
      getE('Shade').style.height=nHeight.toString()+"px";
      
    if(!getE('OrderStatusWindow')) 
      {
        oStatusW=document.createElement('div');
        oStatusW.id='OrderStatusWindow';
        oStatusW.className='OrderStatusWindow';
        document.body.appendChild(oStatusW);
      }
    else
      {
       getE('OrderStatusWindow').style.display="block";
      }
  
  //alert(encodeURIComponent(sorder));
  
    fn_ajax_get("/_axah_orderstatus.asp?norder="+encodeURIComponent(sorder)+"&semail="+encodeURIComponent(semail),"OrderStatusWindow","fn_show_orderstatus","","")
  }
}

function fn_hideStatus()
{
  getE("Shade").style.display="none";getE("OrderStatusWindow").style.display="none";getE("OrderStatusWindow").innerHTML="";
}

/*###########################################################################################################################*/
function fn_show_orderstatus(sxml,sDestination,sForm)
{
   var txt, xx, i, er, nrow, nrowsonpage, npage
   var aTable = new Array();
   
 //  window_opener = window.dialogArguments;
  // alert(window_opener);
 
  //aTable.push("<table class=\"Top\" cellspacing=\"0\"><tr><th class=\"LTcr\"></th><td></td><th class=\"RTcr\"></th></tr></table>") 
  
  x=sxml.documentElement.getElementsByTagName("rowdata");
  
  if (x.length==0)
  {
  aTable.push("<table class=\"Order\">")
  aTable.push("<tr><td><h2>Order was not found</h2></td></tr>")
  aTable.push("<tr><td class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
  aTable.push("<tr><th style=\"height:40px;\">There is no order with the specified number and email</th></tr>");
  aTable.push("<tr><td class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
  aTable.push("<tr><td class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
  aTable.push("<tr><td><input type=\"button\" value=\"close\" class=\"Close\" onclick=\"fn_hideStatus();\" /></td></tr>")           
  aTable.push("</table>");  
  }
  else
  {  
  aTable.push("<table class=\"Order\">")
  aTable.push("<tr><td colspan=\"7\"><h2>Order was found</h2></td></tr>")
  aTable.push("<tr><td colspan=\"7\" class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
  aTable.push("<tr><th>order number</th><th>date placed</th><th>price</th><th>payment status</th><th>order status</th><th>delivery type</th><th>tracking number</th></tr>");
  aTable.push("<tr><td colspan=\"7\" class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
  aTable.push("<tr><td colspan=\"7\" class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
  
    for (i=0;i<x.length;i++)
      {
       aRow = new Array();
        for (ii=0;ii<x[i].childNodes.length;ii++)
          {
            aRow[x[i].childNodes[ii].tagName] = x[i].childNodes[ii].firstChild?x[i].childNodes[ii].firstChild.nodeValue:"&nbsp;";
          }
 
        switch (parseInt(aRow["nState"]))
          {  
            case 0: 
              sStatus="Sent - on the way to you";
              break;
            case 1: 
              sStatus="Saved - awaiting payment";
              break;
            case 3: 
              sStatus="Preparing for dispatch";
              break;
            case 4: 
              sStatus="Canceled";
              break;
            case 9: 
              sStatus="Refundation - canceled";
              break;
            default: sStatus="Unknown"; 
          }   

      txt="<tr>";
        
      txt+="<td>#"+aRow["pktblCommodityOrder"]+"</td>";
      txt+="<td>"+aRow["dDateOrder"]+"</td>";
      txt+="<td>"+(Math.round(aRow["nPrice"]*100)/100).toFixed(2).toString()+"</td>";
      txt+="<td>"+(aRow["nPaymentState"]==1?"Paid":"Not paid")+"</td>";
      txt+="<td>"+sStatus+"</td>";
      txt+="<td>"+aRow["sDeliveryType"]+"</td>";
      txt+="<td>"+aRow["nTrackingNo"]+"</td>";
      txt+="</tr>\n";
                  
      aTable.push(txt);
      }                           

    aTable.push("<tr><td colspan=\"7\" class=\"nopadding\" ><div class=\"hline nomargin\">&nbsp;</div></td></tr>")
    aTable.push("<tr><td colspan=\"7\"><input type=\"button\" value=\"close\" class=\"Close\" onclick=\"fn_hideStatus();\" /></td></tr>")           
    aTable.push("</table>");
    //aTable.push("<table class=\"Bottom\" cellspacing=\"0\"><tr><th class=\"LBcr\"></th><td></td><th class=\"RBcr\"></th></tr></table>")
     }
     
    getE(sDestination).innerHTML=aTable.join('\n');    
}

/*###########################################################################################################################*/
function fn_ajax_get(sUrl,sDestination,sOk,sError,sForm)
{  

if(document.getElementById(sDestination))
{
  document.getElementById(sDestination).style.position="relative";
  
  var loadingbox=document.createElement("div");
  loadingbox.style.position="absolute";
  loadingbox.style.height=document.getElementById(sDestination).offsetHeight;
  loadingbox.style.width="100%";
  loadingbox.style.top="0";
  loadingbox.style.left="0";
  loadingbox.innerHTML="&nbsp;";
  loadingbox.className="loading";
   
  document.getElementById(sDestination).appendChild(loadingbox);
 }

  var surlvalues = "";
  
  if (oForm=document.getElementsByName(sForm)[0])
  {           
  
  if (oForm.bLoading) {oForm.bLoading.value=Number(oForm.bLoading.value)+1;}
 // alert(oForm.name);
  
  surlvalues=fn_getFormData(sForm,"&");
  
  
  if (oForm.elements.length>0) {sUrl+=sUrl.indexOf("?")>-1?"&"+surlvalues:"?"+surlvalues;}
  //sForm=oForm.name;
 //window.open(sUrl);
  }
//alert(sUrl); 
//window.open(sUrl);
//alert(sUrl);
                                          
//document.getElementById(sDestination).innerHTML="Načítám data...";
  
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.open("GET", sUrl, true);
    theHttpRequest.onreadystatechange = function() {processAXAH(sOk,sError,sForm);};
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    theHttpRequest.send();
       
          function processAXAH(sOk,sError,sForm){
           if (theHttpRequest.readyState == 4) {     
               if (theHttpRequest.status == 200) {
               //alert(sForm);
                  var sxml=theHttpRequest.responseXML; 
                  window[sOk](sxml,sDestination,sForm);
                  //fn_alert(sxml.documentElement.getElementsByTagName("msave").length);
                  } else {
                 // box_loading(0);
                   alert('data not found');
               }
           }
        }        
}

/* Novinky na uvodni strance - ajax vezme novinky a pripravi prepinani - az do 10*/
function fn_WelcomepageNews()
{
  fn_ajax_get("/_axah_newitems.asp","NewsWindow","fn_NewsRotate","","")  
}

/*Rotace novinek na uvodni strance - mame zdrojove XML, pripravim boxy ktere budou rotovat...*/
function  fn_NewsRotate(sXml,sDestination,sForm)
{
  var txt, xx, i, er, nrow, nrowsonpage, npage
  var aTable = new Array();
  
  
  
  x=sXml.documentElement.getElementsByTagName("rowdata");

      for (i=0;i<x.length;i++)
      {
       aRow = new Array();
        for (ii=0;ii<x[i].childNodes.length;ii++)
          {
            aRow[x[i].childNodes[ii].tagName] = x[i].childNodes[ii].firstChild?x[i].childNodes[ii].firstChild.nodeValue:"&nbsp;";
          }
      
       aTable.push("<p><span class=\"Top\" >&nbsp;</span>")
       aTable.push("  <a href=\"/"+fn_getNiceURL(aRow["sName"])+"/d-" + aRow["pkTblCommodity"] + "/\">"+aRow["sName"]+"</a>")
       aTable.push("  <a class=\""+(aRow["bVertical"]=="1"?"hImg":"vImg")+"\" href=\"/"+fn_getNiceURL(aRow["sName"])+"/d-" + aRow["pkTblCommodity"] + "/\"><img src=\"/fotocache/small2"+(aRow["bVertical"]=="1"?"_h":"")+"/"+aRow["sImagePath"]+"\" alt=\""+aRow["sName"]+"\" /><span></span></a>")
       aTable.push("  <strong  class=\"Price\">"+aRow["sCurrency"]+(Math.round(aRow["nPrice"]*100)/100).toFixed(2).toString().replace(".",".<small>")+"</small></strong>")
       aTable.push("</p>")
       }
       
  getE(sDestination).innerHTML=aTable.join("");
  tTimer=window.setTimeout("fn_RotateNews(0,'"+sDestination+"')",3000); 
}

  function fn_RotateNews(nCounter,sDestination)
  {
   getE(sDestination).childNodes[nCounter].style.display='none';
    nCounter++;
    if (!getE(sDestination).childNodes[nCounter]) {for(i=0;i<nCounter;i++){getE(sDestination).childNodes[i].style.display='';};nCounter=0;} 
    tTimer=window.setTimeout("fn_RotateNews("+nCounter.toString()+",'"+sDestination+"')",3000);
  }
      



function fn_getBodyHeight()
{
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight)
    );
}

function stripHTML(sString){
var re = /(<([^>]+)>)/gi;  
return sString.replace(re, "")
}

function fn_getNiceURL(sString)
{
  sString=sString.toLowerCase();
  sString=sString.replace(" - ","-").replace(" ","-");
  sString=stripHTML(sString);
  return encodeURI(sString);
}


//#######################################################################################3
function fn_wpCountDown(nHour,nMin,nSec,sDestination) {
  
  nSec--;
  if (nSec == -01) {
      nSec = 59;
      nMin = nMin - 1; }

  if (nMin == -01) {
      nMin = 59;
      nHour = nHour - 1; }

  if (nHour == -01) {
      nHour = 23; 
      var d = new Date();
      getE(sDestination).innerHTML="<a href=\"/?dd="+encodeURI(d.getDate())+"\">Reload page for actual item!</a>";
      return;
      }
  else
  {
    getE(sDestination).innerHTML=(nHour/10).toFixed(1).toString().replace(".","")+"h "+(nMin/10).toFixed(1).toString().replace(".","")+"m "+(nSec/10).toFixed(1).toString().replace(".","")+"s";
  }

  SD=window.setTimeout("fn_wpCountDown("+nHour.toString()+","+nMin.toString()+","+nSec.toString()+",'"+sDestination+"');", 1000);
}

//############################################################################################
// na detailu zobrazi zalozku + free gift a  + free gift and shipping

function fn_dtShowFree()
{
 if(getE('all_price'))
  {
    nPrice=stripHTML(getE('all_price').innerHTML).replace('$','').replace('&Pound;','').replace('&Euro;','');
    nPriceCart=stripHTML(getE('CartPrice').innerHTML).replace('$','').replace('&Pound;','').replace('&Euro;','')
  
    nPrice=Math.abs(nPrice);
    nPriceCart=Math.abs(nPriceCart);
    
    if (nPrice+nPriceCart>99 && nPriceCart<=99) {
        if(getE('Free')) {getE('Free').removeNode(true);}
        oNew=document.createElement('span');
        oNew.id='Free';
        oNew.className='Freeshipping';
        getE('all_price').appendChild(oNew);
        getE('all_price').parentNode.className='Prices Fre';
        //alert('Free shipping');
        }  
    else if (nPrice+nPriceCart>29 && nPriceCart<=29) {
        if(getE('Free')) {getE('Free').removeNode(true);}
        oNew=document.createElement('span');
        oNew.id='Free';
        oNew.className='Freegift';
        getE('all_price').parentNode.appendChild(oNew);
        getE('all_price').parentNode.className='Prices Fre';
        //alert('Free gift');
        }
    else
    {
      if(getE('Free')) {getE('Free').removeNode(true);}
      getE('all_price').parentNode.className='Prices';
    }    
          
  }
}
