/* ------------------------------------------------------------------
global.js 
www.revlon-japan.com / Global JS
Last updated: 	03/01/2007
------------------------------------------------------------------ */

var jsFolder = "common/js/";
var getJsFile = ["showFlash","img_swap","topnavi_write","Fixpng","copyright","PullDownMenu","ChangeColor","jquery","jquerypngfix"]
//"prototype","MochiKit",

//gnavi Show/Hidden Tag
var hiddenTargetTag = "ul";
//gnavi Target ID
var foundIDs = ["bt-catalog","bt-featured","bt-information"]



/* ------------------------------------------------------------------
onload
------------------------------------------------------------------ */
function onloadSet(){
	PDMOnload();
	correctPNG();
}


/* ------------------------------------------------------------------
init
------------------------------------------------------------------ */
var nowPage = document.location.href;
var level = "";
var sitelevel = "";                                                  //WebSite Depth
var siloName = "";                                                   //WebSite CategoryName
var sub_category = '';                                               //WebSite SubCategory


/* ------------------------------------------------------------------
URL Default Setting
------------------------------------------------------------------ */
sitelevel_absolute = "http:" + "//" + location.host + "/";
sitelevel_absolute_ssl = "https:" + "//" + location.host + "/";


/* ------------------------------------------------------------------
sitelevel
------------------------------------------------------------------ */
//SitelevelNew
function getSiteLevel(){
	var hereFolder = location.pathname;
	var SlashCount = hereFolder.match(/[/]/g);

	level = SlashCount.length;

	if (level == 1) {sitelevel = "./";}                    // [Top]for Revlon Japan Home Page
	else if (level == 2) {sitelevel = "../";}              // [2nd Depth] for category top page
	else if (level == 3) {sitelevel = "../../";}           // [3rd Depth]
	else if (level == 4) {sitelevel = "../../../";}        // [4th Depth]
	else if (level == 5) {sitelevel = "../../../../";}     // [5th Depth]
	else if (level == 6) {sitelevel = "../../../../../";}  // [6th Depth]

	if (level == 12) {sitelevel = "../../";}  // [6th Depth] for recruiting pages
}


/* ------------------------------------------------------------------
getCategory
------------------------------------------------------------------ */
function getCategory(){
	var here = nowPage;

	if (here.indexOf("/catalog/") != -1){
		siloName = "catalog";
		if (here.indexOf("/lips/") != -1){
			sub_category = "lips";
		}else if (here.indexOf("/face/") != -1){
			sub_category = "face";
		}else if (here.indexOf("/nail/") != -1){
			sub_category = "nail";
		}else if (here.indexOf("/eye/") != -1){
			sub_category = "eye";
		}else if (here.indexOf("/fragrance/") != -1){
			sub_category = "fragrance";
		}else if (here.indexOf("/accessories/") != -1){
			sub_category = "accessories";
		}else if (here.indexOf("/othes/") != -1){
			sub_category = "othes";
		}
	}else if (here.indexOf("/featured/") != -1){
		siloName = "featured";
		if (here.indexOf("/skinlights/") != -1){
			sub_category = "skinlights";
		}else if (here.indexOf("/colorstay/") != -1){
			sub_category = "colorstay";
		}else if (here.indexOf("/speed_shine/") != -1){
			sub_category = "speed_shine";
		}else if (here.indexOf("/perfect10/") != -1){
			sub_category = "perfect10";
		}else if (here.indexOf("/lipglide/") != -1){
			sub_category = "lipglide";
		}else if (here.indexOf("/moistureshine/") != -1){
			sub_category = "moistureshine";
		}else if (here.indexOf("/colorstay_mineral/") != -1){
			sub_category = "colorstay_mineral";
		}else if (here.indexOf("/beyond_natural/") != -1){
			sub_category = "beyond_natural";
		}else if (here.indexOf("/age_defying/") != -1){
			sub_category = "agedefying";
		}else if (here.indexOf("/age_defying_spa/") != -1){
			sub_category = "agedefying_spa";
		}else if (here.indexOf("/photoready/") != -1){
			sub_category = "photoready";
		}
	}else if (here.indexOf("/letter/") != -1){
		siloName = "letter";
		
	}else if (here.indexOf("/information/") != -1){
		siloName = "information";
		if (here.indexOf("/shops/") != -1){	
			sub_category = "shops";
		}
		if (here.indexOf("/about_us") != -1){	
			sub_category = "about_us";
		}
		if (here.indexOf("/about_us") != -1){	
		sub_category = "about_us";
		}
		if (here.indexOf("/history_research") != -1){	
		sub_category = "history";
		}
		if (here.indexOf("/face_of_revlon") != -1){	
		sub_category = "face_of_revlon";
		}
		if (here.indexOf("/around_the_world") != -1){	
		sub_category = "world";
		}
		if (here.indexOf("/sitemap") != -1){	
		sub_category = "sitemap";
		}
	}else if (here.indexOf("/contact/") != -1){
		siloName = "contact";

	}else if (here.indexOf("/promortion/") != -1){
		siloName = "promortion";

	}else if (here.indexOf("/lec/") != -1){
		siloName = "lec";

	}else siloName = "kanri";
}

