﻿var cal = new CalendarPopup();
var waitImg = "<img class='loadgif' src='img/loading.gif'/>";
var tmpImg = "";
var msgDiv = "msgSpace";
var pageDiv = "PageDiv";
var contentSpace = "contSpace";
var container = "";
var imgArray = new Array();
var thePage = "";
var lang = "GR";

function resizeMainCont()
{  
	elem = container;
	psize = getPageSize();
	pageH = psize[1];
	windH = psize[3];

	var offset = 150;
	if(elem == "mediumTextContentDiv" || elem == "eventContDiv")
		offset = 270;
	try{
		newH = eval(document.getElementById(elem).offsetHeight);
		//alert(newH);
		if(elem == "ptviewTV")
			document.getElementById(pageDiv).style.height = "630px";	
		else if((elem != "mediumTextContentDiv" && newH > 430) || (elem == "mediumTextContentDiv" && newH > 330) || (elem == "eventContDiv" && newH > 320))
		{
			document.getElementById(pageDiv).style.height = newH + offset;	
			//alert(document.getElementById(pageDiv).style.height);
		}	
		else
			document.getElementById(pageDiv).style.height="620px";
		}catch(e){alert(e);}
	window.scrollTo(0,0);	

	if(thePage == "HOME")
	{
		document.getElementById("mainBottomImg").src = "img/mainBottomBg5.png";
		document.getElementById("HomePageMainBottomDiv").style.height="300px";
		document.getElementById(pageDiv).style.height="650px";
	}	
	else
	{
		//document.getElementById(pageDiv).style.height="620px";
		document.getElementById("mainBottomImg").src = "img/mainBottomBg4.png";
		document.getElementById("HomePageMainBottomDiv").style.height="227px";
	}	
	
	document.getElementById("linkpageA").href = "index.html?page="+thePage;
}


function showEvent(id)
{
	t = document.getElementById("eventContDiv");
	trs = t.rows;
	var curdisp = document.getElementById("subTR"+id).style.display;
	
	for (i=0;i<trs.length;i++)
	{
		sid = trs[i].id;
		sidID = sid.substr(4, sid.length - 5);
		if(sid.substr(0,5) == "subTR")
		{
			trs[i].style.display = "none";
		}	
		if(sid.substr(0,2) == "TR")
			trs[i].childNodes[0].className = "eventTitleTD";
	}
	
	document.getElementById("subTR"+id).style.display = curdisp == "none"?"":"none";
	document.getElementById("TR"+id).childNodes[0].className = curdisp == "none"?"eventTitleTDON":"eventTitleTD";
	
	resizeMainCont();
}

function RightMenuOver(i, ONOFF)
{
	if(ONOFF == 1)
	{
		document.getElementById(i+"sidemenuitem").className = "rightMenuArrowON";
		document.getElementById(i+"sidemenutext").className = "rightMenuContentON"
	}
	else
	{
		document.getElementById(i+"sidemenuitem").className = "rightMenuArrow";
		document.getElementById(i+"sidemenutext").className = "rightMenuContent"
	}	
	
}

//main ajax rendering functions
var aj = new GLM.AJAX();

//this func requests an update for all page elements that vary from page to page
function getPage(page)
{
	thePage = page;
	popup(waitImg,1);
	menuSelection();
	
	if(thePage == "APPARELORDER")
	{
		pwd = querySt("pwd");
		un = querySt("un");
		code = querySt("code");
	
		if(code == "ORDERSTATUS")
		{
			qs = "APPARELORDER&code=ORDERSTATUS&pwd="+pwd+"&un="+un;
			page = qs;
		}	
	}	
	
	//getControl(backend class name, callback function, param to send back)
	if(document.getElementById("headerContDiv").innerHTML == "")
		getControl("headerMenu", page);
	getControl("mainContent", page);
	getControl("subMenu", page);
	if(document.getElementById("rightMenuDiv").innerHTML == "")
		getControl("rightMenu", page);
	if(document.getElementById("boxesDiv").innerHTML == "")	
		getControl("box", page);
	if(document.getElementById("homeNewsDiv").innerHTML == "")	
		getControl("homeNews", page);	
		
	if(thePage == "APPAREL")
		getControl("eshopCart", page);
}

