
function uploadProgressPopUp(mypage, myname, w, h, scroll, titlebar)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function uploadProgressPost(sessionid)
{
	baseUrl = "/uploader/pgbar.php";
	iTotal = escape("-1");
	baseUrl += "?iTotal=" + iTotal;
	baseUrl += "&iRead=0";
	baseUrl += "&iStatus=1";
	baseUrl += "&sessionid=" + sessionid;
	uploadProgressPopUp(baseUrl,"Uploader",460,240,false,false);
	return true;
}

















var blnNoClick=false;

function ACM_popup(url, width, height) {
		if(!width) {
			width=100;
		}
		if(!height) {
			height=100;
		}
		window.open(url,'acm_popup','width='+width+', height='+height+', directories=no, location=no, menubar=yes, scrollbars=yes, scrolling=auto, status=yes, toolbar=no, resizable=yes');
}


function ACM_blank(url, width, height) {
		if(!width) {
			width=100;
		}
		if(!height) {
			height=100;
		}
		window.open(url,'acm_popup','width='+width+', height='+height+', directories=no, location=no, menubar=no, scrollbars=no, scrolling=no, status=no, toolbar=no, resizable=no');
}

function ACM_userpopup(url, width, height) {
		if(!width) {
			width=300;
		}
		if(!height) {
			height=450;
		}
		window.open(url,'acm_userpopup','width='+width+', height='+height+', directories=no, location=no, menubar=no, scrollbars=no, scrolling=no, status=no, toolbar=no, resizable=yes');
}




function ACM_fitPic(addonX, addonY) { 
	var iWidth;
	var iHeight;

	if(!addonX) {
		addonX = 1;
	}
	if(!addonY) {
		addonY = 1;
	}

	var NS = (navigator.appName=="Netscape")?true:false; 

	iWidth = (NS)?window.innerWidth:document.body.clientWidth; 
	iHeight = (NS)?window.innerHeight:document.body.clientHeight; 
	iWidth = (document.images[0].width + addonX) - iWidth; 
	iHeight = (document.images[0].height + addonY) - iHeight; 

	//alert('x: ' + iWidth + ' y: ' + iHeight);
	
	window.resizeBy(iWidth, iHeight); 
	self.focus(); 
}



function waitmessage(theDocument, theMessage) {

	if(theDocument!='') {
		eval(theDocument).document.write('<html><link rel=\'stylesheet\' href=\'/css/acm.css\'>');
		eval(theDocument).document.write('<body bgcolor=\'#FFFFFF\' background=\'/img/backgrounds/raster-dense.gif\'>');
		eval(theDocument).document.write('<table border=\'0\' width=\'100%\' height=\'100%\'><tr><td align=\'center\' valign=\'middle\'><big><big><i>' + theMessage + '</i></big></big></td></tr></table>');
		eval(theDocument).document.write('</body></html>');
	}
	else {	
		document.write('<html><link rel=\'stylesheet\' href=\'/css/acm.css\'>');
		document.write('<body bgcolor=\'#FFFFFF\' background=\'/img/backgrounds/raster-dense.gif\'>');
		document.write('<table border=\'0\' width=\'100%\' height=\'100%\'><tr><td align=\'center\' valign=\'middle\'><big><big><i>' + theMessage + '</i></big></big></td></tr></table>');
		document.write('</body></html>');
	}
}

function FixSize(autosize){
	var acmImage = 'ACMimg' + autosize;
	var x = eval('document.' + acmImage + '.width + 312');
	var y = eval('document.' + acmImage + '.height + 320');

	if (screen.availWidth<x) { x = screen.availWidth - 28; }
	if (screen.availHeight<y) { y = screen.availHeight - 28; }

	window.resizeTo(x,y);
}

function ACM_selectAdd(iform, itarget, idata) {
	if(idata!='') {
		var option = new Option(idata, idata);
		eval('document.'+iform+'.'+itarget+'.options.add(option)');
	}
}




