function openColorOptions ()
{
	window.open('color_options.htm','','width=900,left=100,top=100,resizable=yes,scrollbars=yes');}

function openKivaGlassOptions ()
{
	window.open('kiva_glass_options.htm','','width=900,left=100,top=100,resizable=yes,scrollbars=yes');
}

function enableSelectForGoogleCartIfWidgetLoaded ( )
{
	if (googlecartWidget.isLoaded())
	{
	var x = document.getElementsByTagName("select");
	for (var i=0;i<x.length;i++)
		{
		var n = x[i].getAttribute("id");
		if (!n) continue;
		document.getElementById(x[i].id).disabled=false;
		}
	clearInterval (enableSelectIntervalId);
	}
}	

/* kivaInit function intializes kiva pages, hides no JavaScript message, initializes lightbox galleries... */
/* To add a new lightbox gallery, copy one gallery and change target directory and lightboxer_name class to unique id */
/* see 3 lines marked "EDIT" in first gallery below */
function kivaInit()
{
	document.getElementById("noJavascriptMsg").style.display="none";
	
        //gets all images with source in the "products" directory
        $("img[src*='products/']").each(function() { //**************************************EDIT src*='new_directory_name'
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer"); //**********************************************EDIT addClass("lightboxer_new_name")
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer').lightBox(); //*****EDIT ('a.lightboxer_new_name') - lightboxer_new_name must match EDIT line above
 
      
        //gets all images with source in the "images/designs" directory
        $("img[src*='images/designs/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_designs");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_designs').lightBox();


        //gets all images with source in the "images/colors" directory
        $("img[src*='images/colors/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_color");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_color').lightBox();


        //gets all images with source in the "images/liners_glass" directory
        $("img[src*='images/liners_glass/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_liners_glass");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_liners_glass').lightBox();


        //gets all images with source in the "images/options" directory
        $("img[src*='images/options/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_options");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_options').lightBox();


        //gets all images with source in the "images/bulbs" directory
        $("img[src*='images/bulbs/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_bulbs");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_bulbs').lightBox();


        //gets all images with source in the "images/specs" directory
        $("img[src*='images/specs/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_specs");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_specs').lightBox();


        //gets all images with source in the "images/specs" directory
        $("img[src*='specials/']").each(function() {
            //reads the source file name
            var Img = $(this).attr('src');
            //gets the Alt tag text
            var Text = $(this).attr('alt');
            //strips off the extension ".jpg, .png, etc"
            var imgExt = /(\.\w{3,4}$)/;
            //creates a new image object
            var newImg = new Image();
            //attaches the link information to the "_big" file version
            newImg.src = Img.replace(imgExt,'_big$1');
            //creates a link html tag
            var a = $('<a/>').attr('href', newImg.src).attr('title', 'Click to See Larger Image');
            // adds the "lightboxer" class to the link           
            $(a).addClass("lightboxer_specials");
            //wraps the thumb image with this new link tag
            $(this).wrap(a);
        });//ends "each" function
       
        //binds the links to the lightbox function
        $('a.lightboxer_specials').lightBox();

 
/* EDIT add new gallery before this line */
}; //ends kivaInit function


function initMenu()
{
	$('.nav').superfish({delay: 400});
  $('.nav li:has(ul)').find('a:first').addClass('sub');
  $('.nav ul li:has(ul)').find('a:first').removeClass('sub').addClass('subsub');
}


/*initializes tabs to set first atb active when page loads - specify activeTab, activeFolder on each page in <head> */
function initTabs ()
{
	document.getElementById(activeFolder).style.display="block";
	document.getElementById(activeTab).style.background="#FEEAD2 url('../images/page_layout/tab_FEEAD2_Left.png') no-repeat left top";
	document.getElementById(activeTabRight).style.background="#FEEAD2 url('../images/page_layout/tab_FEEAD2_Right.png') no-repeat right top";
}

function setActiveTab(tabId,folderId,tabRightId)
{
	document.getElementById(activeFolder).style.display="none";
	activeFolder=folderId;
	document.getElementById(folderId).style.display="block";
	document.getElementById(activeTab).style.background="#BB7E38 url('../images/page_layout/tab_BB7E38_Left.png') no-repeat left top";
	activeTab=tabId;
	document.getElementById(tabId).style.background="#FEEAD2 url('../images/page_layout/tab_FEEAD2_Left.png') no-repeat left top";
	document.getElementById(activeTabRight).style.background="#BB7E38 url('../images/page_layout/tab_BB7E38_Right.png') no-repeat right top";
	activeTabRight=tabRightId;
	document.getElementById(tabRightId).style.background="#FEEAD2 url('../images/page_layout/tab_FEEAD2_Right.png') no-repeat right top";
}	

//	alert(activeTab+' '+ activeFolder+' '+activeTabRight);



/* bookmark page */
function bookmarkpage()
{
	if (window.sidebar) // firefox
		window.sidebar.addPanel(document.title, document.URL, "");
	else if(window.opera && window.print)
	{ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',document.URL);
		elem.setAttribute('title',document.title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
	window.external.AddFavorite(document.URL, document.title);
}