function refreshPage(page)
{
	popup(waitImg,1);
	getControl("headerMenu", page);
	getControl("mainContent", page);
	getControl("subMenu", page);
	getControl("rightMenu", page);
	getControl("box", page);
	
	if(page == "APPAREL")
		getControl("eshopCart", page);
	resizeMainCont();
}

function changeLang(lng)
{
	lang = lng
	aj.callPage("index.php", changeLangCallback, "POST", "lang="+lang);
}

function changeLangCallback()
{
	refreshPage("HOME");
}

function getControl(obj, param)
{
	popup(waitImg,1);
	aj.callPage("index.php", eval(obj+"Callback"), "POST", "control="+obj+"&param="+param);
}

function getFunction(func, param)
{
	popup(waitImg,1);
	aj.callPage("index.php", eval(func+"Callback"), "POST", "function="+func+"&param="+param);
}

function getAction(action, qs, method)
{
	popup(waitImg,1);
	if(method=="" || method=="GET")
		aj.callPage("index.php?action="+action+qs, eval(action+"Callback"));
	if(method=="POST")
	{
		q = "";
		if(qs != "")
			q = "&"+qs;
		aj.callPage("index.php", eval(action+"Callback"), "POST", "action="+action + q);
	}
}

function ADDLINKCallback(response)
{
	popup("",0);
	message(response);
	document.getElementById("proposeLink").value = "";
}
function ALLPHOTOSCallback(response)
{
	popup("",0);
	message(response);
}
function PHOTOSBYMONTHCallback(response)
{
	popup("",0);
	message(response);
}
function PHOTOSBYDATECallback(response)
{
	popup("",0);
	try{eval(response);
	}catch(e){message(response)}
}

function GETPANOCallback(response)
{
	popup("",0);
	mainContentCallback(response);
}
function WEEKPHOTOCallback(response)
{	
	showImgFromThumb(response);
}
function NEWPOSTCallback(response)
{
	popup("",0);
	//message(response,1);
	alert(response);
}
function SHOWTOPICCallback(response)
{
	popup("",0);
	fillContent(response,0);
}
function WEEKOFFERCallback(response)
{
	popup("",0);
	message(response);
}
function BONUSGAMECallback(response)
{
	popup("",0);
	getControl("mainContent", "WEEKOFFER");
	message(response);
}	

function UPDATEMEMCallback(response)
{
	popup("",0);
	message(response);
}
function LOGOUTCallback(response)
{	
	popup("",0);
	window.location = "index.html";
}
function LOGINCallback(response)
{
	popup("",0);
	getControl("headerMenu", "HOME");
	getControl("box", "HOME");
}

function LOGIN2Callback(response)
{
	if(response < 0)
	{
		alert("Τα στοιχεία σας δεν έιναι σωστά.");
		return;
	}
	popup("",0);
	getControl("headerMenu", "HOME");
	getControl("box", "HOME");
}

function STAFFCallback(response)
{
	popup("",0);
	document.getElementById("staffInfoDiv").innerHTML = response;
}
function DVDCallback(response)
{
	popup("",0);
	popup(response,1);
}
function TEAMCallback(response)
{
	popup("",0);
	message(response);
}
function AVAILBYMONTHCallback(response)
{
	popup("",0);
	message(response);
}
function AVAILBYDATECallback(response)
{
	popup("",0);
	message(response);
}
function CONTACTFORMCallback(response)
{
	popup("",0);
	message(response);
}

function regok(res)
{
	popup("",0);
	var prefix = res.substr(0, 1);
	
	if(prefix == 1)
	{
		getPage("MEMBER3");
	}
	else
	{
		msg = res.substr(1, res.length - 1);
		message(msg);
	}

}

function REGISTERMEMCallback(response)
{
	regok(response.toString());
}

function checkEmailCallback(response)
{
	popup("",0);
	message(response);
}

function headerMenuCallback(response)
{   
	popup("",0);
	document.getElementById("headerContDiv").innerHTML = response;
	correctPNG();
}

