var likeEmEmbed = null; 

function setHighlights() {									
	for (i=0;i<document.forms.length;i++) {
		//for (j=0;j<document.forms[i].length;j++){
		var arryInput = document.forms[i].getElementsByTagName('input');
		for (j=0;j<arryInput.length;j++) {
			objElement = arryInput[j];
			if(objElement.getAttribute("type").toLowerCase() == "text" || objElement.getAttribute("type").toLowerCase() == "password"){
				addEvent( objElement, 'focus', function(){ cName=this.className; this.className='ffActive'; } );
				addEvent( objElement, 'blur', function(){ this.className=cName; } );
			}
		}
	}
}

function addEvent( obj, type, fn ) {
	if ( obj.attachEvent ) {
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} else
		obj.addEventListener( type, fn, false );
}

function removeEvent( obj, type, fn ) {
	if ( obj.detachEvent ) {
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	} else
	obj.removeEventListener( type, fn, false );
}

function addLoadEvent(func) {

  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
	window.onload = func;
  } else {
	window.onload = function() {
	  if (oldonload) {
		oldonload();
	  }
	  func();
	}
  }

}

/*auto included load events*/
//addLoadEvent(setHighlights)

function displayNotice(m,w,n,e) {
	
	if (m.length > 0) {	$('messageList').innerHTML = '<li>' + m + '</li>'; Element.show('messageOut'); Effect.BlindUp('messageOut', {delay: 5.0})}
	if (w.length > 0) {	$('warningList').innerHTML = '<li>' + w + '</li>'; Element.show('warningOut'); Effect.BlindUp('warningOut', {delay: 5.0})}
	if (n.length > 0) {	$('noticeList').innerHTML = '<li>' + n + '</li>'; Element.show('noticeOut'); Effect.BlindUp('noticeOut', {delay: 5.0})}
	if (e.length > 0) {	$('errorList').innerHTML = '<li>' + e + '</li>'; Element.show('errorOut'); Effect.BlindUp('errorOut', {delay: 5.0})}
		
}

function setPrimaryImage(id) {
	$('div.primary').removeClass('primary');
	$('div#image_' + id).addClass('primary').highlight("slow");
}

function likeEmPlay() {
	likeEmStop();
	likeEmEmbed = document.createElement("embed");
	likeEmEmbed.setAttribute("src", "/flash/likeEm.mp3");
	likeEmEmbed.setAttribute("hidden", true);
	likeEmEmbed.setAttribute("autostart", true);
	document.body.appendChild(likeEmEmbed);
}

function likeEmStop() {
	if ( likeEmEmbed ) {
		document.body.removeChild(likeEmEmbed);
		likeEmEmbed = null;
	}
}