

function toggleMe(a){
	var e=document.getElementById(a);
	if(!e)return true;
	if(e.style.display=="none"){
		e.style.display="block"
		} else {
			e.style.display="none"
		}
	return true;
}

function initLoginArea(){
  var myAjax = new Ajax('/lib/handler.login.php',{update: $('login_area')}).request();
}
function login(){
  var myAjax = new Ajax('/lib/handler.login.php',{method: 'post', data:$('f'), update: $('login_area')}).request();
}

function retrievePassword(){
//  var mySlider = new Fx.Slide('passwordRecover', {duration: 500}); 
  	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms['f'].elements['fldRecoverName'].value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
	}
	 else {  
	  var myAjax = new Ajax('/lib/handler.password.retrieval.php',{method: 'post', data:$('f'), update: $('passwordRecover')}).request();
	  }
}	

function loadSignUpInfo(){
  //set info div to visible

	collapsible.hide();
	collapsible.slideIn();
		
}



function validateForm(form,fields){
	
	var form;
	var err = "";
	var fields = fields.split(",");
	
	for(i=0;i<fields.length;i++){
		fieldName = fields[i];
		value = form.elements[fieldName].value;
		name  = form.elements[fieldName].id;
		if(value.length<1){err += "" + name + " is required. \n";}
	}
	if(err.length>0){alert(err);return false;}else{return true;}
}

function windowPop(fileSource) {
 	popWin=window.open(fileSource, "popUp","width=512,height=384,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
	popWin.focus();
}

function recipePop(fileSource) {
    cw = Math.floor(((screen.availWidth-609)/2)-100);
    ch = Math.floor(((screen.availHeight-317)/2)-200);
 	popWin=window.open(fileSource, "recipe","width=629,height=317,toolbar=0,location=0,directories=0,status=FALSE,menubar=0,scrollbars=0,resizable=0,top="+ch+",left="+cw+"");
	popWin.focus();
}

function windowPopSize(fileSource, width, height) {
    cw = Math.floor(((screen.availWidth-width)/2)-100);
    ch = Math.floor(((screen.availHeight-height)/2)-200);
 	popWin=window.open(fileSource, "popUp","width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,top="+ch+",left="+cw+"");
	popWin.focus();
}

function focusField(fieldName){
	document.forms['f'].elements[fieldName].focus();
}
function swapClass(obj,css){
	obj.className = css;
}