  function alertuser(string,redirect)
  {
    if(confirm(string))
      location.replace(redirect);
  }
  function imagePop(img, w, h)
  {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    window.open(img,'ugl','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width='+w+',height='+h+',resizable=yes,top='+wint+',left='+winl).focus();
  }
  function toggleSection(div)
  {
    divv = getE(div);
    if(divv.style.visibility=="hidden")
      showSection(div);
    else
      divv.style.visibility = "hidden";
  }
  function showSection(div)
  {
    divv = getE(div);
    divv.style.visibility = "visible";
  }
  function hideSection(div)
  {
    divv = getE(div);
    divv.style.visibility = "hidden";
  }
  function changeSectionColor(div,color)
  {
    getE(div).bgColor = color;
  }
  function clearOptions(selectbox,firstoption,firstoptionvalue)
  {
    selectbox = getE(selectbox);
    for(var i=selectbox.options.length-1;i>=0;i--)
      selectbox.remove(i);
  }
  function addOption(selectbox,text,value )
  {
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
  }
  function getE(element) { return document.getElementById(element); }
  function fillSize(sizesection,sizeselect,colorselect,swatch,idn)
  {
    sizesection = getE(sizesection);
    sizeselect = getE(sizeselect);
    colorselect = getE(colorselect);
    var item = null;
    if(colorselect.value=="")
      hideSection(sizesection.id);
    else
    {
      sizes = getAjaxResponse('index.php?section=ajax&subsection=fillsize&idn='+idn+'&color='+colorselect.value);
      // size layout: price`itemnumber`size`swatch|...
      sizes = sizes.split("|");
      var j = sizes.length;
      clearOptions(sizeselect.id);
      addOption(sizeselect,"Select Size","");
      for(var i=0;i<j;i++)
      {
        params = sizes[i].split("`");
        addOption(sizeselect,params[2]+" ["+params[1]+"] - $"+params[0], params[1]);
        if(i==0) 
        {
          item = params[1];
          displaySwatch(swatch,params[3]);
        }
      }
      showSection(sizesection.id);
    }
  }
  function displaySwatch(swatch,swatchfile)
  { 
    swatch = getE(swatch);
    if(swatchfile==null || typeof(swatchfile)=="undefined" || swatchfile.length<=0)
      swatch.setAttribute("src","images/shim_invis.gif");
    else
      swatch.setAttribute("src","uploads/colors/"+swatchfile);
  }
  function addToCart(sizeselect,colorselect,qty,idn)
  {
    sizeselect = getE(sizeselect);
    colorselect = getE(colorselect);
    qty = getE(qty);
    if(colorselect.length>1)
      if(colorselect.selectedIndex==0) {dropDownMessage("Please select a color for this item",5000); return;}
    if(sizeselect.selectedIndex==0) {dropDownMessage("Please select a size for this item",5000); return;}
    addToCartAJAX(qty.value, sizeselect.value)
  }
  function addToCartAJAX(qty,itemnum)
  {
    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&itemnumber='+itemnum+'&qty='+qty),10000);
  }

//********************************
//* 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_red/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);
}

// some icons from Freeiconsweb

/***********************************************
* 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
***********************************************/

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= "#FFFFFF"; //"#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 = '" border="0"></td></tr><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 + '"><tr><td align="center" width="100%"><img src="';
		var tip = startStr + message[0] + midStr + '<span style="font-family:' + tipFontFamily + '; 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>')


