// JavaScript Document
var ns4, ie4, ie5, moz;
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
ie5 = (document.getElementByID && document.all)? true:false;
moz = (document.getElementById)?true:false;

function layerWrite_hdr(id,nestref,text) {
	if (ie4) {
		if (document.all[id]) document.all[id].innerHTML = text;
	} else {
		if (moz) {
			if (document.getElementById(id)) document.getElementById(id).innerHTML = text;
		} else {
			if (ns4) {
				var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
				lyr.open();
				lyr.write(text);
				lyr.close();
			}
		}
	}
}

function Subtitle(sTitleImg, sCategory) {
	//alert(sTitleImg + " " +sCategory + " ");
	sStuffToWrite = "";
	if (sCategory != "") {
		sStuffToWrite = "<span class='font_11_blue' style='position: relative; top: 13px; float: right'><b>E-Shirt Category:</b> "+ sCategory +"</span>";
	}
	sStuffToWrite = sStuffToWrite + "<img src='"+ sTitleImg +"' height='22' style='position: absolute; top: 8px;'/><br><hr>";
	layerWrite_hdr("categoryheader",'',sStuffToWrite);
}

function WriteLeftMenu(sStoreList, sURLList) {
	var cookval = readCookie('username');
	bLogged = false;
	if (cookval) bLogged = true;
	document.body.style.backgroundImage="url(images/ver2/spanner2.gif)";
	document.body.style.backgroundPosition="left";
	document.body.style.backgroundRepeat="repeat-y";
	document.body.style.backgroundColor="#FFFFFF";
	var aStoreList = sStoreList.split("~");
	var aURLList = sURLList.split("~");
	sLeftMenu = "";
	if (bLogged) {
		sLeftMenu = "<span class='leftmenu1'><ul><span class='font_11_blk_bold'><li><a href='http://e-shirt.com/affiliate/StoreOwnerHomepage.php' title='STORE OWNER HOME'>STORE HOMEPAGE</a></li>";
		sLeftMenu = sLeftMenu + "<li><a href='http://e-shirt.com/affiliate/ManageStores.php' title='STORES'>STORES</a></li></span>";
		
		nGrowthFactor = 185 + (20*aStoreList.length);
	
		if (document.getElementById) {
			document.getElementById("leftbar").style.height=nGrowthFactor+"px";
			document.getElementById("rightbar").style.height=nGrowthFactor+"px";
			document.getElementById("leftmenucontent").style.height=nGrowthFactor+"px";
		}
		if (aStoreList.length > 0) sLeftMenu = sLeftMenu + "<span class='font_11_blk'><span class='leftmenu2'><ul>";
		for (nI=0; nI<aStoreList.length; nI++) {
			var nMaxTitleLen = 32;
			sVisibleName = aStoreList[nI].replace("&apos;","'");
			sVisibleName = sVisibleName.replace("&quot;","\"");
			sVisibleName = sVisibleName.replace("&amp;","&");
			sURL = "http://www.e-shirt.com/Affiliate/ManageStores.php?storeid="+aURLList[nI];
			if (sVisibleName.length > nMaxTitleLen) sVisibleName = sVisibleName.substr(0,nMaxTitleLen-3) + "...";
			sLeftMenu = sLeftMenu + "<li style='margin: 0px 0px 0px 0px; padding:0px;'><a href='"+ sURL +"' title='"+ aStoreList[nI] +"'>"+ sVisibleName +"</a></li>";
		}
		if (nI > 0)	sLeftMenu = sLeftMenu + "</ul></span>";
		sLeftMenu = sLeftMenu + "<span class='font_11_blk_bold'><li><a href='http://e-shirt.com/affiliate/StoreOwnerHomepage.php' title='DESIGN STUDIO TOOL'>DS TOOL</a></li>";
		sLeftMenu = sLeftMenu + "<li><a href='http://e-shirt.com/affiliate/Reports.php' title='REPORTS'>REPORTS</a></li>";
		sLeftMenu = sLeftMenu + "<li><a href='http://e-shirt.com/affiliate/ProfileEditor.php?mode=Modify' title='EDIT PROFILE'>EDIT PROFILE</a></li>";
		sLeftMenu = sLeftMenu + "<li><a href='http://e-shirt.com/affiliate/FAQs.php' title='FAQs'>FAQs</a></li>";
		sLeftMenu = sLeftMenu + "<li><a href='http://e-shirt.com/affiliate/MoreServices.php' title='MORE SERVICES'>MORE SERVICES</a></li>";
		sLeftMenu = sLeftMenu + "<li><a href='http://www.e-shirt.com/Affiliate/signout.php' title='LOGOUT'>LOGOUT</a></li></span></ul></span><br>";
	} else {	//bLogged
		sLeftMenu = "<span class='leftmenu1'><ul><span class='font_11_blk_bold'><li><a href='http://e-shirt.com' title='E-SHIRT CATALOG'>E-SHIRT CATALOG</a></li>";
		sLeftMenu = sLeftMenu + "<br><li><a href='http://e-shirt.com/affiliate/ProfileEditor.php' title='NEW ACCOUNT'>NEW ACCOUNT</a></li>";
		sLeftMenu = sLeftMenu + "<br><li><a href='http://e-shirt.com/affiliate/Login.php' title='LOGIN'>LOGIN</a></li>";
		sLeftMenu = sLeftMenu + "<br><li><a href='http://e-shirt.com/affiliate/forgotpass.php' title='LOST PASSWORD'>LOST PASSWORD</a></li>";
		sLeftMenu = sLeftMenu + "<br><li><a href='http://e-shirt.com/affiliate/FAQs.php' title='FAQs'>FAQs</a></li>";
		sLeftMenu = sLeftMenu + "</span></ul></span><br>";

	}

layerWrite_hdr("leftmenucontent",'',sLeftMenu);
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