function ACM_selectRemove(iform, itarget) {
	if(eval('document.'+iform+'.'+itarget+'.selectedIndex')>=0) {
		eval('document.'+iform+'.'+itarget+'.remove(document.'+iform+'.'+itarget+'.selectedIndex)');
	}
}

  function accessCSS(layerID) {
		if(document.getElementById){
			  return document.getElementById(layerID).style;
		}
		else if(document.all){
			  return document.all[layerID].style;
		}
		else if(document.layers){
			  return document.layers[layerID];
		}
  }

  function accessID(layerID) {
		if(document.getElementById){
			  return document.getElementById(layerID);
		}
		else if(document.all) {
			  return document.all[layerID];
		}
		else if(document.layers) {
			  return document.layers[layerID];
		}
  }



function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if(typeof(window.pageYOffset) == 'number') {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	}
	else {
		if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		}
		else {
			if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
				//IE6 standards compliant mode
				scrOfY = document.documentElement.scrollTop;
				scrOfX = document.documentElement.scrollLeft;
			}
		}
	}
	return new Array(scrOfX, scrOfY);
}

		
function windowSize() {
	var myWidth = 0, myHeight = 0;
	if(typeof(window.innerWidth) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else {
		if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else {
			if(document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			}
		}
	}
	return new Array(myWidth, myHeight);
}


function writeToLayer(txt) {
	if (document.all) { //expl.
		document.all["tallager"].innerHTML=txt;
	}
	else if (document.layers) { //ns4
		document["tallager"].document.open();
		document["tallager"].document.write(txt);
		document["tallager"].document.close();
	}
	else if (document.getElementById) { //ns6
		document.getElementById("tallager").innerHTML=txt;
	}
}



var blnInfoBoxCreated = false;

function infoBox(theAction, mess) {
	/*
	if(!blnInfoBoxCreated) {
		var divHtml = '<div id="infoboxlayerB" style="position: absolute; visibility: hidden; z-index: 1; left: 20; top: 20; border: none; border-color: 000000; border-width: 1px; width: 271; height: 153; background-image: url(\'/img/templates/infobox/infoboxbg.gif\');" onBlur="infoBox(\'hide\', \'\');" onClick="infoBox(\'hide\', \'\');"><center><form style="margin-top: 20" name="infoboxform"><textarea name="infoboxmessage" style="background-color: FFFFFF; border: solid; border-width: 1px; width: 234; height: 107;"></textarea></center></form></div>';
		var divEle = xCreateElement("infoboxlayer");
		xInnerHTML(divEle, divHtml);
		blnInfoBoxCreated = true;
	}
	
	return false;
	if(theAction=='show') {



		var layoutWidth=271;
		var layoutHeight=252;

		var theWindowSize = windowSize();
		var theScrollPos = getScrollXY();

		var theLeft = (theWindowSize[0] - layoutWidth) / 2;
		var theTop = ((theWindowSize[1] - layoutHeight) / 2) + theScrollPos[1];


		xResizeTo("infoboxlayer", layoutWidth, layoutHeight);
		
		xShow("infoboxlayer");
		xMoveTo("infoboxlayer", theLeft, theTop);
		xZIndex("infoboxlayer", 99);		
		
		
		//accessCSS('infoboxlayerB').left=theLeft;
		//accessCSS('infoboxlayerB').top=theTop;
		//document.infoboxform.infoboxmessage.value=mess;
		//accessCSS('infoboxlayerB').visibility='visible';
		
		
		//accessID('infoboxlayerB').focus();
		return false;
	}
	else if(theAction=='hide') {
		xHide("infoboxlayerB");
		//accessCSS('infoboxlayerB').visibility='hidden';
	}
	*/
	
}


var validateForm = false;
var errorusField;
var passEq;
var strJS = new Array();

function ACM_validateForm(theTarget, theID) {
	//alert('yay' + strJS);
	//return false;

	validateForm=false;
	var lax= 'a' + theTarget + 'x' + theID + 'a';

	eval(strJS[lax]);
	
	if(validateForm==false) {
		return true; //return true;
	}
	else {
		errorusField.style.backgroundColor='D0DBFF';
		alert(validateForm); //infoBox('show', validateForm);
		return false;
	}

	
}

function ACM_format(rule, theField, theFieldType, theThreshold, errorMessage) {
	

	if(validateForm==false) {
		var errorus=false;
		if(!theField || !rule) return false;
		if(rule=="required") {
			if(theFieldType=='radio') {
				var pass=false;
				for (var i=0; i<theField.length && pass==false; i++) {
					if (theField[i].checked) {
						pass=true;
					}
				}
				if(pass==false) {
					errorus = 'You must choose an option from \"' + theField[0].name + '\".';
					errorusField=theField[0];
				}
			}
			else if(theFieldType=='checkbox') {
				if(theField.value == 0) {
					errorus = 'The field \"' + theField.name + '\" is required.';
				}
			}
			else if(!theField.value) {
				errorus = 'The field \"' + theField.name + '\" is required.';
			}
		}
		else if(theField.value!='') {
			//theField.value=trim(theField.value);


			if(rule=="email") {
				var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
				if(re.test(theField.value)==false) {
					errorus = 'The field \"' + theField.name + '\" does not contain a valid e-mailadress.';
				}
			}
			else if(rule=="min_strlen") {
				if(theField.value.length < theThreshold) {
					errorus = 'The field \"' + theField.name + '\" must contain at least ' + theThreshold + ' characters.';
				}
			}
			else if(rule=="max_strlen") {
				if(theField.value.length > theThreshold) {
					errorus = 'The field \"' + theField.name + '\" can not contain more than ' + theThreshold + ' characters.';
				}
			}
			else if(rule=="min_value") {
				var reint = /^([0-9]+)$/
				if(reint.test(theField.value)==false) {
					errorus = 'The field \"' + theField.name + '\" may only contain numbers.';
				}
				if(theField.value < theThreshold && theField.value) {
					errorus = 'The field \"' + theField.name + '\" requires a number higher or equal to ' + theThreshold + '.';
				}
			}
			else if(rule=="max_value") {
				var reint = /^([0-9]+)$/
				if(reint.test(theField.value)==false) {
					errorus = 'The field \"' + theField.name + '\" may only contain numbers.';
				}
				if(theField.value > theThreshold) {
					errorus = 'The field \"' + theField.name + '\" requires a number lower or equal to ' + theThreshold + '.';
				}
			}
			else if(rule=="username") {
				var re = /^([a-zA-Z0-9_]{5,20})$/
				if(re.test(theField.value)==false) {
					errorus = 'You have entered an invalid username.\n\n The username must be 5-20 characters long, and may only consist of A-Z, 0-9 and the underscorecharacter \"_\".';
				}
			}
			else if(rule=="password") {
				var ree = /^([a-zA-Z0-9_]{5,20})$/
				if(ree.test(theField.value)==false) {
					errorus = 'You have entered an invalid password.\n\n The password must be 5-20 characters long, and may only consist of A-Z, 0-9 and the underscorecharacter \"_\"';
				}
				else {
					passEq = theField.value;
				}
			}
			else if(rule=="password2") {
				if(passEq != theField.value) {
					errorus = 'The password verification does not match the password.';
				}
			}
			else if(rule=="url") {
				/* to be continued.. :)
				var ree = /^([\w])$/
				if(ree.test(theField.value)==false) {
					errorus = 'You have entered an invalid URL-adress in the field \"' + theField.name + '\".';
				}
				*/
			}
		}


		if(errorus!=false) {
			if(theFieldType=='radio') {
				errorusField=theField[0];
			}
			else {
				errorusField=theField;
			}
			if(errorMessage != '') {
				errorus=errorMessage;
			}
			return errorus;
		}
		else {

			return false;
		}
	}
	else {
		return validateForm;
	}
}