function mainContentCallback(response)
{   
	popup("",0);
	document.getElementById("mainContent").innerHTML = response;
	execRuntimeJS();
	correctPNG();
}

function subMenuCallback(response)
{
	popup("",0);
	document.getElementById("subMenuDiv").innerHTML = response;
	correctPNG();
}

function boxCallback(response)
{
	popup("",0);
	document.getElementById("boxesDiv").innerHTML = response;
	correctPNG();
}

function homeNewsCallback(response)
{
	popup("",0);
	document.getElementById("homeNewsDiv").innerHTML = response;
	correctPNG();
}

function rightMenuCallback(response)
{
	popup("",0);
	document.getElementById("rightMenuDiv").innerHTML = response;
	correctPNG();
}


///////for the page navigation within the textarea element////////////////
function gotoPage(pageName, num, numField, totalField)
{
	total = document.getElementById(totalField).value;
	document.getElementById(numField).value = num;
	
	for(i=0;i<total;i++)
		document.getElementById(pageName+i).style.display = "none";

	
	document.getElementById(pageName+num).style.display = "";
	resizeMainCont();	
}

function navPage(pageName, numField, totalField, where)
{
	num = document.getElementById(numField).value;
	total = document.getElementById(totalField).value;
	
	if(where == "NEXT" && num < total - 1)
		num++;
	if(where == "PREV" && num > 0)
		num--;
	if(num <0 || num > total)
		return;
	document.getElementById(numField).value = num;

	for(i=0;i<total;i++)
		document.getElementById(pageName+i).style.display = "none";
	
	document.getElementById(pageName+num).style.display = "";
	resizeMainCont();	
}
///////////////////////////////////////////////////////////////////////
function  menuItemOver(ON, id)
{
	if(ON == "ON")
	{
		if(document.getElementById("menuMC" + id).getAttribute("code") == thePage)
		{
			document.getElementById("smenuT" + id).className = "submenuTableON";
			return;
		}
		document.getElementById("menuLC" + id).src = "img/headerMenuLeftCornerON.gif";
		document.getElementById("menuRC" + id).src = "img/headerMenuRightCornerON.gif";
		document.getElementById("menuMC" + id).className = "menuItemON";
		document.getElementById("smenuT" + id).className = "submenuTableON";
	}
	else
	{
		subT = document.getElementById("smenuT" + id);
		subC = false;
		for(i=0;i<subT.rows.length;i++)
		{
			if(subT.rows[i].cells[0].getAttribute("code") == thePage)
				subC = true;
		}	
		
		if(document.getElementById("menuMC" + id).getAttribute("code") == thePage || subC == true)
		{
			document.getElementById("smenuT" + id).className = "submenuTableOFF";
			return;
		}
		document.getElementById("menuLC" + id).src = "img/headerMenuLeftCorner.gif";
		document.getElementById("menuRC" + id).src = "img/headerMenuRightCorner.gif";
	    document.getElementById("menuMC" + id).className = "menuItem";
 		document.getElementById("smenuT" + id).className = "submenuTableOFF";
	}
}

function  smenuItemOver(ON, id, pid)
{
	if(ON == "ON")
	{
		document.getElementById("smenuT" + pid).className = "submenuTableON";
		document.getElementById("subMenuMC" + pid + id).className = "smenuItemON";
	}
	else
	{
		if(document.getElementById("subMenuMC" + pid + id).getAttribute("code") == thePage)
		{
			document.getElementById("smenuT" + pid).className = "submenuTableOFF";
			return;
		}
 	    document.getElementById("smenuT" + pid).className = "submenuTableOFF";
		document.getElementById("subMenuMC" + pid + id).className = "smenuItem";
	}
}

