function addToCart(item,qty)
{
  qty = getE(qty).value;
  item = getE(item).value;
  if(isNaN(qty)) {dropDownMessage("Please enter a numeric quantity for this item",5000); return;}
  if(qty==0) {dropDownMessage("Please enter a quantity for this item",5000); return;}
  dropDownMessage(getAjaxResponse('index.php?section=cart&subsection=add&itemidn='+item+'&qty='+qty),15000);
}
//********************************
//* AJAX functions
//* By Stephen Rusin
//********************************
function GetXmlHttpObject()
{
    var xh = null;
  try
      {
	  // Firefox, Opera 8.0+, Safari
	  xh = new XMLHttpRequest();
      }
  catch (e)
      {
	  // Internet Explorer
    try
	{
	    xh = new ActiveXObject("Msxml2.XMLHTTP");
	}
    catch (e)
	{
	    xh = new ActiveXObject("Microsoft.XMLHTTP");
	}
      }
  return xh;
}

function getAjaxResponse(url)
{
    var xmlHttp = GetXmlHttpObject()
	if(xmlHttp==null)
	    {
		alert ("Your browser does not support AJAX! You won't be able to properly view this site!");
		return;
	    }
    xmlHttp.open('GET',url+'&sid='+(new Date()).getTime(),false);
    xmlHttp.send(null);
    if(xmlHttp.status == 200)
	return xmlHttp.responseText;
}

function dropDownMessage(text,delay)
{
    if(typeof dropinboxv2=="undefined")
	dropinboxv2 = getE("dropinboxv2");
  dropinboxv2.innerHTML = '<p align="right" style="margin: 0px 0px 5px 0px; background: url(\'images/n31.gif\'); padding: 2px 3px 2px 0px;"><a href="#" onClick="dismissboxv2();return false" style="padding: 0px; margin: 51px 0px 0px 0px;"><img width=25 height=25 src=images/close.png border=0></a></p><p align="center" style="margin: 25px 10px 0px 10px;">' + text + "</p>";
  initboxv2(delay);
}

function getE(element) { return document.getElementById(element); }


function nav(u) { document.location.href = u; }

/***********************************************
 * Amazon style Drop-in content box- * Visit DynamicDrive.com for hundreds of DHTML scripts
 * This notice must stay intact for legal use
 * Go to http://www.dynamicdrive.com/ for full source code
 ***********************************************/
// some icons from Freeiconsweb
var dropboxleft=0 //set left position of box (in px)
    var dropboxtop=0 //set top position of box (in px)
    var dropspeed=30 //set speed of drop animation (larger=faster)

    //1) "always"- This makes the fade-in box load each time the page is displayed
    //2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
    //3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
    // For example, 2 would display the box about (1/2) 50% of the time the page loads.

    //var displaymode="always"

    ///Don't edit beyond here///////////

    //if (parseInt(displaymode)!=NaN)
    //var random_num=Math.floor(Math.random()*displaymode)
var ie=document.all
var dom=document.getElementById

    function initboxv2(delay)
{
    if(window.liftstart) clearInterval(liftstart);
    if(window.dismissstart) clearInterval(dismissstart);
    if (!dom&&!ie)
    return
	crossboxcover=(dom)?document.getElementById("dropinboxv2cover") : document.all.dropinboxv2cover
	crossbox=(dom)?document.getElementById("dropinboxv2"): document.all.dropinboxv2
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
  crossbox.height=crossbox.offsetHeight
	crossboxcover.style.height=parseInt(crossbox.height)+"px"
	crossbox.style.top=crossbox.height*(-1)+"px"
  crossboxcover.style.left=dropboxleft+"px"
  crossboxcover.style.top=dropboxtop+"px"
	crossboxcover.style.visibility=(dom||ie)? "visible" : "show"
	dropstart=setInterval("dropinv2()",50)
	dismissstart=setInterval("dismissboxv2()",delay);
}

    function dropinv2()
    {
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	    if (parseInt(crossbox.style.top)<0)
		{
    crossboxcover.style.top=scroll_top+dropboxtop+"px"
    crossbox.style.top=parseInt(crossbox.style.top)+dropspeed+"px"
		}
	    else
		{
		    clearInterval(dropstart)
    crossbox.style.top=0
			}
    }

function dropoutv2()
{
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	if (parseInt(crossbox.style.top) > -1*parseInt(crossbox.height) )
	    {
    crossboxcover.style.top = scroll_top - dropboxtop + "px"
    crossbox.style.top = parseInt(crossbox.style.top) - dropspeed + "px"
	    }
	else
	    {
		clearInterval(liftstart)
		    clearInterval(dismissstart)
    crossboxcover.style.visibility="hidden"
		    }
}

