var numFeatureImages=10;



function init() 
{
	
	//fixPNG();
	initFeatureImage();
	initProductDetails();
	
	
 	if (!document.getElementsByTagName) 
 		return;
 		
 	var b = document.getElementsByTagName("body");
 	theBody = b[0];
 	if(theBody.className.match("popup"))
 	{
 		 window.focus();
	}
 
 	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) 
 	{
   		var anchor = anchors[i];
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
   		{
     		anchor.target = "_blank";
 		}	
     	else if (anchor.className.match("print")) 
     	{
        	anchor.onclick = function() 
        	{
          		printPage();
          		return false;
        	};
    	}
    	else if (anchor.className.match("window")) 
     	{
        	anchor.onclick = function() 
        	{
          		popUp(this.getAttribute("href"));
          		return false;
        	};
    	}
    	else if (anchor.className.match("file")) 
     	{
        	anchor.onclick = function() 
        	{
          		window.open(this.getAttribute("href"));
          		return false;
        	};
    	}
    	else if (anchor.className.match("close")) 
     	{
        	anchor.onclick = function() 
        	{
          		window.close();
          		return false;
        	};
    	}
 	}
 
}

window.onload = init;





function popUp(URL)
{
	eval("window.open('" + URL + "','windowName', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=462,height=500');");
}

/* Author: Rebecca Skeers rebecca@webmistress.com.au 2005 */
function printPage() 
{
  	if (window.print)
		window.print()
	else
		alert("Sorry, your browser doesn't support the print feature. Use the File menu on your browser to select Print.");
	return false;
}






function fixPNG()
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters) && (version < 7)) 
	{
		for(var i=0; i<document.images.length; i++)
		{
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML
				i = i-1
			}
		}
	}	
};


function initFeatureImage()
{
	var div = document.getElementById("content");
	var str;
	
	randomNumber = Math.ceil(Math.random() * numFeatureImages);

	if (div.className == "")
	{
		div.className = "banner"+randomNumber;
	}
	else
	{
		div.className += " banner"+randomNumber;
	}
};





function initProductDetails() 
{
	var sectionProductDetails = document.getElementById("section-products");
	if(sectionProductDetails != null)
	{
		var mainDiv = document.getElementById("main");
		
		if(mainDiv != null)
		{
			var divs = mainDiv.getElementsByTagName("div");
		
			for (var i=0; i<divs.length; i++) 
			{
				if(divs[i].className=="product-details")
				{
					var listItems = divs[i].getElementsByTagName("li");
					
					
					for (var k=0; k<listItems.length; k++) 
					{
					
						listItems[k].onmouseover=function() 
						{
							
								if(this.className == "")
									this.className="hover";
								else
									this.className+=" hover";
							
						}
						
						listItems[k].onmouseout=function() 
						{
							
							this.className=this.className.replace(new RegExp(" hover\\b"), "");
							this.className=this.className.replace(new RegExp("hover\\b"), "");
						
						}
						
						listItems[k].onfocus=function() 
						{
							
								if(this.className == "")
									this.className="hover";
								else
									this.className+=" hover";
						
						}
						
						listItems[k].onblur=function() 
						{
							this.className=this.className.replace(new RegExp(" hover\\b"), "");
							this.className=this.className.replace(new RegExp("hover\\b"), "");
							
						}
					}
				}
				
				
				
				
			}
		}
	}
}