function menuSelection()
{
	try{
	mainT = document.getElementById("topmenuTable");	
	k = -1;
	for(i=0;i<mainT.rows[0].cells.length;i++)
	{
		id = mainT.rows[0].cells[i].id;
		
		//deselect all menu items along with their corner images
		if(id.substr(0,6) == "menuMC")
		{
			mainT.rows[0].cells[i].className = "menuItem";
			k++;
		}	
		if(id.substr(0,7) == "menuCoR")
			mainT.rows[0].cells[i].childNodes[0].src = "img/headerMenuRightCorner.gif";
		if(id.substr(0,7) == "menuCoL")
			mainT.rows[0].cells[i].childNodes[0].src = "img/headerMenuLeftCorner.gif";
		
		//select the right one		
		if(mainT.rows[0].cells[i].getAttribute("code") == thePage)
			mainT.rows[0].cells[i].className = "menuItemON";

		if(mainT.rows[0].cells[i].getAttribute("code") == thePage + "R")
			mainT.rows[0].cells[i].childNodes[0].src = "img/headerMenuRightCornerON.gif";
		
		if(mainT.rows[0].cells[i].getAttribute("code") == thePage + "L")
			mainT.rows[0].cells[i].childNodes[0].src = "img/headerMenuLeftCornerON.gif";	
		
		try{
		subT = document.getElementById("smenuT" + k);
		
		for(j=0;j<subT.rows.length;j++)
		{
			subT.rows[j].cells[0].className = "smenuItem";
			if(subT.rows[j].cells[0].getAttribute("code") == thePage)
			{
				subT.rows[j].cells[0].className = "smenuItemON";
				pid = subT.rows[j].cells[0].getAttribute("pid");
				document.getElementById("menuMC" + pid).className = "menuItemON";
				document.getElementById("menuRC" + pid).src = "img/headerMenuRightCornerON.gif";
				document.getElementById("menuLC" + pid).src = "img/headerMenuLeftCornerON.gif";
			}	
		}	
		}catch(e){}
	}	
	}catch(e){}	
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {//alert(document);
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
			//var imgUsemap = (img.usemap)?" usemap='" + img.usemap + "'":"";  
			//alert(img.usemap);
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\');\"></span>" 
            img.outerHTML = strNewHTML;
            i = i-1;
			//if(imgName == "FOOTERCORNERLEFT.PNG")
				//alert(strNewHTML);
         }
      }
   }    
}

function regStep1()
{
	getPage("MEMBER2");
}

function regStep2()
{
	var name  = document.getElementById("theName").value;
	var sname = document.getElementById("theSurname").value;
	var email = document.getElementById("theEmail").value;
	var nick  = document.getElementById("theNick").value;
	var newsletter  = document.getElementById("theNews").checked?"1":"0";;
	var gameInfo   = document.getElementById("theInf").checked?"1":"0";;

	if(name=="" || sname=="" || email=="")
	{
		if(lang == "EN")
			alert("The name, surname and email are mandatory.");
		else
			alert("Το όνομα, επώνυμο και email είναι υποχρεωτικά.");
		return;
	}	
	
	//getFunction("checkEmail",email);
	var qs = "&name="+name+"&surname="+sname+"&email="+email+"&nick="+nick+"&newsletter="+newsletter+"&gameInfo="+gameInfo;
	getAction("REGISTERMEM",qs, "POST");
}

function saveMem()
{
	var email  = document.getElementById("theEmail").value;
	var name  = document.getElementById("theName").value;
	var sname = document.getElementById("theSurname").value;
	var nick  = document.getElementById("theNick").value;
	var newsletter  = document.getElementById("theNews").checked?"1":"0";;
	var gameInfo   = document.getElementById("theInf").checked?"1":"0";;

	if(email == "" || name=="" || sname=="")
	{
		alert("το email, όνομα και επώνυμο είναι υποχρεωτικά");
		return;
	}	
	
	//getFunction("checkEmail",email);
	var qs = "&name="+name+"&surname="+sname+"&nick="+nick+"&newsletter="+newsletter+"&gameInfo="+gameInfo+"&email="+email;
	getAction("UPDATEMEM",qs,"POST");
}

function  showDownloadsTxt(id)
{
	document.getElementById("fTxt").style.display = (id=="1"?"":"none")
	document.getElementById("vTxt").style.display = (id=="2"?"":"none")
	document.getElementById("mTxt").style.display = (id=="3"?"":"none")
	document.getElementById("dTxt").style.display = (id=="4"?"":"none")
	document.getElementById("nill").style.position = "absolute"
	document.getElementById("nill").style.display = (id=="999"?"":"none")
}