function dismissboxv2()
{
    if (window.dropstart) clearInterval(dropstart)
			      if (window.liftstart) clearInterval(liftstart)
							liftstart=setInterval("dropoutv2()",50)
							}

function truebody()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}


/***********************************************
 * Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
 * Copyright 2002-2007 by Sharon Paine
 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
 ***********************************************/

/* IMPORTANT: Put script after tooltip div or
   put tooltip div just before </BODY>. */

var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= false;
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 440;
var offX= 20;   // how far from mouse to show tip
var offY= -200;
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#CACBCD"; //"#D5DFF0";
var tipBorderColor= "#000080";
var tipBorderWidth= 1;
var tipBorderStyle= "ridge";
var tipPadding= 0;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
// multi-dimensional arrays containing:
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
/*
var messages = new Array();
messages[0] = new Array('tiles/1_full.jpg','<center><b>Arpa Natura</b><br>Oro 12 x 12 AHNA-OR-F1');
messages[1] = new Array('tiles/5_full.jpg','<center><b>Cerdomus Thermae</b><br>Ercolano 12 x 12 CMTH-ER-1');
messages[2] = new Array('tiles/4_full.jpg','<center><b>Cerdomus Thermae</b><br>Ercolano 12 x 12 CMTH-ER-1');
messages[3] = new Array('tiles/3_full.jpg','<center><b>Cerdomus Thermae</b><br>Ercolano 12 x 12 CMTH-ER-1');
messages[4] = new Array('tiles/7_full.jpg','<center><b>Cerdomus Thermae</b><br>Ercolano 12 x 12 CMTH-ER-1');
messages[5] = new Array('tiles/6_full.jpg','<center><b>Cerdomus Thermae</b><br>Ercolano 12 x 12 CMTH-ER-1');
*/
////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
/*
if (document.images) {
        var theImgs = new Array();
        for (var i=0; i<messages.length; i++) {
        theImgs[i] = new Image();
                theImgs[i].src = messages[i][0];
  }
}
*/

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
//var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '<tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip     - initialization for tooltip.
//              Global variables for tooltip.
//              Set styles
//              Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
    if (nodyn) return;
    tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
    tipcss = tooltip.style;
    if (ie4||ie5||ns5) {    // ns4 would lose all this on rewrites
	tipcss.fontFamily = tipFontFamily;
	tipcss.fontSize = tipFontSize;
	tipcss.color = tipFontColor;
	tipcss.backgroundColor = tipBgColor;
	tipcss.borderColor = tipBorderColor;
	tipcss.borderWidth = tipBorderWidth+"px";
	tipcss.padding = tipPadding+"px";
	tipcss.borderStyle = tipBorderStyle;
    }
    if (tooltip&&tipFollowMouse) {
	document.onmousemove = trackMouse;
    }
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//                      Assembles content for tooltip and writes
//                      it to tipDiv
/////////////////////////////////////////////////
var t1,t2;      // for setTimeouts
var tipOn = false;      // check if over tooltip link
function doTooltip(evt,message,width,height,offsetY) {

    if(offsetY!=null) offY = offsetY;

    var twidth = tipWidth;

    if(width!=null) twidth = width;
    tipcss.width = twidth+"px";


    if (!tooltip) return;
    if (t1) clearTimeout(t1);       if (t2) clearTimeout(t2);
    tipOn = true;

    // set colors if included in message array
    if (message[2]) var curBgColor = message[2];
    else curBgColor = tipBgColor;
    if (message[3]) var curFontColor = message[3];
    else curFontColor = tipFontColor;
    if (ie4||ie5||ns5) {
	var startStr = '<table width="' + twidth + '">';
        if(message[0]!=null)
          startStr += '<tr><td align="center" width="100%"><img src="'+message[0]+'" border="0"></td></tr>';        
        var tip = startStr + midStr + '<span style="font-family:' + tipFontFamily + '; zIndex: 200; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + message[1] + '</span>' + endStr;
                tipcss.backgroundColor = curBgColor;
                tooltip.innerHTML = tip;
    }
    if (!tipFollowMouse) positionTip(evt);
    else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
    standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
        mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
    mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
    if (tipOn) positionTip(evt);
}
/////////////////////////////////////////////////////////////
//  positionTip function
//              If tipFollowMouse set false, so trackMouse function
//              not being used, get position of mouseover event.
//              Calculations use mouseover event position,
//              offset amounts and tooltip width to position
//              tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
    if (!tipFollowMouse) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	    mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
    }
    // tooltip width and height
    var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
    var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
    // document area in view (subtract scrollbar width for ns)
    var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
    var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
    // check mouse position against tip and window dimensions
    // and position the tooltip
    if ((mouseX+offX+tpWd)>winWd)
	tipcss.left = mouseX-(tpWd+offX)+"px";
    else tipcss.left = mouseX+offX+"px";
    if ((mouseY+offY+tpHt)>winHt)
	tipcss.top = winHt-(tpHt+offY)+"px";
    else tipcss.top = mouseY+offY+"px";
    if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
    if (!tooltip) return;
    t2=setTimeout("tipcss.visibility='hidden'",100);
    tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')

