//watermark update
var watermarks = new Array();
function watermarkThis(obj)
{
	watermarkThis(obj,'');
}
function watermarkThis(obj, frmID) {
	var index = watermarks.length;
	watermarks.push({id:obj.id, text:obj.value, orgState: obj.className, frmID: frmID});
	if (frmID != '')
		document.getElementById(frmID).onsubmit = function(){return validateWatermark(index);};
	obj.onfocus = function(){ watermarkFocus(obj,index)};
	obj.onblur = function() {watermarkBlur(obj,index)};
}
function watermarkFocus(obj,index) {
	if (obj.value == watermarks[index].text) {
		obj.value = '';
		obj.className = "stateA stateB";
	}
	var frmID = watermarks[index].frmID;
	
}
function watermarkBlur(obj,index) {
	if (obj.value == '') {
		obj.value = watermarks[index].text;
		obj.className = watermarks[index].orgState;
	}
	var frmID = watermarks[index].frmID;
}

function validateWatermark(index)
{
	var watermark = watermarks[index];
	var val = document.getElementById(watermark.id).value;
	return val != '' && val != watermark.text;
}

//create list page sub cat nav
var isChild = false;

function loadCurCat() {
	document.getElementById("cat--999").href = "/?cmd=sb-list&id=-999&srt=3";
	if(catID == 0) //is search
	{
		document.getElementById("parentCat").innerHTML = "Search<div class=\"edge\"></div>";
		document.getElementById("childCat").innerHTML = catDesc;
		return;
	}
	subCatLink = document.getElementById("sCat-" + catID);
	subCatCont = document.getElementById("cat-" + catID + "-subList");		
	if (subCatLink) {
		subCatParent = subCatLink.parentNode;
		var parentCat = 1;
		parentCat = subCatParent.id.substring(4, subCatParent.id.length - 8).replace('-subList','');
		subCatCont = document.getElementById("cat-" + parentCat  + "-subList");	
		isChild = true;
		subCatLink.className = "navSelected";
		parentCatID  = document.getElementById("cat-" + parentCat);
		document.getElementById("parentCat").innerHTML = "<a href=\"?cmd=sb-list&id=" + parentCat + "\">" + parentCatID.innerHTML + "</a><div class=\"edge\"></div>";	
		document.getElementById("childCat").innerHTML = catDesc;
		loadParentSubCats(subCatCont,parentCat);
	} else {
		document.getElementById("parentCat").innerHTML = document.getElementById('cat-' + catID).innerHTML + "<div class=\"edge\"></div>";	
		if (subCatCont) {
			loadSubCats();	
		}	
	} 
}
function loadSubCats() {
	var subCatCont = document.getElementById("cat-" + catID + "-subList");	
	document.getElementById("subCatsNav").style.display = "";
	document.getElementById("subCatsNav").innerHTML = "	<div class=\"title\">IN THIS CATEGORY:</div>" + 
		"<a id=\"featuredCatItems\" href=\"?cmd=sb-list&id=" + catID + "\">All</a>" +
		subCatCont.innerHTML + "<div class=\"navBtm\"></div>";						
	document.getElementById("subCatsNav").style.display = "";
	document.getElementById("featuredCatItems").className = "navSelected";
}
function loadParentSubCats(elm, parentID) {
	
	document.getElementById("subCatsNav").style.display = "";
	document.getElementById("subCatsNav").innerHTML = "	<div class=\"title\">IN THIS CATEGORY:</div>" + 
		"<a id=\"featuredCatItems\" href=\"?cmd=sb-list&id=" + parentID + "\">All</a>" +
		elm.innerHTML + "<div class=\"navBtm\"></div>";
	var leftNav = document.getElementById("subCatsNav");
	
	for (var i = 0; i < leftNav.childNodes.length; i++)
	{
		if (leftNav.childNodes[i].id == "sCat-" + catID)
		{
			leftNav.childNodes[i].className = "highlight1 slct";
			break;
		}
	}
//	document.getElementById("sCat-" + catID).className = "highlight1";
	document.getElementById("subCatsNav").style.display = "";
	document.getElementById("featuredCatItems").className = "navSelected";
}
//select box
function showDrop(a,e) {
	curSelectBoxID = a.parentNode.id;
	curSelectBox = a;
	options = a.nextSibling;
	while (options.nodeName !="DIV") {
		options = options.nextSibling
	}
	masterWidth = a.clientWidth;
	if (options.style.display == "" || options.style.display == "none") {
		curMode = "block";
	} else {
		curMode = "";
	}
	options.style.display = curMode;
	//options.style.width = masterWidth + 26 + "px";
	cancelBubbleEvent(e);
}
function slctOpt(b) {
	alert(b.getAttribute("optionValue"));
	document.getElementById(curSelectBoxID).value = b.innerHTML;
	options.style.display = "";
	curSelectBox.innerHTML = b.innerHTML;
}
function closeDropDown() {
	document.getElementById("contVarDrp").style.display = "none";
}

//popUp system
function launchStPop(i,m,mc,b) {
	var stPop = document.getElementById("stPop");
	var stPopHeight = stPop.offsetHeight;
	var ico = document.getElementById("stPopIco");
	var title = document.getElementById("stPopTitle");
	msg = document.getElementById("stPopBody");
	stPop.style.marginTop = "-" + (stPopHeight / 2) + "px";
	stPop.style.left = "50%";
	ico.style.backgroundImage = "url('/content/skin-02/images/st" + i + ".jpg')";
	title.innerHTML = m;
	title.className = mc;
	msg.innerHTML = b;
	//document.write(b);
}
function closeMe(ele) {
	document.getElementById(ele).style.left = "-999px";
}
function showMe(ele) {
	document.getElementById(ele).style.left = "-999px";
}
function cancelBubbleEvents(e) {
    var e = e || window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}

function showLoginBox(invalid) {
	if (invalid) {
		document.getElementById("loginPop").style.height = "50%";		
		document.getElementById("loginPop").style.top = "109px";		
	} else {
		showLoginPop();
	}
}
function showLoginPop() {
	$("#loginPop").animate({height: $(window).height() / 2, top: '109px'},500,function(){$("#emailAddress").focus()});
}
function closeLoginPop() {
	if (!isDiaologLogin) {
		$("#loginPop").animate({height: '0', top: '0'},500);
	}
	else if (closeLoginAction == 1) {
		hideDiaologLogin();
	}
	else {
		location.href = closeLoginAction;
	}
}

function scroll2TopNonIe() {
    var msie = ((navigator.appVersion.indexOf("MSIE")!= -1)&&!window.opera)? true : false;
    if (! msie) {
        scroll(0,0);
    }
}
function showDiaologLogin(title, cancelUrl) {
    document.getElementById("fadeCover").style.display = "block";
	boxTitle = document.getElementById("loginTitle");
	boxTitle.innerHTML = title;
	boxTitle.style.display = "";
    popupObj = document.getElementById("loginPop");
    popupObj.style.height = "50%";
    popupObj.style.display = "block";
	if (cancelUrl == 0) {
		document.getElementById("btnCancelLogin1").style.display = "none";
		document.getElementById("btnCancelLogin2").style.display = "none";
	}
	closeLoginAction = cancelUrl;
	isDiaologLogin = true;
	//initFB();	
}
function hideDiaologLogin() {
    popupLogin = document.getElementById("loginPop");
    popupLogin.style.display = "none";
    popupObj.style.height = "";
	document.getElementById("loginTitle").style.display = "none";
    document.getElementById("fadeCover").style.display = "none";
}
var isSwagstore30 = true;
var isDiaologLogin = false;


//end login pop