function proposeLink()
{
	var thelink = document.getElementById('proposeLink').value;
	getAction("ADDLINK", "link="+thelink, "POST");
}

function contactForm()
{
	var mail = document.getElementById("theEmail").value;
	var mes  = document.getElementById("theMes").value;
	var sec  = document.getElementById("theSec").value;
	
	if(mail == "" || mes== "" || sec == "")
	{
		alert("Ολα τα πεδία είναι υποχρεωτικά");
		return;
	}
	
	var data = "mail="+mail+"&mes="+mes+"&sec="+sec;
	getAction("CONTACTFORM",data,"POST")
}

function message(mes)
{
	try{
		document.getElementById(msgDiv).innerHTML = mes;	
		resizeMainCont();
		}catch(e){alert(mes);}
		
}

function fillContent(cont,append)
{
		try{
		if(append==1)
			document.getElementById(contentSpace).innerHTML = document.getElementById(contentSpace).innerHTML + cont;
		else
			document.getElementById(contentSpace).innerHTML = cont;		
		resizeMainCont();
		}catch(e){alert(e);}
}

function resultsByDate()
{
	date = document.getElementById("dateCriterion").value;
	if(date != "")
		getAction("AVAILBYDATE","date=" + date,"POST");
}

function resultsByMonth(mon)
{
	mon = document.getElementById("monthCriterion").value;
	if(mon != "")
		getAction("AVAILBYMONTH","month=" + mon,"POST");
}

function showCalendar()
{
	cal.select(document.getElementById("dateCriterion"),'reservedAnchor','dd/MM/yyyy'); return false;
}

function showTeamInfo(team, info)
{
	//info is TEXT,ROSTER OR PHOTOS
	getAction("TEAM", "team="+team+"&show="+info, "POST");
}

function overSmallPh(src, onoff, plNo)
{
	if (onoff == 0)
	{
		document.getElementById("centerPLPhoto" + plNo).src = tmpImg;
		src.className='phOFF';		
	}
	else
	{
		tmpImg = document.getElementById("centerPLPhoto" + plNo).src;
		src.className='phON';
		document.getElementById("centerPLPhoto" + plNo).src = src.src;
	}
}

function showPhotos(src)
{
	t = document.getElementById('teamPhotosTable');
	for (i=0;i<t.rows.length;i++)
	{
		if (t.rows[i].getAttribute("head") != 1)
		{
			if (t.rows[i].id != src)
				t.rows[i].style.display = "none";
			else	
				t.rows[i].style.display = "";
		}
	}
}

function popup(content,onoff)
{
	var classname = onoff==1?"popupDivON":"popupDivOFF";
	document.getElementById("popupDiv").innerHTML = content;
	document.getElementById("popupDiv").className = classname;
}

function popupImg(content,onoff)
{
	var classname = onoff==1?"popupDivONImg":"popupDivOFF";
	document.getElementById("popupDiv2").innerHTML = content;
	document.getElementById("popupDiv2").className = classname;
	
	var ps = getPageSize();
	document.getElementById("popupDiv2").style.width = ps[0];
}

function closePop()
{
	document.getElementById("popupDiv").style.display = "none";
	document.getElementById("popupDiv2").style.display = "none";
}

function popup2(objId, onoff)
{
	var ps = getPageSize();
	obj = document.getElementById(objId);
	var height = document.getElementById(objId).style.height;
	var width = document.getElementById(objId).style.width;

	var top = (ps[3] - height)/2 - 20;
	var left = (ps[0] - width)/2;
	obj.style.left = left;
	obj.style.top = top;
	obj.style.display = "";
	
	var classname = onoff==1?"popupDivON":"popupDivOFF";
	document.getElementById("popupDiv").childNodes[0] = obj;
	document.getElementById("popupDiv").className = classname;
}

function showPopupStaff(src)
{	
	document.getElementById("kkk").style.visibility = "hidden";
	document.getElementById("kkk").innerHTML = str;
}