/* Flex Level Drop Down Menu v1.0
* Created: Jan 5th, 2010 by DynamicDrive.com. This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/

//Usage: $(elementselector).addflexmenu('menuid')
//ie:
//jQuery(document).ready(function($){
	//$('a.mylinks').addflexmenu('flexmenu1') //apply flex menu with ID "flexmenu1" to links with class="mylinks"
//})

jQuery.noConflict()

var flexdropdownmenu=
{
  arrowpath: 'images/arrow.gif', //full URL or path to arrow image
  animspeed: 200, //reveal animation speed (in milliseconds)
  showhidedelay: [150, 150], //delay before menu appears and disappears when mouse rolls over it, in milliseconds

  //***** NO NEED TO EDIT BEYOND HERE
  startzindex:-1,
  builtflexmenuids: [], //ids of flex menus already built (to prevent repeated building of same flex menu)

  positionul:function($, $ul, e, $anchor)
  {
    //Bool indicating whether $ul is top level flex menu DIV
    var istoplevel=$ul.hasClass('jqflexmenu') 
    //40 is to account for shadows in FF
    var docrightedge=$(document).scrollLeft()+$(window).width()-40 
    var docbottomedge=$(document).scrollTop()+$(window).height()-40
    //if main flex menu DIV
    if (istoplevel)
    {
      var offsets=$anchor.offset()
      var anchorsetting=$anchor.data('setting')
      //x pos of main flex menu UL
      var x=offsets.left+anchorsetting.useroffsets[0]+(anchorsetting.dir=="h"? $anchor.outerWidth() : 0) 
      var y=offsets.top+anchorsetting.useroffsets[1]+(anchorsetting.dir=="h"? 0 : $anchor.outerHeight()) + 4
      //if not enough horizontal room to the ridge of the cursor
      x=(x+$ul.data('dimensions').w > docrightedge)? x-(anchorsetting.useroffsets[0]*2)-$ul.data('dimensions').w+$anchor.outerWidth()+(anchorsetting.dir=="h"? -($anchor.outerWidth()*2) : 0) : x 
      // removed SMR static menu change
      //      y=(y+$ul.data('dimensions').h > docbottomedge)? y-(anchorsetting.useroffsets[1]*2)-$ul.data('dimensions').h-$anchor.outerHeight()+(anchorsetting.dir=="h"? ($anchor.outerHeight()*2) : 0) : y
    }
    else //if sub level flex menu UL
    { 
      var $parentli=$ul.data('$parentliref')
      var parentlioffset=$parentli.offset()
      //x pos of sub UL
      var x=$ul.data('dimensions').parentliw 
      var y=0
      //if not enough horizontal room to the ridge parent LI
      x=(parentlioffset.left+x+$ul.data('dimensions').w > docrightedge)? x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w : x 
      y=(parentlioffset.top+$ul.data('dimensions').h > docbottomedge)? y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih : y
    }
    $ul.css({left:x, top:y})
  },
	
  showbox:function($, $flexmenu, e) 
  {
    clearTimeout($flexmenu.data('timers').hidetimer)
    $flexmenu.data('timers').showtimer=setTimeout(function(){$flexmenu.show(flexdropdownmenu.animspeed)}, this.showhidedelay[0])
  },

  hidebox:function($, $flexmenu)
  {
// added SMR static menu change
return;
    clearTimeout($flexmenu.data('timers').showtimer)
    //hide flex menu plus all of its sub ULs
    $flexmenu.data('timers').hidetimer=setTimeout(function(){$flexmenu.hide(100)}, this.showhidedelay[1]) 
  },

  buildflexmenu:function($, $menu, $target)
  {
    $menu.css({display:'block', visibility:'hidden', zIndex:this.startzindex}).addClass('jqflexmenu').appendTo(document.body)
    $menu.bind('mouseenter', function()
    {
      clearTimeout($menu.data('timers').hidetimer)
    })		
    $menu.bind('mouseleave', function()
    { 
      //hide menu when mouse moves out of it
      flexdropdownmenu.hidebox($, $menu)
    })
    //remember main menu's dimensions
    $menu.data('dimensions', {w:$menu.outerWidth(), h:$menu.outerHeight()}) 
    $menu.data('timers', {})
    //find all LIs within menu with a sub UL
    var $lis=$menu.find("ul").parent() 
    $lis.each(function(i)
    {
      var $li=$(this).css({zIndex: 1000+i})
      //set sub UL to "block" so we can get dimensions
      var $subul=$li.find('ul:eq(0)').css({display:'block'}) 
      $subul.data('dimensions', {
          w:$subul.outerWidth(), h:$subul.outerHeight(), parentliw:this.offsetWidth, parentlih:this.offsetHeight
      })
      //cache parent LI of each sub UL
      $subul.data('$parentliref', $li) 
      $subul.data('timers', {})
      $li.data('$subulref', $subul) //cache sub UL of each parent LI
      $li.children("a:eq(0)").append( //add arrow images
        '<img src="'+flexdropdownmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />' 
				      )
      $li.bind('mouseenter', function(e)
      { 
        //show sub UL when mouse moves over parent LI
        var $targetul=$(this).css('zIndex', ++flexdropdownmenu.startzindex).addClass("selected").data('$subulref')
        if ($targetul.queue().length<=1)
        { 
          //if 1 or less queued animations  
          clearTimeout($targetul.data('timers').hidetimer) 
          $targetul.data('timers').showtimer=setTimeout(function(){
                flexdropdownmenu.positionul($, $targetul, e)
                $targetul.show(flexdropdownmenu.animspeed)
	      }, flexdropdownmenu.showhidedelay[0])
	}
      })
      $li.bind('mouseleave', function(e)
      { 
        //hide sub UL when mouse moves out of parent LI
        var $targetul=$(this).data('$subulref')
        clearTimeout($targetul.data('timers').showtimer)
        $targetul.data('timers').hidetimer=setTimeout(function()
        {
          $targetul.hide(100).data('$parentliref').removeClass('selected')
        }, flexdropdownmenu.showhidedelay[1])
      })
    })
    //collapse all ULs again
    $menu.find('ul').andSelf().css({display:'none', visibility:'visible'}) 
    //remember id of flex menu that was just built    
    this.builtflexmenuids.push($menu.get(0).id) 
  },

  init:function($, $target, $flexmenu)
  {
    if (this.builtflexmenuids.length==0)
    { 
      //only bind click event to document once
      $(document).bind("click", function(e)
      {
        if (e.button==0)
        {
          //hide all flex menus (and their sub ULs) when left mouse button is clicked
// removed SMR static menu change
//          $('.jqflexmenu').find('ul').andSelf().hide()
        }
      })
    }
    //if this flex menu hasn't been built yet
    if (jQuery.inArray($flexmenu.get(0).id, this.builtflexmenuids)==-1)
      this.buildflexmenu($, $flexmenu, $target)
    //if $target matches an element within the flex menu markup, don't bind onflexmenu to that element
    if ($target.parents().filter('ul.jqflexmenu').length>0) 
      return
    //get additional user offsets of menu
    var useroffsets=$target.attr('data-offsets')? $target.attr('data-offsets').split(',') : [0,0] 
    useroffsets=[parseInt(useroffsets[0]), parseInt(useroffsets[1])]
    //store direction (drop right or down) of menu plus user offsets
    $target.data('setting', {dir: $target.attr('data-dir'), useroffsets: useroffsets}) 
    $target.bind("mouseenter", function(e)
    {
      // top level show
      $flexmenu.css('zIndex', ++flexdropdownmenu.startzindex)
      flexdropdownmenu.positionul($, $flexmenu, e, $target)
      flexdropdownmenu.showbox($, $flexmenu, e)
    })
    $target.bind("mouseleave", function(e)
    {
      flexdropdownmenu.hidebox($, $flexmenu)
    })
  },
  showM:function($,$target,$flexmenu)
  {
     $flexmenu.css('zIndex', ++flexdropdownmenu.startzindex)
     flexdropdownmenu.positionul($, $flexmenu, null, $target)
     flexdropdownmenu.showbox($, $flexmenu, null)
  }
}

jQuery.fn.addflexmenu=function(flexmenuid, direction)
{
  var $=jQuery
  return this.each(function()
  { 
    //return jQuery obj
    var $target=$(this)
    flexdropdownmenu.init($, $target, $('#'+flexmenuid))
    flexdropdownmenu.showM($, $target, $('#'+flexmenuid))
  })
};

//By default, add flex menu to anchor links with attribute "data-flexmenu"
jQuery(document).ready(function($){
	var $anchors=$('*[data-flexmenu]')
	$anchors.each(function(){
		$(this).addflexmenu(this.getAttribute('data-flexmenu'))
	})
})