// JavaScript Document
/*sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/



sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	
	//
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function highlightRequiered(id, message){
	$(id).style.color = "black"
	$(id).value = message
	new Effect.Highlight(id,{afterFinish: function(){$(id).value="";$(id).style.color = ""}})
}
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 }

function signup(){
	readytosend = "yes"

	if($F('name')==""){
		highlightRequiered('name', "Required")
		readytosend = "no"
	}
	if($F('email')=="" || !isValidEmail($F('email'))){
		highlightRequiered('email', "Required")
		readytosend = "no"
	}
	if(readytosend == "yes"){
		var url = '/modules/members/signup.php';
		var pars = Form.serialize($('signupform'))
		//var SignupAjax = new Ajax.Updater('inside', url, {method: 'get', parameters: pars});
		
		
/*		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars, 
				evalScripts: true,
				onComplete: UpdateInside
			});*/
			
			
			
			
			var myAjax = new Ajax.Updater(
			'inside', url, 
			{
				method: 'post', 
				parameters: pars, 
				evalScripts: true,
				onComplete: UpdateInside
			});
	}
}
function UpdateInside(originalRequest){
	$('inside').style.display = "none"
	//$('inside').innerHTML =originalRequest.responseText;
	Effect.Appear('inside', {duration: 1.6, queue:{scope:'inside', position:'end'}});


}

function Set_Cookie(name, value, expires, path, domain, secure ) {

	//alert("Setting Cookie on "+name+": "+value);

	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	if ( expires ){
		//expires = expires * 1000 * 60 * 60 * 24;
		expires = expires * 1000 * 60 * 60;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name ) {
		
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
	
function logout(){
	Delete_Cookie( "member_login", "/")

	var url = '/modules/members/signup_form.php';
	var myAjax = new Ajax.Updater(
			'inside', url, 
			{
				method: 'post', 
				evalScripts: true,
				onComplete: UpdateInside
			});
}
