
function initNav() {
	if(primaryNav != "" && primaryNav != "beauty_extranet") {
 		document.images[primaryNav].src = eval(primaryNav + "On.src");
	}
	if(secondaryNav != "") {
		//alert("secondaryNav is  "+secondaryNav);
		document.images[secondaryNav].src = eval(secondaryNav + "On.src");
	}
}

function swapImage(image, state) {
	if(primaryNav == image || secondaryNav == image) {
		return;
	}
	else {
		document.images[image].src = eval(image + state + ".src");
	}
}

function goTo(oSelect) {
	
	var url = oSelect.options[oSelect.selectedIndex].value;

	// split the url to determine if you need to open a new window or not
	var result = url.split( "#", 2 );
	
	if( result.length == 1) window.open(result[0]);
	else if(result[1] == "true") window.open(result[0]);
	else window.location.href = result[0];
}

function getElementXY(elm) {
  
	var point = { x: 0, y: 0, imgHeight: 0 };
  	point.imgHeight = elm.height;
	
	// recurse the DOM to get the true offsetLeft and offsetTop
	while (elm != null) {
    	point.x += elm.offsetLeft;
    	point.y += elm.offsetTop;
    	elm = elm.offsetParent;
  	}
	
	return point;
}

function processDropDown(dropdown, referenceObj) {
	/* positions a dropdown and makes it visible */
		
	if( (! document.getElementById) || (! initDropDowns) ) {
		return;
	}
	
	var referencePoint;
	var child; 
	
	// position the dropdown and make it visible
	referencePoint = getElementXY( referenceObj );
	m_obj = document.getElementById(dropdown);
	if (referenceObj.id == 'csl_header')
		m_obj.style.left =  (referencePoint.x + 12) + "px";
	else
		m_obj.style.left =  (referencePoint.x + 5) + "px";
	m_obj.style.top = (referencePoint.y+2) + referencePoint.imgHeight + "px";
	m_obj.style.visibility = "visible";
	m_obj.onmouseover = showDropDown;
	if (referenceObj.id == 'csl_header')
		m_obj.onmouseout = showDropDown;
	else
		m_obj.onmouseout = hideDropDown;
 }

function processSecondaryDropDown(dropdown, referenceObj,name) {
	/* positions a dropdown and makes it visible */
		
	if( (! document.getElementById) || (! initDropDowns) ) {
		return;
	}
	
	var referencePoint;
	var child;
	
	// position the dropdown and make it visible
	referencePoint = getElementXY( referenceObj );
	m_obj = document.getElementById(dropdown);

	if(name == 'A'){  						//My Haircolor Goal
		childtop = referencePoint
		m_obj.style.left = (referencePoint.x + 145) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
		changeVisibility('secondaryNavA');
		changeVisibility('secondaryNavB');
		changeVisibility('tertiaryNavA');
		changeVisibility('tertiaryNavB');
	} else if(name == 'B'){  				//My Hair Type
		m_obj.style.left = (referencePoint.x + 145) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
		changeVisibility('secondaryNav');
		changeVisibility('secondaryNavB');
		changeVisibility('tertiaryNav');
		changeVisibility('tertiaryNavB');
	} else if(name == 'C'){					//My Level of Experience
		m_obj.style.left = (referencePoint.x + 145) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
		changeVisibility('secondaryNavA');
		changeVisibility('secondaryNav');
		changeVisibility('tertiaryNav');
		changeVisibility('tertiaryNavA');
	} else if(name == 'D'){					//Blonde
		m_obj.style.left = (referencePoint.x + 141) + "px";		// controls where the dropdown tertiary appears
		m_obj.style.top = (referencePoint.y -2) + "px";			// controls where the dropdown tertiary appears
	} else if(name == 'E'){					//Brunette
		m_obj.style.left = (referencePoint.x + 141) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'F'){					//Black
		m_obj.style.left = (referencePoint.x + 141) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'G'){					//Red
		m_obj.style.left = (referencePoint.x + 141) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'H'){					//Highlights
		m_obj.style.left = (referencePoint.x + 141) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'I'){					//Relaxed
		m_obj.style.left = (referencePoint.x + 174) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'J'){					//Fine
		m_obj.style.left = (referencePoint.x + 174) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'K'){					//Curly
		m_obj.style.left = (referencePoint.x + 174) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'L'){					//Coarse
		m_obj.style.left = (referencePoint.x + 174) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'M'){					//Gray
		m_obj.style.left = (referencePoint.x + 174) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'N'){					//Chemically treated
		m_obj.style.left = (referencePoint.x + 174) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'O'){					//Beginner
		m_obj.style.left = (referencePoint.x + 148) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	} else if(name == 'P'){					//Experienced
		m_obj.style.left = (referencePoint.x + 148) + "px";
 		m_obj.style.top = (referencePoint.y -2) + "px";
	}
	m_obj.style.visibility = "visible";
}

