var bPageIsLoaded = false;
/***********************************************************************
*
* setCookie -	Generic Set Cookie routine
*
* Input: sName	 -	Name of cookie to create
*	 sValue	 -	Value to assign to the cookie
*	 sExpire -	Cookie expiry date/time (optional)
*
* Returns: null
*
************************************************************************/

function setCookie(sName, sValue, sExpire) 
    {
    var sCookie = sName + "=" + escape(sValue) +"; path=/";	// construct the cookie
    if (sExpire)
    	{
    	sCookie += "; expires=" + sExpire.toGMTString();	// add expiry date if present
    	}
    document.cookie = sCookie;					// store the cookie
    return null;
    }

/***********************************************************************
*
* getCookie	-	Generic Get Cookie routine
*
* Input: sName	-	Name of cookie to retrieve
*
* Returns:		Requested cookie or null if not found
*
************************************************************************/

function getCookie(sName) 
    {
    var sCookiecrumbs = document.cookie.split("; "); 	// break cookie into crumbs array
    var sNextcrumb
    for (var i=0; i < sCookiecrumbs.length; i++) 
	{
	sNextcrumb = sCookiecrumbs[i].split("=");	// break into name and value
	if (sNextcrumb[0] == sName)			// if name matches
	    {
	     return unescape(sNextcrumb[1]); 		// return value
	    }
	}
	return null;
    }

/***********************************************************************
*
* saveReferrer -	Saves the referrer to a Cookie
*
* Input: 		nothing
*
* Returns:		null
*
************************************************************************/

function saveReferrer() 
    {
    var bSetCookie = false;
    if (parent.frames.length == 0)					// No FrameSet
		{
		bSetCookie = true;
		}
    else														// FrameSet in use
		{
		var bCatalogFrameSet = false;
		for (var nFrameId = parent.frames.length; nFrameId > 0; nFrameId--)
			{
			if (parent.frames[nFrameId - 1].name == 'CatalogBody')	// Catalog FrameSet used
				{
				bCatalogFrameSet = true;
				break;
				}
			}
		if (bCatalogFrameSet)							// Catalog FrameSet
			{
			if (window.name=='CatalogBody')			// and this is the CatalogBody frame
				{
				bSetCookie = true;
				}
			}
		else													// Not Catalog FrameSet
			{
			bSetCookie = true;
			}
		}
    if (bSetCookie)
		{
		var sUrl = document.URL;
		var nHashPos = sUrl.lastIndexOf("#");		// Look for URL anchor
		if (nHashPos > 0)									// if it exists
		    {
		    sUrl = sUrl.substring(0,nHashPos);		// then remove it
		    }
		setCookie("ACTINIC_REFERRER", sUrl);		// Emulates HTTP_REFERER
		}
	    return null;
	    }
    
saveReferrer();						// For v6 only, should be in templates for v7

/***********************************************************************
*
* CreateArray	creates an array with n elements
*
* Input: n	-	number of elements
*
* Returns:		the created array
*
************************************************************************/

function CreateArray(n)
	{
	this.length = n;
	for (var i=1; i <= n; i++)							// for all ns
		{
		this[i] = new Section();						// create a section structure
		}
	return this;											// return the created array
	}

/***********************************************************************
*
* Section	-	creates the section structure for raw section lists
*
* Input: 				nothing
*
* Returns:				nothing
************************************************************************/

function Section()
	{
	this.sURL = null;
	this.sName = null;
	this.sImage = null;
	this.nImageWidth = null;
	this.nImageHeight= null;
	this.nSectionId	= null;
	this.pChild = null;
	}
	
/***********************************************************************
*
* SwapImage			-	swaps an image to the alternative
*
* Input:	sName		-	name of the image
*
*			sAltImage	-	filename of the alternative image
*
************************************************************************/

function SwapImage(sName, sAltImage)
	{
	var nCount = 0;
	document.aSource = new Array;						// array for images
	if (document[sName] != null)						// if image name exists
		{
		document.aSource[nCount++] = document[sName];	// store image
		if(null == document[sName].sOldSrc)
			{
			document[sName].sOldSrc = document[sName].src;	// store image source
			}
		document[sName].src = sAltImage;				// change image source to alternative
		}
	}
	
function swapproductimg(sAltImage)
{
	var nCount = 0;
	document.aSource = new Array;						// array for images
	if (document["imgProd"] != null)						// if image name exists
		{
		document.aSource[nCount++] = document["imgProd"];	// store image
		if(null == document["imgProd"].sOldSrc)
			{
			document["imgProd"].sOldSrc = document["imgProd"].src;	// store image source
			}
		document["imgProd"].src = sAltImage;				// change image source to alternative
		}
}
	
