// Example: 
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}
// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
 
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
   //alert(name+": "+cookieValue);
  return cookieValue;
}
/***************************************************/
/* FUNCIONES DEL ORTO QUE NO SE PARA QUE ESTAN.    */
/***************************************************/
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

/******************************/
/* FIN DE FUNCIONES DEL ORTO. */
/******************************/

var popUpWin=0;

function showPopup(URLStr){

  if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  } 
  
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=640,height=480');
}

function addToCart(_id){
	/*if(!confirm("Add item to your cart?")){
		return false;
	}*/
	var c=CART;
	var t=document.getElementById(_id+"_count");
	var count=1;
	if(t){
		if(!isNaN(t.value)){
			count=Number(t.value);
		}else{
			alert("Quantity is not valid. One item was added to cart.");
			count=1
		}
		
	}else{
		alert("Quantity is not valid. One item will be added to cart.");
		count=1;
	}
	if(count<=0){
		count=1;
		alert("Quantity is not valid. One item will be added to cart.");
	}	
	if(!confirm("Do you really want to add "+count+" item(s) to cart?")){
		return false;
	}

	c.add(_id, count);
	c.refreshCart(document);
}
function addToCart2(_id){
	var c=CART;
	c.add(_id);
	c.refreshCart(document);
}
function substractCart(_id){
	var c=CART;
	c.substract(_id);
	c.refreshCart(document);
}
function deleteOfCart(_id){
	if(!confirm("Delete this item from your cart?")){
		return false;
	}
	var c=CART;
	c.deleteItem(_id);
	c.refreshCart(document);
}



function discountITEM(_id,_id2,QTY){
	var c=CART;
	c.add(_id2, QTY);
	c.deleteItem(_id);
}




function discountME(){
	var c=CART;
	c.discountIT();
	c.refreshCart(document);
}