function processSecondaryDropDownIE(dropdown, referenceObj,name) {
	//alert(referenceObj);
	/* positions a dropdown and makes it visible */
	if( (! document.getElementById) || (! initDropDowns) ) {		
		return;
	}
	
	var referencePoint;
	var child;
	
	// position the dropdown and make it visible
	referencePoint = getElementXY( referenceObj );
	m_obj = document.getElementById(dropdown);
	//referenceObj.class=active;
	if(name == 'A'){  						//My Haircolor Goal
		m_obj.style.left = (referencePoint.x + 147) + "px";
 		m_obj.style.top = (referencePoint.y - 1) + "px";
		changeVisibility('secondaryNavA');
		changeVisibility('secondaryNavB');
		changeVisibility('tertiaryNavA');
		changeVisibility('tertiaryNavB');
	} else if(name == 'B'){  				//My Hair Type
		m_obj.style.left = (referencePoint.x + 147) + "px";
 		m_obj.style.top = (referencePoint.y - 1) + "px";
		changeVisibility('secondaryNav');
		changeVisibility('secondaryNavB');
		changeVisibility('tertiaryNav');
		changeVisibility('tertiaryNavB');
	} else if(name == 'C'){					//My Level of Experience
		m_obj.style.left = (referencePoint.x + 147) + "px";
 		m_obj.style.top = (referencePoint.y - 1) + "px";
		changeVisibility('secondaryNavA');
		changeVisibility('secondaryNav');
		changeVisibility('tertiaryNav');
		changeVisibility('tertiaryNavA');
	} else if(name == 'D'){					//Blonde
		m_obj.style.left = (referencePoint.x + 143) + "px";		// controls where the dropdown tertiary appears
		m_obj.style.top = (referencePoint.y - 1) + "px";			// controls where the dropdown tertiary appears
	} else if(name == 'E'){					//Brunette
		m_obj.style.left = (referencePoint.x + 143) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'F'){					//Black
		m_obj.style.left = (referencePoint.x + 143) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'G'){					//Red
		m_obj.style.left = (referencePoint.x + 143) + "px";
 		m_obj.style.top = (referencePoint.y - 1) + "px";
	} else if(name == 'H'){					//Highlights
		m_obj.style.left = (referencePoint.x + 143) + "px";
 		m_obj.style.top = (referencePoint.y - 1) + "px";
	} else if(name == 'I'){					//Relaxed
		m_obj.style.left = (referencePoint.x + 179) + "px";
 		m_obj.style.top = (referencePoint.y - 1) + "px";
	} else if(name == 'J'){					//Fine
		m_obj.style.left = (referencePoint.x + 179) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'K'){					//Curly
		m_obj.style.left = (referencePoint.x + 179) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'L'){					//Coarse
		m_obj.style.left = (referencePoint.x + 179) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'M'){					//Gray
		m_obj.style.left = (referencePoint.x + 179) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'N'){					//Chemically treated
		m_obj.style.left = (referencePoint.x + 179) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'O'){					//Beginner
		m_obj.style.left = (referencePoint.x + 151) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	} else if(name == 'P'){					//Experienced
		m_obj.style.left = (referencePoint.x + 151) + "px";
 		m_obj.style.top = (referencePoint.y  - 1) + "px";
	}
	m_obj.style.visibility = "visible";
}

