var homeImage01 = new Image
var homeImage02 = new Image
var homeImage03 = new Image
var homeImage04 = new Image

homeImage01.src = "images/homeImage01.jpg"
homeImage02.src = "images/homeImage02.jpg"
homeImage03.src = "images/homeImage03.jpg"
homeImage04.src = "images/homeImage04.jpg"


HomePics = new Array(homeImage01,homeImage03)
imgCt = HomePics.length
var randomNum = Math.floor((Math.random() * imgCt))
if (randomNum == 0) {
    var backHead = homeImage01.src;
    var backNoHead = homeImage02.src;
}
else {
    var backHead = homeImage03.src;
    var backNoHead = homeImage04.src;
}

function choosePic() {
    document.body.background = backHead;;
}

function menuProducts() {
   productsHeight = parseInt(document.getElementById('ifrmProducts').style.height);
   if (productsHeight == 30) {
      productsCloseStop = "yes";
      productsOpenStop = "no";
      menuProductsOpen();
   }
   else {
      productsCloseStop = "no";
      productsOpenStop = "yes";
      menuProductsClose();
   }
}

function menuProductsOpen() {
   productsHeight=productsHeight+10;
     if (productsHeight == 110 && productsOpenStop == 'no') {
        checkProducts = document.getElementById('ifrmProducts');
        checkProducts.style.height=110; 
      }
      else if (productsHeight != 110 && productsOpenStop == 'no') {
        checkProducts = document.getElementById('ifrmProducts');
        checkProducts.style.height=productsHeight;  
        setTimeout("menuProductsOpen();",1);            
      }
}

function menuProductsClose() {
   productsHeight=productsHeight-10;
     if (productsHeight == 30 && productsCloseStop == 'no' || productsHeight < 30 && productsCloseStop == 'no') {
        checkProducts = document.getElementById('ifrmProducts');
        checkProducts.style.height=30; 
      }
      else if (productsHeight != 30 && productsCloseStop == 'no') {
        checkProducts = document.getElementById('ifrmProducts');
        checkProducts.style.height=productsHeight;  
        setTimeout("menuProductsClose();",1);            
      }
}

function menuSpecial() {
   specialHeight = parseInt(document.getElementById('ifrmSpecial').style.height);
   if (specialHeight == 30) {
      specialCloseStop = "yes";
      specialOpenStop = "no";
      menuSpecialOpen();
   }
   else {
      specialCloseStop = "no";
      specialOpenStop = "yes";
      menuSpecialClose();
   }
}

function menuSpecialOpen() {
   specialHeight=specialHeight+10;
     if (specialHeight == 280 && specialOpenStop == 'no') {
        checkSpecial = document.getElementById('ifrmSpecial');
        checkSpecial.style.height=280; 
      }
      else if (specialHeight != 280 && specialOpenStop == 'no') {
        checkSpecial = document.getElementById('ifrmSpecial');
        checkSpecial.style.height=specialHeight;  
        setTimeout("menuSpecialOpen();",1);            
      }
}

function menuSpecialClose() {
   specialHeight=specialHeight-10;
     if (specialHeight == 30 && specialCloseStop == 'no' || specialHeight < 30 && specialCloseStop == 'no') {
        checkSpecial = document.getElementById('ifrmSpecial');
        checkSpecial.style.height=30; 
      }
      else if (specialHeight != 30 && specialCloseStop == 'no') {
        checkSpecial = document.getElementById('ifrmSpecial');
        checkSpecial.style.height=specialHeight;  
        setTimeout("menuSpecialClose();",1);            
      }
}

function menuFlyer() {
   flyerHeight = parseInt(document.getElementById('ifrmFlyer').style.height);
   if (flyerHeight == 30) {
      flyerCloseStop = "yes";
      flyerOpenStop = "no";
      menuFlyerOpen();
   }
   else {
      flyerCloseStop = "no";
      flyerOpenStop = "yes";
      menuFlyerClose();
   }
}

function menuFlyerOpen() {
   flyerHeight=flyerHeight+10;
     if (flyerHeight == 240 && flyerOpenStop == 'no') {
        checkFlyer = document.getElementById('ifrmFlyer');
        checkFlyer.style.height=240; 
      }
      else if (flyerHeight != 240 && flyerOpenStop == 'no') {
        checkFlyer = document.getElementById('ifrmFlyer');
        checkFlyer.style.height=flyerHeight;  
        setTimeout("menuFlyerOpen();",1);            
      }
}

function menuFlyerClose() {
   flyerHeight=flyerHeight-10;
     if (flyerHeight == 30 && flyerCloseStop == 'no' || flyerHeight < 30 && flyerCloseStop == 'no') {
        checkFlyer = document.getElementById('ifrmFlyer');
        checkFlyer.style.height=30; 
      }
      else if (flyerHeight != 30 && flyerCloseStop == 'no') {
        checkFlyer = document.getElementById('ifrmFlyer');
        checkFlyer.style.height=flyerHeight;  
        setTimeout("menuFlyerClose();",1);            
      }
}