function SetImageOn()
{
	var strURL = window.location.toString();
	if (strURL.toLowerCase().indexOf('index.html')>0 && document['nav_home'].src.indexOf('_o.gif')<1)
		document['nav_home'].src = document['nav_home'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('faq.html')>0 && document['nav_faq'].src.indexOf('_o.gif')<1)
		document['nav_faq'].src = document['nav_faq'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('links.html')>0 && document['nav_links'].src.indexOf('_o.gif')<1)
		document['nav_links'].src = document['nav_links'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('contactus.html')>0 && document['nav_contact'].src.indexOf('_o.gif')<1)
		document['nav_contact'].src = document['nav_contact'].src.replace('.gif','_o.gif');
	
	if (strURL.toLowerCase().indexOf('special_offers.html')>0 && document['Special_Offers'].src.indexOf('_o.gif')<1)
		document['Special_Offers'].src = document['Special_Offers'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('hot_products.html')>0 && document['hot_products'].src.indexOf('_o.gif')<1)
		document['hot_products'].src = document['hot_products'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('garden.html')>0 && document['Garden'].src.indexOf('_o.gif')<1)
		document['Garden'].src = document['Garden'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('accessories.html')>0 && document['accessories'].src.indexOf('_o.gif')<1)
		document['accessories'].src = document['accessories'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('home_office.html')>0 && document['home_office'].src.indexOf('_o.gif')<1)
		document['home_office'].src = document['home_office'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('dining.html')>0 && document['dining'].src.indexOf('_o.gif')<1)
		document['dining'].src = document['dining'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('lighting.html')>0 && document['lighting'].src.indexOf('_o.gif')<1)
		document['lighting'].src = document['lighting'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('living.html')>0 && document['living'].src.indexOf('_o.gif')<1)
		document['living'].src = document['living'].src.replace('.gif','_o.gif');
	if (strURL.toLowerCase().indexOf('sleeping.html')>0 && document['sleeping'].src.indexOf('_o.gif')<1)
		document['sleeping'].src = document['sleeping'].src.replace('.gif','_o.gif');
}

/***********************************************************************
*
* SwapImage1			-	swaps an image to the alternative (assumes -on)
*
* Input:	sName		-	name of the image
*
************************************************************************/

function SwapImage1old(sName)
{
	var nCount = 0;
	document.aSource = new Array;						// array for images
	if (document[sName] != null)						// if image name exists
	{
	document.aSource[nCount++] = document[sName];	// store image
	if(null == document[sName].sOldSrc)
		{
		document[sName].sOldSrc = document[sName].src;	// store image source
		}
	if (document[sName].src.indexOf('-on.gif')<1)
		document[sName].src = document[sName].sOldSrc.replace('.gif','-on.gif');	// change image source to alternative
	}
}

/***********************************************************************
*
* SwapImage1			-	swaps an image to the alternative (assumes -on)
*
* Input:	sName		-	name of the image
*			iSection	-	the section ID
*
************************************************************************/

function SwapImage1(sName,iSection)
{
	var nCount = 0;
	document.aSource = new Array;						// array for images
	if (document[sName] != null)						// if image name exists
	{
		document.aSource[nCount++] = document[sName];	// store image
		if(null == document[sName].sOldSrc)
		{
			document[sName].sOldSrc = document[sName].src;	// store image source
		}
		if (document[sName].src.indexOf('_o.gif')<1)
			document[sName].src = document[sName].sOldSrc.replace('.gif','_o.gif');	// change image source to alternative
	}

	try{
		DisplaySubSection(iSection);
	}
	catch(Ex){}
}	

/***********************************************************************
*
* HideSubSection		-	Displays the subsection div tag if it exists
*
* Input:	iSection	-	the section ID
*
************************************************************************/

function HideSubSection(iSection)
{
	var cursor = {x:0, y:0};
	cursor = getPosition();
	
	try{
		var oSub = document.getElementById("sub_" + iSection);
		//alert(cursor.x + "<" + (oSub.style.left.replace('px','')-10) + ":or:" + cursor.x + ">" + (oSub.style.left.replace('px','')-(145)*-1));
		if (cursor.x < (oSub.style.left.replace('px','')-10) || cursor.x > (oSub.style.left.replace('px','')-(145)*-1))
			oSub.style.visibility = 'hidden';
			
		//alert(cursor.y + "<" + (oSub.style.top.replace('px','')) + ":or:" + cursor.x + ">" + (oSub.style.top.replace('px','')-(470)*-1));
		if (cursor.y < oSub.style.top.replace('px',''))
			oSub.style.visibility = 'hidden';
	}
	catch(Ex){}
}

