var rightCaret = String.fromCharCode (62);
var heightSet = false;

function moveNextProdImage(imgs){
	if (!heightSet){
		figureHeight(3);
		heightSet = true
	}
	var showBoxID = 0; 
	var imgBox = document.getElementById("imgHolder0");
	if (imgBox.style.display=="block"){
		imgBox.style.display="none";
		document.getElementById("imgHolder1").style.display="block";
	}
	else{
		for (var n=1; n<imgs+1; n++){
			imgBox = document.getElementById("imgHolder"+n);
			if (imgBox.style.display=="block"){
				showBoxID = n;
			}
		}
		document.getElementById("imgHolder"+showBoxID).style.display="none"
		showBoxID++;
		if (showBoxID >imgs) showBoxID=0;
		document.getElementById("imgHolder"+showBoxID).style.display="block"
	}
				
}


function movePrevProdImage(imgs){
	if (!heightSet){
		figureHeight(3);
		heightSet = true
	}
	for (var n=0; n<imgs+1; n++){
			imgBox = document.getElementById("imgHolder"+n);
			if (imgBox.style.display=="block"){
				showBoxID = n;
			}
		}
		document.getElementById("imgHolder"+showBoxID).style.display="none"
		showBoxID--;
		if (showBoxID<0) showBoxID=imgs;
		document.getElementById("imgHolder"+showBoxID).style.display="block"
}

function figureHeight(imgs){
try{
	var maxHeight = document.getElementById("img0").height;
	var maxWidth = document.getElementById("img0").width;
	var nextHeight = 0;
	var nextWidth = 0;
	for (var n=1; n<imgs-1; n++){
		document.getElementById("imgHolder"+n).style.display="block";
		nextHeight = document.getElementById("img"+n).height;
		nextWidth = document.getElementById("img"+n).width;
		document.getElementById("imgHolder"+n).style.display="none";
		if (nextHeight>maxHeight)
			maxHeight = nextHeight;
		if (nextWidth>maxWidth)
			maxWidth = nextWidth;
	}
	maxHeight = maxHeight+50;
	maxWidth=maxWidth+50;
	document.getElementById("imgList").style.height=maxHeight;
	document.getElementById("imgList").style.width=maxWidth;
}
catch(e){}
	
}



function changeTab(tabID){
		var tabBoxName = "";
		var tabName
		for (var n=1; n<6; n++){
		try{
			tabBoxName = eval("tabBox"+n);
			tabName = eval("tab"+n);
			document.getElementById("tabBox"+n).style.display="none";
			document.getElementById("tab"+n).className="tab";
		}
		catch(e){}
		}
		
		document.getElementById("tab"+tabID).className="tab activeTab";
		document.getElementById("tabBox"+tabID).style.display="block";
	}
	
function openWin( windowURL, windowName, windowFeatures )
{return window.open( windowURL, windowName, windowFeatures );}
 
function SubmitRec(frm){frm.submit();}


function LaunchImageManager(){
   window.showModalDialog("/admin/imageManager.asp", "select:no", "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:520px;");
}  
function LaunchResourceManager(){ 
   window.showModalDialog("/admin/resourceManager.asp", "select:no", "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:550px;");
}  
function pickImageFile(el){
   var sResult = window.showModalDialog("/admin/imageManager.asp", "value:" + el.value, "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:520px;");
   if (sResult != "cancel") el.value = sResult;
}   
function pickResourceFile(el, dir){
   var args = "value:" + el.value;
   if (dir)
      args += ";root:" + dir;
   var sResult = window.showModalDialog("/admin/resourceManager.asp", args, "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:520px;");
   if (sResult != "cancel") el.value = sResult;
}

function viewFile(el){
   if (el.value != "")
      window.open(el.value);
   else
      alert("Please select a file first.");
}
function clearSetting(el){
   el.value = "";
}		
function checkName(el)
{
	var allowKey = false;
	var keyCode = window.event.keyCode;
	switch (true)
	{
		case (el.value.length >= 50):
			allowKey = false;
			break;
		case (keyCode == 45):
		case ((keyCode >= 48) && (keyCode <= 57)): 
		case ((keyCode >= 65) && (keyCode <= 90)):
		case ((keyCode >= 97) && (keyCode <= 122)):
			allowKey = true;
			break;
		default:
			allowKey = false;
			break;
	}
	window.event.returnValue = allowKey;
}
function checkKey(){
   var e = window.event;
   if (e.keyCode == 13) 
      submitForm();
   e.cancelBubble = true;
}

function displayChildren(divMenu){
	HideMenuCookie()
	var d = document.getElementById(divMenu);
	if (d){
		if (d.className == "clsHiddenMenu") {
			d.className = "clsVisibleMenu";
			SetCookie(divMenu);
		} else {
			d.className = "clsHiddenMenu";
			SetCookie("");   
		}
	}
}
function toggleMenuState(divMenu){
	HideMenuCookie()
	var d = document.getElementById(divMenu);
	if (d){
		if (d.className == "clsHiddenMenu") 
		{
			SetCookie(divMenu);
		} else {
			d.className = "clsHiddenMenu";
			SetCookie("");   
		}
	}
}
     
function SetCookie( cookieName)
{
	if (cookieName.indexOf("subMenu_") == -1)
		cookieName = "subMenu_" + cookieName;
		
    var exp = new Date();
    exp.setTime(exp.getTime() + 2.6784e9);
    document.cookie = "navCookie" + "=" + escape(cookieName) + "; expires=" + exp.toGMTString();	
}


function getCookie(Name) {
 var search = Name + "=";
 if (document.cookie.length>0) {
  offset=document.cookie.indexOf(search);
  if (offset!=-1) {
   offset+=search.length;
   end=document.cookie.indexOf(";",offset);
   if (end==-1) {
    end=document.cookie.length;
   } return unescape(document.cookie.substring(offset,end));
  } else {return ""}
 } else {return ""}
}
function HideMenuCookie(){
    var defCookie = getCookie("navCookie");
    var d = document.getElementById(defCookie);
    if (d){
        d.className = "clsHiddenMenu";
		SetCookie("");
		}
}

