// JavaScript Document

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

var imgEffect = {
	_divID : 'order',
		
	_configList : null,
	
	_configIndex : 0,
	
	_timeOut : 5000,
	
	init : function() {
		imgEffect._configList = new Array();
		imgEffect._configList[0] = '-199';
		imgEffect._configList[1] = '15';
		
		window.setTimeout('imgEffect._callBack()', imgEffect._timeOut);
	},
	
	_callBack : function() {
		var curDiv = document.getElementById(imgEffect._divID);
		if(imgEffect._configList[imgEffect._configIndex] == null) imgEffect._configIndex = 0;
		var curConfig = imgEffect._configList[imgEffect._configIndex];
		imgEffect._configIndex++;
		
		curDiv.style.left = curConfig+'px';
		
		window.setTimeout('imgEffect._callBack()', imgEffect._timeOut);
	}
};

//changes the image of tagImage to what is in strImageSrc
function changeImage(tagImage,strImageSrc)
{
	//gets the properties of tagImage
	tagImage = getDocID(tagImage);
	
	//checks if there is a properties
	if(tagImage != null)
		tagImage.src = strImageSrc;
}//end of changeImage()

//this is for the duel layers that sometimes is need
function duelToggleLayer(whichLayer,layer1,layer2)
{
	var activeLayer = "";//holds the active Layer	
	var style2 = "";//holds the style of layer1
	var style3 = "";//holds the style of layer2

	// this is the way the standards work
	if (whichLayer != ''){activeLayer = getDocID(whichLayer);}
	if (layer1 != ''){style2 = getDocID(layer1);}
	if (layer2 != ''){style3 = getDocID(layer2);}

	//Checks if there is an active layer
	if (activeLayer != "")
	{
		//checks if the activeLayer is already active and if so then skips code
		//since the layer cannot be turn off and leave a hole in the review layer
		if (activeLayer.style.display == "")
		{
			//removes the block from the display in order to make the layer to disapper	
			if (style2 != ''){style2.style.display = style2.style.display? "":"";}

			//checks if there is a style3
			if (style3 != ''){style3.style.display = style3.style.display? "":"";}
	
			//displays the new active Layer and updates its id
			activeLayer.style.display = activeLayer.style.display? "":"block";
		}//end of if
	}//end of if
}//end of duelToggleLayer()

//gets the document properties in order to use them as there are many types of browers with different versions
function getDocID(tagLayer)
{
	var tagProp = "";//holds the proerties of tagLayer
	
	//gets the whichLayer Properties depending of the differnt bowers the user is using
	if (document.getElementById)//this is the way the standards work
		tagProp = document.getElementById(tagLayer);
	else if (document.all)//this is the way old msie versions work
		tagProp = document.all[tagLayer];
	else if (document.layers)//this is the way nn4 works
		tagProp = document.layers[tagLayer];
			   
	return tagProp;			
}//end of getDocID()

//moves a div loaction base on the mouse
function moveDivByMouse(tagLayer,event)
{
	var tagLayer = getDocID(tagLayer);//holds the tagLayer
	
	if (tagLayer != null)
	{		
		//checks if the browser is using pageX if nto then use clientX instead
		if ('pageX' in event) 
		{
            tagLayer.style.top = (event.pageY - document.documentElement.scrollLeft) + "px";
			tagLayer.style.left = (event.pageX - document.documentElement.scrollLeft) + "px";
		}//end of if
        else
		{
        	tagLayer.style.top = (event.clientY + document.documentElement.scrollLeft) + "px";
            tagLayer.style.left = (event.clientX + document.documentElement.scrollTop) + "px";
		}//end of else
	}//end of if
}//end of moveDivByMouse()

//shoes and hides a <div> using display:block/none from the CSS
function toggleLayer(tagLayer,tagGrayOut,tagMedia)
{
	var tagStyle = '';//holds the style of tagLayer

	//gets the tagLayer and tagGrayOut Properties
	tagStyle = getDocID(tagLayer);
	tagGrayOut = getDocID(tagGrayOut);
	tagMedia = getDocID(tagMedia);
		
	if (tagStyle != null)
	{tagStyle.style.display = tagStyle.style.display? "":"block";}
	
	if (tagGrayOut != null)
	{
		tagGrayOut.style.display = tagGrayOut.style.display? "":"block";

		//for IE
		if (navigator.userAgent.indexOf('MSIE') != -1)
		{
			tagGrayOut.attachEvent('onclick',function () {
				toggleLayer(tagStyle.id,tagGrayOut.id)
								
				//checks if there is any Media to stop also pleace remove when REUSING THIS FUNCTION 
				if (tagMedia != null && document.getElementById("embed_url") != null)
					tagMedia.removeChild(document.getElementById("embed_url"));
					//tagMedia.src = "";
					//exit_youtube();
			});
		}//end of if
		//for the other browsers
		else
		{
			tagGrayOut.addEventListener('click',function () {
				toggleLayer(tagStyle.id,tagGrayOut.id);
				
			if (tagMedia != null && document.getElementById("embed_url") != null)
				tagMedia.removeChild(document.getElementById("embed_url"));
			},false);
		}//end of else
	}//end of if
}//end of toggleLayer()
