// JavaScript Document

function ishttps(){
	return location.protocol;	
}
 function realNav(where){
	var a = window.location.toString().split("#");
	window.location = a[0] +'#page='+where;
}
function navLoader(){
	var a=window.location.toString().toLowerCase().split("page=");
	if(a[1])
		content.location=a[1];
	else
		content.location="i.php";
}
function addToBag(who){
	var flashMovie=document.getElementById("bag");
	flashMovie.SetVariable("strType", who);
}
function setLogin(v){
	if(v){
		document.getElementById('login_btn').style.display = "block";
		document.getElementById('logout_btn').style.display = "none";
	}else{
		document.getElementById('login_btn').style.display = "none";
		document.getElementById('logout_btn').style.display = "block";
	}
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
	{ 
	c_start=c_start + c_name.length+1; 
	c_end=document.cookie.indexOf(";",c_start);
	if (c_end==-1) c_end=document.cookie.length;
	return unescape(document.cookie.substring(c_start,c_end));
	} 
  }
return "";
}

function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

if( isdefined("site_http_url")) {
	img_outofstock = new Image(); 
	img_outofstock.src = site_http_url+skin_images+"/buttons/sm_outofstock.gif";
	
	img_notavailable = new Image(); 
	img_notavailable.src = site_http_url+skin_images+"/buttons/sm_notavailable.gif";

}

function gebi(w){
	return document.getElementById(w);	
}
// check product availability
function cpa(){
	if(gebi('select_COLOR')){
		var color = gebi('select_COLOR').value;
		var size = gebi('select_SIZE').value;
		var pid = gebi('product_name').value;
		var obj= (pid+size+color);
	}else{
		return false;	
	}
	gebi('addToBagImg').disabled = true;
	if(avids[obj]>-9998){
		gebi('stockError2').style.display = 'none';
		gebi('addToBagImg').disabled = false;
		if(avids[obj]<1){
			gebi('addToBagImg').src =img_outofstock.src;
			gebi('stockError').style.display = 'block';
		}else{
			gebi('addToBagImg').src =site_http_url+skin_images+"/buttons/sm_addtocart.gif";
			gebi('stockError').style.display = 'none';
		}
	}else{
		gebi('addToBagImg').src =img_notavailable.src;
		gebi('stockError').style.display = 'none';
		gebi('stockError2').style.display = 'block';
	}
	
}
function swapMC(w){
	if(w=='2'){
		window.parent.document.getElementById('mContainer').style.display='block';
		window.parent.document.getElementById('mp3Player').style.marginLeft = "135px";
	}if(w=="1"){
		window.parent.document.getElementById('mContainer').style.display='none';
		window.parent.document.getElementById('mp3Player').style.marginLeft = "0px";
	}
		
}
function n(w,t){
	if(t){
		w.src = w.src.split('off').join('on');
		var m = (w.src.indexOf('nav3')>11)?'block':'none';
		looksmenu = (m=='block')?w:null;
		document.getElementById('looks_mnu').style.display = m;
	}else{
		w.src = w.src.split('on').join('off');
	}
}
var smo = false;
var looksmenu=null;
function sm(w,t){
	if(t){
		if(smo) return false;
		smo = true;
		w.style.display='block';
		if(looksmenu)
			looksmenu.src = looksmenu.src.split('off').join('on');
	}else{
		if(!smo) return false;
		smo=false;
		setTimeout( function(){
			if(smo==false){
				w.style.display='none';
				if(looksmenu)
					looksmenu.src = looksmenu.src.split('on').join('off');
			}
							 },500);
	}
}

// LINK HANDLING
function handlelinks(who,isdirect){
	
	if(isdirect=="2")
		dest = who;
	else
		dest = document.getElementById('jnjlink'+who).title;
			
	if (window.frameElement) {
		window.parent.content.location = dest;
	}else{
		window.content.location = dest;
	}
}

function handleAllLinks(){
	var mozilla=document.getElementById && !document.all
	var ie=document.all
	var contextisvisible=0
	
	var atags = document.getElementsByTagName("a");
	
	for(i=0; i <atags.length; i++)
	{
		// remove the HREF tags and insert DESTINATION tags
		atags[i].setAttribute("title",atags[i].href);
		atags[i].setAttribute("onclick",new Function("handlelinks('"+i+"',false)") );
		atags[i].setAttribute("id","jnjlink"+i);
		atags[i].removeAttribute('href');
		
		// change the function of A onClick
		if(mozilla){
			atags[i].addEventListener("click", new Function("handlelinks('"+i+"',false)") , true);
		}else if (ie){ 
			atags[i].attachEvent("onclick",new Function("handlelinks('"+i+"',false)") );
		}
	}
}