function doPopup(theURL, theWinName, theLeft, theTop, theWidth, theHeight, theresize, thescrollbars, thestatusbar, themenu, thetools, thelocationbar, thedirs){
	// EXAMPLE doPopup('popup.asp', 'popwin', 10, 10, 500, 300, 'no', 'no', 'yes', 'no', 'no', 'no', 'no')
	// USE theLeft AND theTop = -1 FOR AUTO-CENTER

	if (theLeft == -1 && theTop == -1){
		theLeft = (screen.width - theWidth) / 2;
		theTop = (screen.height - theHeight) / 2;
	}
	var paramstr;
	paramstr = "width=" + theWidth + "px,height=" + theHeight + "px,left=" + theLeft + "px,top=" + theTop + "px,resizable=" + theresize + ",scrollbars=" + thescrollbars + ",status=" + thestatusbar + ",menubar=" + themenu + ",toolbar=" + thetools + ",location=" + thelocationbar + ",directories=" + thedirs;
	window.open(theURL, theWinName, paramstr);
}



function enlargeImage(theImg, theAlt){
	theURL = "../common/enlargeImage.asp?theImg=" + theImg + "&theAlt=" + theAlt
	theWidth = 100;
	theHeight = 100;
	theLeft = (screen.width - theWidth) / 2;
	theTop = (screen.height - theHeight) / 2;
	window.open(theURL, 'enlarge', "width=" + theWidth + "px,height=" + theHeight + "px,left=" + theLeft + "px,top=" + theTop + "px,resizable=no,scrollbars=no,statusbar=no,menubar=no,personalbar=no,toolbar=no,locationbar=no,directories=no");
}

function alertModal(theMessage,isError, wdt, hgt, pageRequested){
	var myObject = new Object();
	var lft, tp;
	lft = (screen.width - wdt) / 2;
	tp = (screen.height - hgt) / 2;
	myObject.bodys = theMessage;

	if (isError=="ERROR"){
		win = window.showModalDialog("../common/modalError.asp", myObject, "dialogWidth:" + wdt + "px; dialogHeight:"+ hgt +"px; dialogLeft:" + lft + "px; dialogTop:" + tp + "px; help:0;status:0;scroll:0;resizable:0");
	}
	else if (isError=="LOGIN"){
		win = window.open("../common/modalLogin.asp?pageWanted="+pageRequested, "loginWin", "width=" + wdt + "px,height=" + hgt + "px,left=" + lft + "px,top=" + tp + "px,resizable=no,scrollbars=no,status=no,menubar=no,toolbar=no,location=no,directories=no");
	}
	else if (isError=="SENDFRIEND"){
		win = window.open("../common/sendFriend.asp", "sendFriend", "width=" + wdt + "px,height=" + hgt + "px,left=" + lft + "px,top=" + tp + "px,resizable=no,scrollbars=no,status=no,menubar=no,toolbar=no,location=no,directories=no");
	}
	else if (isError=="TERMS"){
		win = window.showModalDialog("../common/modalTerms.asp", myObject, "dialogWidth:" + wdt + "px; dialogHeight:"+ hgt +"px; dialogLeft:" + lft + "px; dialogTop:" + tp + "px; help:0; status:0 ");
	}
	else{
		win = window.showModalDialog("../common/modalInfo.asp", myObject, "dialogWidth:" + wdt + "px; dialogHeight:" + hgt + "px; dialogLeft:" + lft + "px; dialogTop:" + tp + "px; help:0; status:0 ");
	}
}


var nsstyle='display:""'
if (document.layers)
var scrolldoc=document.scroll1.document.scroll2

function up(){
	if (!document.layers) return
	if (scrolldoc.top<0)
	scrolldoc.top+=10
	temp2=setTimeout("up()",50)
}

function down(){
	if (!document.layers) return
	if (scrolldoc.top-150>=scrolldoc.document.height*-1)
	scrolldoc.top-=10
	temp=setTimeout("down()",50)
}

function clearup(){
	if (window.temp2)
	clearInterval(temp2)
}