function menuContact() {
   contactHeight = parseInt(document.getElementById('ifrmContact').style.height);
   if (contactHeight == 30) {
      contactCloseStop = "yes";
      contactOpenStop = "no";
      menuContactOpen();
   }
   else {
      contactCloseStop = "no";
      contactOpenStop = "yes";
      menuContactClose();
   }
}

function menuContactOpen() {
   contactHeight=contactHeight+10;
     if (contactHeight == 260 && contactOpenStop == 'no') {
        checkContact = document.getElementById('ifrmContact');
        checkContact.style.height=260; 
      }
      else if (contactHeight != 260 && contactOpenStop == 'no') {
        checkContact = document.getElementById('ifrmContact');
        checkContact.style.height=contactHeight;  
        setTimeout("menuContactOpen();",1);            
      }
}

function menuContactClose() {
   contactHeight=contactHeight-10;
     if (contactHeight == 30 && contactCloseStop == 'no' || contactHeight < 30 && contactCloseStop == 'no') {
        checkContact = document.getElementById('ifrmContact');
        checkContact.style.height=30; 
      }
      else if (contactHeight != 30 && contactCloseStop == 'no') {
        checkContact = document.getElementById('ifrmContact');
        checkContact.style.height=contactHeight;  
       setTimeout("menuContactClose();",1);            
      }
}

if (document.getElementById) {
	visible = 'visible';
	hidden = 'hidden';
} else if (document.layers) {
	visible = 'show';
	hidden = 'hide';
} else if (document.all) {
	visible = 'visible';
	hidden = 'hidden';
}
function reveal(menu) {
	if (document.getElementById) {
		theMenu = document.getElementById(menu).style;	 
 } else if (document.layers) {
		var theMenu = document.layers[menu];		
	} else if (document.all) {
		var theMenu = document.all[menu].style;	 
}
	if (theMenu.visibility == visible) {
		theMenu.visibility = visible;
	} else {
		theMenu.visibility = visible;
	}
}

function hide(menu) {
	if (document.getElementById) {
		theMenu = document.getElementById(menu).style;
		
	} else if (document.layers) {
		theMenu = document.layers[menu];
		
	} else if (document.all) {
		theMenu = document.all(menu).style;
}
	if (theMenu.visibility == hidden) {
		theMenu.visibility = hidden;
	} else {
		theMenu.visibility = hidden;
	}
}

function positionMenu() {
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}
var totalW=winW-750;
var halfW=totalW/2;
var rightPosition=Math.round(halfW);
var totalH=winH-500;
var halfH=totalH/2;
var topPosition=Math.round(halfH);
var backW=1600-winW;
var halfBackW=backW/2;
var rightBackPosition=Math.round(halfBackW);
var backH=1000-winH;
var halfBackH=backH/2;
var topBackPosition=Math.round(halfBackH);
var footerPosition=Math.round(winH);
document.getElementById("logo").style.left=rightPosition+10+"px";
document.getElementById("logo").style.top=topPosition+30+"px";
document.getElementById("homeDelivery").style.left=rightPosition+500+"px";
document.getElementById("homeDelivery").style.top=topPosition+30+"px";
document.getElementById("productOrder").style.left=rightPosition+500+"px";
document.getElementById("productOrder").style.top=topPosition+30+"px";
document.getElementById("productListing").style.left=rightPosition+500+"px";
document.getElementById("productListing").style.top=topPosition+30+"px";
document.getElementById("giftCards").style.left=rightPosition+500+"px";
document.getElementById("giftCards").style.top=topPosition+30+"px";
document.getElementById("featuredSpecial").style.left=rightPosition+500+"px";
document.getElementById("featuredSpecial").style.top=topPosition+30+"px";
document.getElementById("staff").style.left=rightPosition+500+"px";
document.getElementById("staff").style.top=topPosition+30+"px";
document.getElementById("footer").style.left=0+"px";
document.getElementById("footer").style.top=footerPosition-30+"px";
}

function getContent(selectedLayer) {
   homeDeliveryWidth = parseInt(document.getElementById('homeDelivery').style.width);
   productOrderWidth = parseInt(document.getElementById('productOrder').style.width);
   productListingWidth = parseInt(document.getElementById('productListing').style.width);
   giftCardsWidth = parseInt(document.getElementById('giftCards').style.width);
   featuredSpecialWidth = parseInt(document.getElementById('featuredSpecial').style.width);
   staffWidth = parseInt(document.getElementById('staff').style.width);
   if (homeDeliveryWidth == 500) {
	 contentHide('homeDelivery',selectedLayer);
   }
   else if (productOrderWidth == 500) {
	 contentHide('productOrder',selectedLayer);
   }
   else if (productListingWidth == 500) {
	 contentHide('productListing',selectedLayer);
   }
   else if (giftCardsWidth == 500) {
	 contentHide('giftCards',selectedLayer);
   }
   else if (featuredSpecialWidth == 500) {
	 contentHide('featuredSpecial',selectedLayer);
   }
   else if (staffWidth == 500) {
	 contentHide('staff',selectedLayer);
   }
   else {
     contentReveal(selectedLayer);
	 document.body.background = backNoHead;

   }
}