function showImgFromThumb(src)
{	
	img = src;
	str = "<img id='dummyImg' onload='dcrePREVNEXT(\""+img+"\", 0, 0);' src='"+img+"'>";
	document.getElementById("kkk").style.visibility = "hidden";
	document.getElementById("kkk").innerHTML = str;
}
function showImgFromThumbArray(id)
{	
	popup(waitImg,1);
	img = imgArray[id];
	str = "<img id='dummyImg' onload='dcrePREVNEXT(\""+img+"\", "+id+", 1);' src='"+img+"'>";
	document.getElementById("kkk").style.visibility = "hidden";
	document.getElementById("kkk").innerHTML = str;
}

function dcrePREVNEXT2(newImg, id, nav, map)
{	
	var ps = getPageSize();
	var height = document.getElementById("dummyImg").height;
	var width = document.getElementById("dummyImg").width;

	src = newImg;
	var top = (ps[3] - height)/2 - 20;
	var left = (ps[0] - width)/2;

	var str = "<div style='position:absolute;left:"+left+";top:"+top+";width:"+width+"px;height:"+height+"px;z-index:10000;' class='imgGal'>";
	str += "<table cellpadding=0 cellspacing=2 border=0 style='border:0px solid #333333;'>";
	str += "<tr><td valign='middle' align='right'>";
	str += "<a href=# onclick='closeImage();'><img src='img/close.png' border=0/></a>";
	str += "</td></tr><tr><td>";
	str += "<img src='"+src+"' border=0 usemap='#"+map+"'/>";
	str += "</td></tr></table>";
	str += "</div>";
	
	popupImg("", 1);
	document.getElementById("kkk").innerHTML = str;
	document.getElementById("kkk").style.visibility = "visible";
	popup("",0);
}


function dcrePREVNEXT(newImg, id, nav)
{	
	var ps = getPageSize();
	var height = document.getElementById("dummyImg").height;
	var width = document.getElementById("dummyImg").width;

	src = newImg;
	var top = (ps[3] - height)/2 - 20;
	var left = (ps[0] - width)/2;

	var str = "<div style='position:absolute;left:"+left+";top:"+top+";width:"+width+"px;height:"+height+"px;' class='imgGal'>";
	str += "<table cellpadding=0 cellspacing=2 border=0 style='border:0px solid #333333;'>";
	str += "<tr><td valign='middle' align='right'>";
	if(nav ==1)
	{
		str += "<a href=# onclick=\"thumbNav(0,'"+id+"');\"><img border=0 src='img/prev1.gif'></a>";
		str += "<a href=# onclick=\"thumbNav(1,'"+id+"');\"><img border=0 src='img/next1.gif'></a>";
	}	
	str += "<a href=# onclick='closeImage();'><img src='img/close.png' border=0/></a>";
	str += "</td></tr><tr><td>";
	str += "<img src='"+src+"'/>";
	str += "</td></tr></table>";
	str += "</div>";
	
	popupImg("", 1);
	document.getElementById("kkk").innerHTML = str;
	document.getElementById("kkk").style.visibility = "visible";
	popup("",0);
}

function dcre(aImages, nImages)
{	
	newImg = aImages[0];
	var ps = getPageSize();
	var height = newImg.height;
	var width = newImg.width;
	src = newImg.src;
	var top = (ps[3] - height)/2 - 20;
	var left = (ps[0] - width)/2;

	var str = "<div style='position:absolute;left:"+left+";top:"+top+";width:"+width+"px;height:"+height+"px;' class='imgGal'>";
	str += "<table cellpadding=0 cellspacing=2 border=0 bgcolor='#ffffff' style='border:5px solid #333333;'><tr><td>";
	str += "<img src='"+src+"'/>";
	str += "</td></tr>";
	str += "<tr><td bgcolor='#ffffff' valign='middle' align='right'>";
	str += "<a href=# onclick='closeImage();'><img src='img/close.gif' border=0/></a>";
	str += "</td></tr></table>";
	str += "</div>";
	
	popupImg("", 1);
	document.getElementById("kkk").innerHTML = str;
}