function _onRollOver(ob){

	ob.style.backgroundColor="#D3CDFF";
}
function _onRollOut(ob){
	
	ob.style.backgroundColor="#D3CDB3";
}
var prevOb=null;
function _onSwitch(n){
	if(prevOb){
		prevOb.style.display="none"	;
	}
	var ob=document.getElementById("detail"+n);
	if(ob==prevOb){
		ob.style.display="none";
		prevOb=null;
	}else{
		ob.style.display="";
		prevOb=ob;
	}
	
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function mmLoadMenus() {
  if (window.mm_menu_0808190647_0) return;
  window.mm_menu_0808190647_0 = new Menu("root",128,20,"Arial, Helvetica, Verdana, sans-serif",10,"#6c6657","#70653a","#e4e0de","#d9d1b7","left","middle",3,0,200,-5,7,true,true,true,0,false,false);
  mm_menu_0808190647_0.addMenuItem("Coffee","location='coffee.php'");
  mm_menu_0808190647_0.addMenuItem("Coffee&nbsp;Accessories","location='coffee_accessories.php'");
  mm_menu_0808190647_0.addMenuItem("Coffee&nbsp;Gifts","location='coffee_gifts.php'");
  mm_menu_0808190647_0.addMenuItem("Specials","location='specials.php'");
  mm_menu_0808190647_0.addMenuItem("Customer&nbsp;Service","location='contact.php'");
    mm_menu_0808190647_0.addMenuItem("Testimonials","location='testimonial.php'");
   mm_menu_0808190647_0.hideOnMouseOut=true;
   mm_menu_0808190647_0.menuBorder=1;
   mm_menu_0808190647_0.menuItemBorder=1;
   mm_menu_0808190647_0.menuLiteBgColor='#e4e0de';
   mm_menu_0808190647_0.menuBorderBgColor='#d7d1ce';
   mm_menu_0808190647_0.bgColor='#e4e0de';
  window.mm_menu_0808184515_1 = new Menu("root",128,20,"Arial, Helvetica, Verdana, sans-serif",10,"#6c6657","#70653a","#e4e0de","#d9d1b7","left","middle",3,0,200,-5,7,true,true,true,0,false,false);
  mm_menu_0808184515_1.addMenuItem("Blue&nbsp;Mountain&nbsp;Coffee","location='explore_blue.php'");
  mm_menu_0808184515_1.addMenuItem("About&nbsp;Jablum","location='explore_about.php'");
  mm_menu_0808184515_1.addMenuItem("Production&nbsp;Process","location='explore_production.php'");
  mm_menu_0808184515_1.addMenuItem("Brew&nbsp;the&nbsp;Perfect&nbsp;Cup","location='brew.php'");
  mm_menu_0808184515_1.addMenuItem("Our&nbsp;People","location='explore_our_people.php'");
  mm_menu_0808184515_1.addMenuItem("Coffee&nbsp;Herald","location='explore_news.php'");
  mm_menu_0808184515_1.addMenuItem("Recipes","location='recipes.php'");
  mm_menu_0808184515_1.addMenuItem("Customer&nbsp;Service","location='contact.php'");
   mm_menu_0808184515_1.hideOnMouseOut=true;
   mm_menu_0808184515_1.menuBorder=1;
   mm_menu_0808184515_1.menuItemBorder=1;
   mm_menu_0808184515_1.menuLiteBgColor='#e4e0de';
   mm_menu_0808184515_1.menuBorderBgColor='#d7d1ce';
   mm_menu_0808184515_1.bgColor='#e4e0de';
  window.mm_menu_1101132757_2 = new Menu("root",179,20,"Arial, Helvetica, Verdana, sans-serif",10,"#6c6657","#70653a","#e4e0de","#d9d1b7","left","middle",3,0,200,-5,7,true,true,true,0,false,false);
  mm_menu_1101132757_2.addMenuItem("Contact&nbsp;Information","window.open('contact_information.php', '_self');");
  mm_menu_1101132757_2.addMenuItem("Product&nbsp;Feedback","window.open('product_feedback.php', '_self');");
  mm_menu_1101132757_2.addMenuItem("FAQ's","window.open('faqs.php', '_self');");
  mm_menu_1101132757_2.addMenuItem("Shipping&nbsp;&amp;&nbsp;Delivery","window.open('shopping_delivery.php', '_self');");
  mm_menu_1101132757_2.addMenuItem("Privacy&nbsp;Policy","window.open('privacy_policy.php', '_self');");
  mm_menu_1101132757_2.addMenuItem("Legal","window.open('legal.php', '_self');");
   mm_menu_1101132757_2.hideOnMouseOut=true;
   mm_menu_1101132757_2.menuBorder=1;
   mm_menu_1101132757_2.menuItemBorder=1;
   mm_menu_1101132757_2.menuLiteBgColor='#e4e0de';
   mm_menu_1101132757_2.menuBorderBgColor='#d7d1ce';
   mm_menu_1101132757_2.bgColor='#e4e0de';

  mm_menu_1101132757_2.writeMenus();
} // mmLoadMenus()

//-->

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var trailimage=["squire2.gif", 31, 60] //image path, plus width and height
var offsetfrommouse=[10,-20] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0 //duration in seconds image should remain visible. 0 for always.

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;left:0px;top:0px;width:1px;height:1px;display:none"><img src="'+trailimage[0]+'" border="0" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div>')



function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

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

function hidetrail(){
//gettrailobj().visibility="hidden"
//alert("hide");
gettrailobj().display="none";
writeCookie("myCookie", "oculto", 24)
}

function showtrail(){
//gettrailobj().visibility="visible"
//alert("show");
gettrailobj().display="";
writeCookie("myCookie", "visible", 24)
}

function swap(){
if (readCookie("myCookie")=="oculto"){
  showtrail()
 } else {
  hidetrail()
 }
}

function condicioninicial(){
//alert("joya:"+readCookie("myCookie"));
  if (readCookie("myCookie")== "visible"){
	  showtrail();
  }
  
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

function followmouse(e){
var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]
if (typeof e != "undefined"){
xcoord+=e.pageX
ycoord+=e.pageY
}
else if (typeof window.event !="undefined"){
xcoord+=truebody().scrollLeft+event.clientX
ycoord+=truebody().scrollTop+event.clientY
}
var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)/*
if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
gettrailobj().display="none"
else 
gettrailobj().display=""*/
gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"
}

document.onmousemove=followmouse
/*
if (displayduration>0)
setTimeout("hidetrail()", displayduration*1000)*/