function contentHide(visibleLayer,selectedLayer) {
    newWidth = parseInt(document.getElementById(visibleLayer).style.width);
    if (newWidth > 0) {
          newWidth=newWidth-50;
          newLeft=newLeft+25;
          document.getElementById(visibleLayer).style.width=newWidth+"px";
          document.getElementById(visibleLayer).style.left=newLeft+"px";
          setTimeout("contentHide('"+visibleLayer+"','"+selectedLayer+"');",0);            
    }
    else if (newWidth == 0) {
          document.getElementById(visibleLayer).style.width=0+"px";
          setTimeout("contentReveal('"+selectedLayer+"');",100);            
    }
}

function contentReveal(selectedLayer) {
    newWidth = parseInt(document.getElementById(selectedLayer).style.width);
    newLeft = parseInt(document.getElementById(selectedLayer).style.left);
    if (newWidth < 500) {
          newWidth=newWidth+50;
          newLeft=newLeft-25;
          document.getElementById(selectedLayer).style.width=newWidth+"px";
          document.getElementById(selectedLayer).style.left=newLeft+"px";
          setTimeout("contentReveal('"+selectedLayer+"');",0);            
    }
    else if (newWidth == 500) {
          document.getElementById(selectedLayer).style.width=500+"px";
    }
}

function closeContent(selectedLayer) {
   newLeft = parseInt(document.getElementById(selectedLayer).style.left);
   document.getElementById(selectedLayer).style.width=0+"px";
   document.getElementById(selectedLayer).style.left=newLeft+250+"px";
   document.body.background = backHead;

}

function changePhoto(photoSource) {
      document.getElementById('staffPhoto').src = photoSource;
}

function CheckForm() {
   var problem = 'No';
	if (document.orderForm.address.value.length <= 0) {
      alert ("You must include your address");
	  document.orderForm.address.focus();
	  problem = 'Yes';  
	}
	if (document.orderForm.city.value.length <= 0) {
      alert ("You must include your city");
	  document.orderForm.city.focus();
	  problem = 'Yes';  
	}if (document.orderForm.postalCode.value.length <= 0) {
      alert ("You must include your postal code");
	  document.orderForm.code.focus();
	  problem = 'Yes';  
	}if (document.orderForm.name.value.length <= 0) {
      alert ("You must include your name");
	  document.orderForm.name.focus();
	  problem = 'Yes';  
	}if (document.orderForm.phone.value.length <= 0) {
      alert ("You must include your phone number");
	  document.orderForm.phone.focus();
	  problem = 'Yes';  
	}if (document.orderForm.email.value.length <= 0) {
      alert ("You must include your email");
	  document.orderForm.email.focus();
	  problem = 'Yes';  
	}if (problem == 'No') {
	  return true;
	}else {
	  return false;	  
    }
}

function pickUp()  {
    document.orderForm.addressDelivery.disabled = true;
    document.orderForm.cityDelivery.disabled = true;
    document.orderForm.postalDelivery.disabled = true;
    document.orderForm.date.disabled = true;
    document.orderForm.addressDelivery.value = "";  
    document.orderForm.cityDelivery.value = "";  
    document.orderForm.postalDelivery.value = "";  
    document.orderForm.date.value = "";  
	document.getElementById('deliveryAddress').className="body_text_bold_fade";
	document.getElementById('deliveryCity').className="body_text_bold_fade";
	document.getElementById('deliveryPostal').className="body_text_bold_fade";
	document.getElementById('deliveryDate').className="body_text_bold_fade";
    document.orderForm.delivery.value = "Pick-up"; 
}
 
function delivery()  {
   document.orderForm.addressDelivery.disabled = false; 
   document.orderForm.cityDelivery.disabled = false; 
   document.orderForm.postalDelivery.disabled = false; 
   document.orderForm.date.disabled = false; 
	document.getElementById('deliveryAddress').className="body_text_bold";
	document.getElementById('deliveryCity').className="body_text_bold";
	document.getElementById('deliveryPostal').className="body_text_bold";
	document.getElementById('deliveryDate').className="body_text_bold";
   document.orderForm.delivery.value = "Delivery"; 
}

function form() {
    PhotoWindow = window.open("mail.php", "IRLY", "width=560,height=340,scrollbars=no,status=no,menubar=no,marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,rightmargin=0")
    PhotoWindow.focus() 
	}