function thumbNav(to, id)
{
	var total = imgArray.length - 1;
	
	for(var i=0;i<=total;i++)
	{
		var next = i;
		var prev = i;
		if(i<total)
			next++;
		if(i>0)
			prev--;	

		var len1 = imgArray[i].length;
		var len2 = src.length
		var start = len2-len1 ;
		
		if(i == id && to == 1)
			showImgFromThumbArray(next);
		else if(i == id && to == 0)
			showImgFromThumbArray(prev);	
	}
}
function closeImage()
{
	popupImg("",0);
	document.getElementById("kkk").innerHTML="";
}

function fetchPopupContent(type,param)
{
	if(type == "ACTION")
		getAction(param,"","POST");		
}

function showStaff(id)
{
	getAction("STAFF", "sid="+id, "POST");	
}

function login()
{
	var pwd = document.getElementById("pwdinput").value;
	getAction("LOGIN", "pwd="+pwd, "POST");	
}

function login2()
{
	var pwd = document.getElementById("e_pwdinput").value;
	var eml = document.getElementById("e_emlinput").value;
	getAction("LOGIN2", "pwd="+pwd+"&eml="+eml, "POST");	
}


function logout()
{
	getAction("LOGOUT", "1=1", "POST");	
}

//function showlogin()
//{
//	popup2("loginDiv",1);
//}

function weekOffer()
{
	getAction("WEEKOFFER","", "POST");
}

function bonusgame()
{
	getAction("BONUSGAME","", "POST");
}	

function showTopic(id)
{
	getAction("SHOWTOPIC","tid="+id, "POST");
}

function sendPost(topicID)
{
	post = document.getElementById("postTextArea").value;
	if(post == "")
		return;
	getAction("NEWPOST","tid="+topicID+"&msg="+post, "POST");
}

function newContainerRendered(cont)
{
	container = cont;
	resizeMainCont();
}

function execRuntimeJS()
{
	try{eval(document.getElementById("jsChunk").innerHTML);}
	catch(e){}
	try{eval(document.getElementById("jsChunk2").innerHTML);}
	catch(e){}
}

function weekPhoto()
{
	getAction("WEEKPHOTO", "", "POST");
}

function getPano(id)
{
	getAction("GETPANO", "id="+id, "POST");
}

function photosByMonth(phCateg)
{
	mon = document.getElementById("photosByMonth").value;
	year = document.getElementById("photosByYear").value;
	mon = mon+"/"+year;
	if(mon != "")
		getAction("PHOTOSBYMONTH","month=" + mon + "&gal=" + phCateg,"POST");
}

function photosByDate(phCateg)
{
	date = document.getElementById("dateCriterion").value;
	if(date != "")
		getAction("PHOTOSBYDATE","date=" + date + "&gal=" + phCateg,"POST");
}

function showAllPhotos(phCateg)
{
	getAction("ALLPHOTOS", "gal=" + phCateg,"POST");
}

function getPhotos(categ,date)
{
	var pardate = "";
	if(date != "")
		pardate = "&date="+date;
		
	getControl("mainContent", "PHOTOGAL&gal="+categ+pardate);
}	

function getPhotosByGal(categ,date)
{
	getPage("VIEWMASTER"+categ);
	var pardate = "";
	if(date != "")
		pardate = "&date="+date;
		
	getControl("mainContent", "PHOTOGAL2&gal="+categ+pardate);
}	

function getNews(nid)
{
	thePage = "NEWS";
	getControl("mainContent", "NEW&nid="+nid);
	getControl("subMenu", "NEWS");
}

function getEvent(eid)
{
	getControl("mainContent", "EVENTS&eid="+eid);
}

function goBack()
{
	eval(document.getElementById("stepback").innerHTML);
}

function gotoStaff(id)
{
	getControl("mainContent", "WHORWE&sid="+id, "POST");	
	getControl("subMenu", "WHORWE");
}

function moveit()
{
	st = document.body.scrollTop;
	offset = 70;
	if(st > 30)
		offset = 30;
	document.getElementById("HomePageLogoDiv").style.top = st + offset;
}