function cleardown(){
	if (window.temp)
	clearInterval(temp)
}

function goToPage(thePage, showPageFrom, showPageTo, listPage){
	document.forms.mainForm.action = listPage;
	if (eval(thePage) > eval(showPageTo)){
		document.forms.mainForm.iBlockCurrent.value = eval(document.forms.mainForm.iBlockCurrent.value) + 1
	}
	if (eval(thePage) < eval(showPageFrom)){
		document.forms.mainForm.iBlockCurrent.value = eval(document.forms.mainForm.iBlockCurrent.value) - 1
	}
	document.forms.mainForm.iPageCurrent.value = thePage;
	document.forms.mainForm.submit();
}

function goToBlock(theBlock, thePage, listPage){
	document.forms.mainForm.action = listPage;
	document.forms.mainForm.iPageCurrent.value = thePage;
	document.forms.mainForm.iBlockCurrent.value = theBlock;
	document.forms.mainForm.submit();
}

function goToView(theArea, theRecord){
	document.forms.mainForm.action = theArea;
	document.forms.mainForm.record.value = theRecord;
	document.forms.mainForm.submit();
}


function goToBack(theArea){
	document.forms.mainForm.action = theArea;
	document.forms.mainForm.submit();
}

function changeSorting(newSorting, theArea){
	document.forms.mainForm.sorting.value = newSorting;
	document.forms.mainForm.action = theArea;
	document.forms.mainForm.submit();
}