/***********************************************************************
*
* ForceHideSubSection		-	Displays the subsection div tag if it exists
*
* Input:	iSection	-	the section ID
*
************************************************************************/

function ForceHideSubSection(iSection)
{
	//try{
	//	var oSub = document.getElementById("sub_" + iSection);
	//	oSub.style.visibility = 'hidden';
	//}
	//catch(Ex){}
	ForceHideAllSubSections();
}

function ForceHideAllSubSections()
{
	for (var i=0; i<20; i++)
	{
		try{
			var oSub = document.getElementById("sub_" + i);
			oSub.style.visibility = 'hidden';
		}
		catch(Ex){}
	}
}

/***********************************************************************
*
* DisplaySubSection		-	Displays the subsection div tag if it exists
*
* Input:	iSection	-	the section ID
*
************************************************************************/

function DisplaySubSection(iSection)
{
	var clientWidth;
	var clientHeight;
	var j;
	
	try{
		var cursor = {x:0, y:0};
		
		try{
			cursor = getPosition();
		}
		catch(Ex){}
		
		var oSub = document.getElementById("sub_" + iSection);
		
		clientWidth = document.body.offsetWidth;
		//alert(document.body.width);
		//alert(document.body.offsetWidth);
		try{
			clientHeight = 124 + ((iSection-1) * 25);
			oSub.style.top = clientHeight + 'px';
			clientWidth = (clientWidth-752)/2 + 140;
			oSub.style.left = clientWidth + "px";
			//alert(clientWidth);
		}
		catch(Ex){
			oSub.style.top = cursor.y;
			oSub.style.left = cursor.x;
		}
	}
	catch(Ex){}
	try
	{
		//for the benefit of foxpro hide all other sub sections has a limit of 20
		for (j=1; j<21; j++)
		{
			if (j == iSection)
			{
				try{
					oSub.style.visibility = 'visible';
				}
				catch(Ex){}
			}
			else
			{
				try	
				{
					document.getElementById("sub_" + j).style.visibility = 'hidden';
				}
				catch(Ex){}
			}
		}
	}
	catch(Ex){}
}

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
       cursor.x = e.pageX;
        cursor.y = e.pageY;
	} 
    else {
        cursor.x = e.clientX + 
            (document.documentElement.scrollLeft || 
            document.body.scrollLeft) - 
            (document.documentElement.clientLeft || 
            document.body.clientLeft);
        cursor.y = e.clientY + 
            (document.documentElement.scrollTop || 
            document.body.scrollTop) - 
            (document.documentElement.clientTop || 
            document.body.clientTop);
    }
    return cursor;
}

/***********************************************************************
*
* RestoreImage		-	restores an image to the original
*
* Input: 	iSection	-	the section ID
*
* Returns:				nothing
************************************************************************/

function RestoreImage(iSection)
	{
	var nCount, aSource = document.aSource;
	if (aSource != null)									// if array of images exists
		{
		for(nCount=0; nCount < aSource.length; nCount++)	// restore all images
			{
			if ((aSource[nCount] != null) &&
				(aSource[nCount].sOldSrc != null))	// if we stored something for this image
				{
				aSource[nCount].src = aSource[nCount].sOldSrc;	// restore the original image
				}
			}
		}
	//SetImageOn()
}

/***********************************************************************
*
* PreloadImages		-	restores an image to the original
*
* Input: 				nothing
*
* Returns:				nothing
*
************************************************************************/

function PreloadImages()
	{
	bPageIsLoaded = true;
	if(document.images)
		{
		if(!document.Preloaded)							// preload array defined?
			{
			document.Preloaded = new Array();		// no, define it
			}
		var nCounter , nLen = document.Preloaded.length, saArguments = PreloadImages.arguments;
		for(nCounter = 0; nCounter < saArguments.length; nCounter++)	// iterate through arguments
			{
			document.Preloaded[nLen] = new Image;
			document.Preloaded[nLen++].src = saArguments[nCounter];
			}
   	}
	}
	
/***********************************************************************
*
* ShowPopUp		-	creates pop up window
*
* Input: sUrl		-	URL o page to display
*			nWidth	-	Width of window
*			nHeight	-	Height of window
*
* Returns:				nothing
*
************************************************************************/

function ShowPopUp(sUrl, nWidth, nHeight)
  	{  
	window.open(sUrl, 'ActPopup', 'width=' + nWidth + ',height=' + nHeight + ',scrollbars, resizable');
	if (!bPageIsLoaded)
		{
		window.location.reload(true);
		}
	}
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Copyright of Living It Up Salon";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")
