/**
* @author acao
*/
var counter = 0,
    interval = 5000,
    images = ["/images/bridal/ad_main1.jpg", "/images/bridal/ad_main2.jpg", "/images/bridal/ad_main3.jpg"],
    links = ["wedding", "bridalparty", "formal"];

/**
* @function imageSlideShow rotating among ad images on index page
*/
function imageSlideShow() {
   var ad = document.getElementById("main-ad");
   
    if (ad) {
        adlink = ad.getElementsByTagName("A")[0].href = links[counter];
        ad.getElementsByTagName("IMG")[0].src = images[counter];
        counter = (counter < images.length-1)? counter+1 : 0;
        setTimeout("imageSlideShow()", interval);
    }
}

/**
* @function popup pops up a window
*/
function popup(url, windowname, width, height) {
	if (! window.focus)return true;
	window.open(url, windowname, "width=" + width + ",height=" + height);
	return false;
}

/**
* @function toggleDisplay show/hide an element
*/
function toggleDisplay(id, e) {
   var element = document.getElementById(id);
   
   if (element && element.getStyle("display") === "none") {
      element.style.display = "block";
      e.preventDefault();
   } else if (element && element.getStyle("display") === "block") {
      element.style.display = "none";
      e.preventDefault();
   }
}

/**
* @function hilightImage hilight the alternate view image on mouseover
*/
function hilightImage(){
   var alternate = document.getElementById("alternate");

   alternate.style.border = "1px solid #F60";
}

/**
* @function unhilightImage unhilight the alternate view image on mouseout
*/
function unhilightImage(){
   var alternate = document.getElementById("alternate");

   alternate.style.border = "1px solid #630";
}

/**
* @function switchImage switch between different views of a product
*/
function switchImage(){
   var primary = temp = document.getElementById("primary"),
       temp = primary.src,
       alternate = document.getElementById("alternate");

   primary.src = alternate.src.replace("/alt_thumbs", "");
   alternate.src = temp;
}

/**
* @function validateForm validate form before submitting
*/
function validateForm(){
   var email = document.getElementById("email");
   
   
}