//-SF
window.onload = loader;
function loader() {
 if (opacityCheck()){
	fadebackground();
	setHeight();
	try{
		document.getElementById("black").style.visibility  = "visible";
		document.getElementById("cart").style.zIndex  = "10";
		document.getElementById("cart").style.visibility  = "visible";
		document.getElementById("dropdown1").style.visibility  = "hidden";
		document.getElementById("dropdown2").style.visibility  = "hidden";
	   }
	catch(e){}
	}

	try{
	   document.getElementById("flashcontent2").style.visibility  = "hidden";
	   }
	catch(e){}
	
	try{
	   initit();
	   }
	catch(e){}
	
}

function closeCart() {
document.getElementById("cart").style.visibility  = "hidden";
unfadebackground();
}

function fadebackground(){
shiftOpacityDark('black', 1000);
}

function unfadebackground(){
shiftOpacityLight('black', 1000);
//dropdowns + some flash content show through all divs in IE so they are made
//invisible when the cart overlaps them and visable when the cart is closed
document.getElementById("dropdown1").style.visibility  = "visible";
document.getElementById("dropdown2").style.visibility  = "visible";
try{
   document.getElementById("flashcontent2").style.visibility  = "visible";
   }
catch(e){}
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
		
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
		
    }

}

//change the opacity for different browsers
function changeOpac(opacity, id) {
 try{
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	//hides black overlay after its faded out
	if (document.getElementById("black").style.opacity == 0){
	document.getElementById("black").style.visibility  = "hidden";
	}
	}
 catch(e){}	
} 

function shiftOpacityLight(id, millisec) {
        opacity(id, 50, 0, millisec);
}

function shiftOpacityDark(id, millisec) {
        opacity(id, 1, 50, millisec);
}

function button(id, color) {
document.getElementById(id).style.background  = over;
}

function setHeight() {
	try{
	document.getElementById("black").style.height = document.body.scrollHeight;
	}
	catch(e){}
}

function getAppName(){
document.write(navigator.appName);
}

function getPlatform(){
document.write(navigator.platform);
}
function getUserAgent(){
document.write(navigator.userAgent);
}

//Checks to see if the user is useing IE on a mac
//Because opacity does not work in this browser
//Cart wont run and defaults back to the old way the site worked
function opacityCheck(){
if (navigator.userAgent.indexOf("Mac") != -1 && navigator.appName.indexOf("Microsoft") != -1)
return false;
else
return true;
}


