/* <![CDATA[ */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function attachEventListener(target,eventType,functionRef,capture){
	if(target==null){return}
	if (typeof(target.attachEvent) != "undefined") {
		//Man, I hate IE
		var functionString=eventType+functionRef;
		target["e"+functionString]=functionRef;
		target[functionString]=function(event){
			if(typeof event=='undefined'){
				event=window.event;
			}
			target["e"+functionString](event);
		};
		target.attachEvent("on"+eventType,target[functionString]);
	} else if (typeof target.addEventListener != "undefined") {
		target.addEventListener(eventType,functionRef,capture);
	}
}
String.prototype.ucFirst = function () {
   return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}
function cancelEvent(event){
	if (event.cancelable){
		event.preventDefault();// DOM style
	}
	event.returnValue=false;//IE
}
function getEventTarget(event){
	var targetElement=null;
	if(typeof event.target!="undefined"){
		targetElement=event.target;
	}else{
		targetElement=event.srcElement;
	}
	while(targetElement.nodeType==3 && targetElement.parentNode!=null){
		targetElement=targetElement.parentNode;
	}
	return targetElement;
}
function switchFieldset(whichfieldset){
	var fieldsets=document.getElementsByTagName('fieldset');
	for(var i=0; fieldsets.length>i; i++){
		if(fieldsets[i].className=='submit'){continue;}
		fieldsets[i].style.display='none';
	}
	document.getElementById(whichfieldset).style.display='';
	var buttons=document.getElementById('login_btns').getElementsByTagName('input');
	for(var i=0; buttons.length>i; i++){
		//buttons[i].removeAttribute('disabled');
		buttons[i].style.color='black';
	}
	//document.getElementById(whichfieldset+'_btn').setAttribute('disabled','disabled');	
	document.getElementById(whichfieldset+'_btn').style.color='gray';	
}

//var jQuery = jQuery.noConflict();
var onSignupDiv = false;
var onSignup = false;
function signupClose(){
	if(!onSignup && !onSignupDiv){
		jQuery("#signupList").stop().animate({opacity:'0.0',height:'0px'},600,'easein',function() { jQuery("#signupList").css({display:'none'}); });
	}
}
jQuery(document).ready(function(){
  jQuery("#signupList").mouseover(function(){
	  onSignupDiv = true;
  });
  jQuery("#signupList").mouseout(function(){
	  onSignupDiv = false;
	  setTimeout(signupClose, 200);
  });
  jQuery("#signup").hoverIntent({
	  over: function(){
			  if(jQuery.browser.msie){
				jQuery("#signupList").stop().css({opacity:'0.0', height:'0px',display:'block'}).animate({opacity:'1.0', height:'500px'},600,'easeout');
			  }else{
				jQuery("#signupList").stop().css({opacity:'0.0', height:'0px',display:'block'}).animate({opacity:'1.0', height:'450px'},600,'easeout');
			  }
			  onSignup = true;
		  },
	  out: function(){
			  onSignup = false;
			  setTimeout(signupClose, 200);
		  },
	  timeout: 600,
	  sensitivity: 7
  });
  jQuery("#signup_email, #signup_email1").focus(function(){
	  if (jQuery(this).val() == jQuery(this)[0].title)
	  {
		  jQuery(this).removeClass("defaultTextActive");
		  jQuery(this).val("");
	  }
  });
  jQuery("#signup_email, #signup_email1").blur(function(){
	  if (jQuery(this).val() == "")
	  {
		  jQuery(this).addClass("defaultTextActive");
		  jQuery(this).val(jQuery(this)[0].title);
	  }
  });
});

/**
 * Limits a text field to specified length. truncates the rest
 */
function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}
/* ]]> */