function tryMe(name){
	changePri = 'Y';
	window.setTimeout('changeVisibility(name)',1000);
}
function showDropDown() {
	this.style.visibility = "visible";
}

function hideDropDown() {
	this.style.visibility = "hidden";
}

var change = "Y";
var changeA = "Y";
var changeB = "Y";
var changeSec = "Y";
var changeSecA = "Y";
var changeSecB = "Y";
var changePri = "Y";

function disappearPri(name){
	if(name=='Y' && change == 'Y'){
		changePri = 'Y';
		//if pri disappears, make sure secondary and tertiary dissapears also
		//window.setTimeout('changeNewVisibility("primaryNav",changePri)',1000);
		//window.setTimeout('changeNewVisibility("tertiaryNav",changePri)',100);
		//window.setTimeout('changeNewVisibility("tertiaryNavA",changePri)',100);
		//window.setTimeout('changeNewVisibility("tertiaryNavB",changePri)',100);
		//window.setTimeout('changeNewVisibility("secondaryNav",changePri)',100);
		//window.setTimeout('changeNewVisibility("secondaryNavA",changePri)',100);
		//window.setTimeout('changeNewVisibility("secondaryNavB",changePri)',100);
	} else {
		changePri='N';
		makeVisible("primaryNav");
	}

}	/*if(name =='Y'){
		changePri = 'Y';
		window.setTimeout('changeNewVisibility("primaryNav",changePri)',1000);
		window.setTimeout('changeNewVisibility("tertiaryNav",changePri)',100);
		window.setTimeout('changeNewVisibility("tertiaryNavA",changePri)',100);
		window.setTimeout('changeNewVisibility("tertiaryNavB",changePri)',100);
		window.setTimeout('changeNewVisibility("secondaryNav",changePri)',100);
		window.setTimeout('changeNewVisibility("secondaryNavA",changePri)',100);
		window.setTimeout('changeNewVisibility("secondaryNavB",changePri)',100);
	} else {
		changePri='N';
		makeVisible("primaryNav");
	}
}*/
function disappear(name){
	if(name=='Y'){
		change = 'Y';
		window.setTimeout('changeNewVisibility("tertiaryNav",change)',1100);
		window.setTimeout('changeNewVisibility("secondaryNav",change)',500);
		//window.setTimeout('changeNewVisibility("primaryNav",change)',500);
	} else {
		change='N';
		changeSec='N';
		makeVisible("tertiaryNav");
		makeVisible("secondaryNav");
		makeVisible("primaryNav");
	}
}

function disappearA(name){
	if(name=='Y'){
		changeA = 'Y';
		window.setTimeout('changeNewVisibility("tertiaryNavA",changeA)',1100);
		window.setTimeout('changeNewVisibility("secondaryNavA",changeA)',500);
		//window.setTimeout('changeNewVisibility("primaryNav",changeA)',500);
	} else {
		changeA='N';
		changeSecA='N';
		makeVisible("tertiaryNavA");
		makeVisible("secondaryNavA");
		makeVisible("primaryNav");
	}
}

function disappearB(name){
	if(name=='Y'){
		changeB = 'Y';
		window.setTimeout('changeNewVisibility("tertiaryNavB",changeB)',1100);
		window.setTimeout('changeNewVisibility("secondaryNavB",changeB)',500);
		//window.setTimeout('changeNewVisibility("primaryNav",changeB)',500);
	} else {
		changeB='N';
		changeSecB='N';
		makeVisible("tertiaryNavB");
		makeVisible("secondaryNavB");
		makeVisible("primaryNav");
	}
}