function isDate(strDate,DateFormat){
	 DateFormat=DateFormat.toLowerCase()

	 if (DateFormat=='dd/mm/yyyy'){var DatePattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;}
	 else if (DateFormat=='mm/dd/yyyy'){var DatePattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;}
	 else if (DateFormat=='yyyy/mm/dd'){var DatePattern = /^(\d{2}|\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;}

	 var matchArray = strDate.match(DatePattern);
	 if (matchArray == null) return false;

	 if (DateFormat=='dd/mm/yyyy'){var day = matchArray[1];var month = matchArray[3];var year = matchArray[4];}
	 else if (DateFormat=='mm/dd/yyyy'){var day = matchArray[3];var month = matchArray[1];var year = matchArray[4];}
	 else if (DateFormat=='yyyy/mm/dd'){var day = matchArray[4];var month = matchArray[3];var year = matchArray[1];}
	 else{return false;}

	 if (month < 1 || month > 12) return false;
	 if (day < 1 || day > 31) return false;
	 if (year < 1900) return false;
	 if ((month == 4 || month == 6 || month==9 || month == 11) && day == 31) return false;
	 if (day>=29 && month == 2 && parseInt(year) % 4 !== 0) {return false;}
	 if (day>=30 && month == 2 && parseInt(year) % 4 == 0) {return false;}
	 return true;
}

function isInteger(theData){ return (theData.search(/^\d+$/) != -1); }

function isEmpty(s){ return ((s == null) || (s.length == 0) || s=="");}

function isMail(sString){
	var emailEXP = /^[a-z_0-9\.]+@[a-z_0-9\-\_\.]+\.[a-z]{2,3}$/i
	if (!sString.match(emailEXP)){
		return false;
	}
	else{
		return true;
	}
}

function isDecimal(theData){ return (theData.search(/\d*\.\d+/) != -1); }

function isChecked(theData){
	var len, found
	len = theData.length;
	found = true
	for(var i=0;i<len;i++){
		if (theData[i].checked) found=false;
	}
	return found;
}

function hasMaxLength(theString, theLen){
	if (theString.length > theLen) {
		return false
	}
	else {
		return true
	}
}

function sendpage(){
	url=document.location.href
	strmailpage="mailto:?subject=Mythos site&body=Κάνε κλικ στο παρακάτω link για να δεις τη σελίδα που σου στέλνω από το site του Μύθου  : " + url
	document.location.href=strmailpage
}

function getRealLeft(imgElem) {
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function getRealTop(imgElem) {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function relocatePageTurn(){
	var ImageLeft, ImageTop, relocateWidthRight, relocateHeightRight, relocateWidthLeft, relocateHeightLeft;
	ImageLeft = getRealLeft(document.getElementById("GetLocation"));
	ImageTop = getRealTop(document.getElementById("GetLocation"));
	documentWidth = document.body.offsetWidth;

	relocateWidthRight = ImageLeft - 40;
	relocateHeightRight = ImageTop + 505;

	relocateWidthLeft = ImageLeft - 793;
	relocateHeightLeft = ImageTop + 505;

	document.getElementById("RightPageTurn").style.left = relocateWidthRight + "px";
	document.getElementById("RightPageTurn").style.top = relocateHeightRight + "px";
	document.getElementById("LeftPageTurn").style.left = relocateWidthLeft + "px";
	document.getElementById("LeftPageTurn").style.top = relocateHeightLeft + "px";
	
	if (document.getElementById("CoverGirlSubMenu")){
		document.getElementById("CoverGirlSubMenu").style.left = (ImageLeft - 785) + "px";
		document.getElementById("CoverGirlSubMenu").style.top = (ImageTop + 55) + "px";
	}	
	
	// Additional Divs for Bottleneck and Super Brewer
	var CreatingMythosPopupBottleneck = document.getElementById("OpenBottleneck");
	if (CreatingMythosPopupBottleneck){
		CreatingMythosPopupBottleneck.style.left = ImageLeft - 755;
		CreatingMythosPopupBottleneck.style.top = ImageTop + 418;
	}
	
	var CreatingMythosPopupSuperBrewer = document.getElementById("OpenSuperBrewer");
	if (CreatingMythosPopupSuperBrewer){
		CreatingMythosPopupSuperBrewer.style.left = ImageLeft - 595;
		CreatingMythosPopupSuperBrewer.style.top = ImageTop + 480;
	}
	
	// Additional Divs for MythosLives
	var HeightCounter = 424
	for (var i=1;i<6;i++){
		var TheDiv = document.getElementById("OpenLives"+i);
		if (TheDiv){
			TheDiv.style.left = ImageLeft - 762;
			TheDiv.style.top = ImageTop + HeightCounter;
			HeightCounter = HeightCounter + 20;
		}
	}
	return true;
}

function dopreload(){
	window.document.preloader.TGotoFrame("_level0/", "2")
}

function setObjHeighteqHTML(changeObj){
	document.getElementById(changeObj).style.height = (getDocHeight()-50)+"px"
}

function getDocHeight() {
	var D = document;
	return Math.max(
		Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
		Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
		Math.max(D.body.clientHeight, D.documentElement.clientHeight)
	);
} 

function togglesound(state){
    var stateIs = state;
    
    var TheFlash=null;
    if (window.document['leftFlash']) {
        TheFlash = window.document['leftFlash'];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds['leftFlash']){
            TheFlash = document.embeds['leftFlash'];
        }                
    } else {        
	   TheFlash = document.getElementById('leftFlash');
    }
    if (TheFlash) {	    	
       TheFlash.SetVariable("S", stateIs);
    }else{
		//window.setTimeout("togglesound("+stateIs+")", 500);
	}
}

function SetToggleSound(state){
    var stateIs = state;   
    var TheFlashMusic=null;    
    if (window.document['music']) {
        TheFlashMusic = window.document['music'];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds['music']){
            TheFlashMusic = document.embeds['music'];
        }                
    } else {        
	   TheFlashMusic = document.getElementById('music');
    }
    if (TheFlashMusic) {	    	
       TheFlashMusic.SetVariable("SetSound", stateIs);
    }else{
		window.setTimeout("settogglesound("+stateIs+")", 500);
	}
}

function getFlashMovieObject(movieName){
    if (window.document[movieName]){
          return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1){
        if (document.embeds && document.embeds[movieName]){
            return document.embeds[movieName];
        }
    } else {// if (navigator.appName.indexOf("Microsoft Internet")!=-1)
        return document.getElementById(movieName);
    }
}

