// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

//alert("application.js");

function $(element) {
	return new YAHOO.util.Element(element);
}

function getEl(element) {
	return( YAHOO.util.Dom.get(element) );
}


function hide(element) {
   $(element).setStyle('visibility','hidden');
}

function show(element) {
   $(element).setStyle('visibility','visible');
}

function page_load() {
	document.getElementById("content").style.visibility='visible';
	wait = 
	new YAHOO.widget.Panel("wait",  
					{ width:"240px", 
					  fixedcenter:true, 
					  close:false, 
		    			  zIndex : 32000,
					  draggable:false, 
//					  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25},
					  modal:true,
					  visible:false
					} 
				);
	wait.setHeader("Qollage");
	wait.setBody("<img src=\"/images/loading.gif\"/> Loading...");
	wait.render(document.body);
}

function page_unload() {
	document.getElementById("content").style.opacity='50';
	document.getElementById("wait").style.visibility='visible';
}	


function checkEnter(e, dialog) { 
	var characterCode = e.keyCode;

	if(characterCode == 13){
		dialog.submit();
		return false;
	} else {
		return true;
	}
}

function checkEmailAddr2(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function checkEmailAddr(email) {
	AtPos = email.indexOf("@")
	StopPos = email.lastIndexOf(".")

	if (AtPos < 1 || StopPos < 1 ) {
		return false;
	}

	if (StopPos < AtPos) {
		return false;
	}

	if (StopPos - AtPos == 1) {
		return false;
	}

	if (email.length - StopPos < 3) {
		return false;
	}
	
	if (email.indexOf(" ") >= 0) {
		return false;
	}

	if (email.indexOf("/") >= 0) {
		return false;
	}
	
	if (email.indexOf("\\") >= 0) {
		return false;
	}
	
	if (email.indexOf(";") >= 0) {
		return false;
	}	

	if (email.indexOf(",") >= 0) {
		return false;
	}	

	if (email.indexOf('"') >= 0) {
		return false;
	}	

	if (email.indexOf(":") >= 0) {
		return false;
	}	


	return true;
};


function registerUnloadFunction(func){ 
  if (window.addEventListener) window.addEventListener("unload", func, false); 
  else if (window.attachEvent) window.attachEvent("onunload", func); 
}; 