function disappearSec(name){
	if(name=='Y' && change == 'Y'){
		changeSec = 'Y';
		window.setTimeout('changeNewVisibility("secondaryNav",changeSec)',1100);
		//if sec disappears, make sure tertiary dissapears
		window.setTimeout('changeNewVisibility("tertiaryNav",changeSec)',500);
		//window.setTimeout('changeNewVisibility("primaryNav",changeSec)',500);
	} else {
		changeSec='N';
		makeVisible("secondaryNav");
		//makeVisible("tertiaryNav");
		makeVisible("primaryNav");
		disappearPri('N');
	}
}

function disappearSecA(name){
	if(name=='Y' && changeA == 'Y'){
		changeSecA = 'Y';
		window.setTimeout('changeNewVisibility("secondaryNavA",changeSecA)',1100);
		//if sec disappears, make sure tertiary dissapears
		window.setTimeout('changeNewVisibility("tertiaryNavA",changeSecA)',1100);
		//window.setTimeout('changeNewVisibility("primaryNav",changeSecA)',1100);
	} else {
		changeSecA='N';
		//makeVisible("tertiaryNavA");
		makeVisible("secondaryNavA");
		makeVisible("primaryNav");
	}
}

function disappearSecB(name){
	if(name=='Y' && changeB == 'Y'){
		changeSecB = 'Y';
		window.setTimeout('changeNewVisibility("secondaryNavB",changeSecB)',1100);
		//if sec disappears, make sure tertiary dissapears
		window.setTimeout('changeNewVisibility("tertiaryNavB",changeSecB)',1100);
		//window.setTimeout('changeNewVisibility("primaryNav",changeSecB)',1100);
	} else {
		changeSecB='N';
		//makeVisible("tertiaryNavB");
		makeVisible("secondaryNavB");
		makeVisible("primaryNav");
	}
}

function changeNewVisibility(obj,val) {
	if(val == 'Y'){
		var elm = document.getElementById(obj);
		elm.style.visibility = "hidden";
	}
}

function changeVisibility(obj) {
	var elm = document.getElementById(obj);
	elm.style.visibility = "hidden";
}

function makeVisible(obj) {
	var elm = document.getElementById(obj);
	
	elm.style.visibility = "visible";
}

oHTMLWin = null;

function centerWindow(url, name, w, h, scroll, menu, resizable)
{
	if (window.screen)
	{
		var chasm = screen.availWidth;
		var mount = screen.availHeight;
		
		winprops = 'width=' + w + ',height=' + h + ',left=' + ((chasm - w - 10) * .5) + ',top=' + ((mount - h - 30) * .5) + ',scrollbars=' + scroll + ',menubar=' + menu + ',resizable=' + resizable;
		
		oHTMLWin = window.open(url, name, winprops);
		oHTMLWin.window.focus();
	}
}


function popup(page) 
{
	centerWindow(page, "popup911", 500, 449, "no", "no", "no");
}


function opennpca()
{
	var url="/popups/npca.jsp";
	centerWindow(url, "popupnpca", 500, 503, "no", "no", "no");
}

function specials()
{
	var url="/popups/cseoffer.jsp";
	centerWindow(url, "spcls", 350, 331, "no", "no", "no");
}

function coppaerror()
{
	var url="/popups/CoppaError.html";
	centerWindow(url, "coppa", 300, 200, "no", "no", "no");
}
function opanelcoppaerror()
{
	var url="/popups/opanelCoppaError.html";
	centerWindow(url, "coppa", 300, 200, "no", "no", "no");
}
function Under18error()
{
	var url="/popups/Under18Error.html";
	centerWindow(url, "coppa", 300, 200, "no", "no", "no");
}

function shadechart()
{
	var url="/brand/niceneasy/chart/shade.jsp";
	centerWindow(url, "shadechart", 617, 600, "yes", "yes", "yes");
}

function openWnd(url, width, height, scroll, menu, resizeable){
	centerWindow(url, "popupWnd", width, height, scroll, menu, resizeable);
}