/* ------------------------------------------------------------------
getCSS
------------------------------------------------------------------ */
function getCSS() {

var myDIV = document.getElementsByTagName("html")[0].lang;

//alert(myDIV);

if(myDIV != "ja"){
	document.writeln ('<link rel="stylesheet" type="text/css" href="' + sitelevel + 'common/css/global_old.css">');

	if (sub_category == "shops"){
			document.writeln ('<link rel="stylesheet" type="text/css" href="' + sitelevel + 'common/css/shops.css">');
	}

}else{
	document.writeln ('<link rel="stylesheet" type="text/css" href="' + sitelevel + 'common/css/global.css" />');

	var here = nowPage;
	if (level == 1){
//		document.writeln ('<link rel="stylesheet" type="text/css" href="' + sitelevel + 'common/css/global.css" />');
		document.writeln ('<link rel="stylesheet" type="text/css" href="' + sitelevel + 'common/css/top.css" />');
	}
}






}


/* ------------------------------------------------------------------
getJS
------------------------------------------------------------------ */
function getJS(){
	var j = getJsFile.length;
	for(i=0; i<j; i++){
		document.writeln ('<script language="JavaScript" src="' + sitelevel + jsFolder + 'lib/' + getJsFile[i] + '.js" type="text/javascript"></script>');
	}
}





/* ------------------------------------------------------------------
PrivacyPopUp
------------------------------------------------------------------ */
function PrivacyPopUp() {
	var varPopLeft = (screen.availWidth / 2) - 200;
	var varPopTop = (screen.availHeight / 2) - 175;
	window.open("privacy_policy/privacy_policy.html","privacy_policy","top=" + varPopTop + ",left=" + varPopLeft + ",width=400,height=350,location=no,toolbar=no,scrollbars=yes");
}


/* ------------------------------------------------------------------
Terms_of_UsePopUp
------------------------------------------------------------------ */
function Terms_of_UsePopUp() {
	var varPopLeft = (screen.availWidth / 2) - 200;
	var varPopTop = (screen.availHeight / 2) - 175;
	window.open("terms_of_use/terms_of_use.html","terms_of_use","top=" + varPopTop + ",left=" + varPopLeft + ",width=400,height=350,location=no,toolbar=no,scrollbars=yes");
}






































/* ------------------------------------------------------------------
UnderCode Use TablesPage
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
getmainDivLeft
------------------------------------------------------------------ */
function getmainDivLeft(){
	document.write ('<script language="javascript">');
	document.write ('if (document.all) {');
	document.write ('	winHeight = document.body.clientHeight;');
	document.write ('	winWidth = document.body.clientWidth;');
	document.write ('}else {');
	document.write ('	winHeight = window.innerHeight;');
	document.write ('	winWidth = window.innerWidth;');
	document.write ('}');
	document.write ('	mainDivLeft = (winWidth / 2) - 360;');
	document.write ('</SCRIPT>');
	document.write ('<div id="main" style="position:absolute; top:5; left:' + mainDivLeft + ' ; z-index:10; visibility:visible;">');

	if( (document.layers) && (level != 1)){
		menu_for_nn4();
	}

 window.onload = function(){
//Back Transparent Img Resize
	var bgHeight = document.getElementById("main").offsetHeight;
	var bgimg = document.getElementsByTagName("table")[0].getElementsByTagName("td")[1].getElementsByTagName("img")[0];
	bgimg.setAttribute("height", bgHeight);
}

}




/* ------------------------------------------------------------------
changeIMG
------------------------------------------------------------------ */
function changeIMG(img_name,img_file){
var img_on = new Image();
img_on.src = sitelevel + img_file;	
	if(document.layers){
       eval("document.main.document." + img_name + ".src = img_on.src");
	}else if(document.all){
       eval("document." + img_name + ".src = img_on.src");
	}else if(document.images){
       eval("document." + img_name + ".src = img_on.src");
	}
}




/* ------------------------------------------------------------------
catalogMenuSelect
------------------------------------------------------------------ */
function catalogMenuSelect(){

	var MENU_BOX = document.getElementById('catalog_menu');
	var isIE = (document.documentElement.getAttribute("style") ==
            document.documentElement.style);

	if(MENU_BOX == null){
		return;
	}else{
		var path = location.pathname.split('/');
		var pageName = path[path.length-1];

		var MENU_BOX_li = MENU_BOX.getElementsByTagName('li');

		for(i=0; i <= MENU_BOX_li.length-1; i++){
			//Nowpage is LinkAncher
			if(MENU_BOX_li[i].getElementsByTagName('a')[0] == nowPage){
				//IE or OtherBrowser
				if(!isIE){
					//OtherBrowser
					MENU_BOX_li[i].getElementsByTagName('a')[0].parentNode.setAttribute("style", "background-image: url('/common/images/lnav/lnav_bt_tri_b.gif')");
				}else{
					//IE
					MENU_BOX_li[i].getElementsByTagName('a')[0].parentNode.style.cssText = "background-image: url('/common/images/lnav/lnav_bt_tri_b.gif')";
				}
				//a Tag Text => li Tag
				MENU_BOX_li[i].innerHTML = MENU_BOX_li[i].getElementsByTagName('a')[0].innerHTML;
				return;
			};
		};
	};

};