//////  Mailing List
function mailing_list_focus(o)
{
	if(o.value == 'JOIN OUR MAILING LIST') o.value = '';	
}

function mailing_list_blur(o)
{
	if(o.value == '') o.value = 'JOIN OUR MAILING LIST';
}

/////// Dreamweaver Rollover
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function switch_image(new_image,description)
{
	document.getElementById('main_image_container').innerHTML="<img src='"+new_image+"' name=\"view\" class=\"gallery_full_frame_image\"  width=\"430\" height=\"282\">";
	document.getElementById('main_image_description').innerHTML=description;
}


// Validations & Corrections

function form_submit(form_obj)
{
	//The first arguement is the form object or 'this.form'
	//The second argument is what to alert if user over clicks
	//the third arguement is what needs to be set for the form to be submitted
	//the fourth is the text displayed if third argument not passed
	// ie form_submit(this.form,'',this.form.agreement.checked,'please check it')
	var args = form_submit.arguments;

	/*
	alert(args[0]);
	alert(args[1]);
	alert(args[2]);
	alert(args[3]);
	*/
	if(!args[2] && args[3]) //if something is not checked and there is something to show as an error 
	{
		alert(args[3]);
		return false;
	};
	if(__submitted == false && validate_form())
	{
		__submitted = true;
		form_obj.submit();
	}
	else if (__submitted == true && document.MM_returnValue && args[1])
	{
		if (args[1] != '') alert(args[1]); 
		return false;
	};
	return false;
};




// #EMAIL OBFUSCATION

function show_email(string)
{
	var string_backwards = "";
	var email;
	for(count=string.length; count >= 0; count--)
	{
	string_backwards+=string.substring(count,count-1);
	}
	email = string_backwards.replace(/_at_/g,'@').replace(/_dot_/g,'.')
	return email;
}


// Simple Popups
simple_popup_window = null;

function simple_popup(url,desired_width,desired_height)
{
	var w,h,window_width,window_height,top,left;
	window_width  = desired_width
	window_height = desired_height

	left = (screen.width  - window_width)/2
	top  = (screen.height - window_height)/2		

	simple_popup_window = window.open
	(
		url,
		'simple_popup_window',
			'width='+window_width+','+
			'height='+window_height+','+
			'directories=no,'+
			'location=no,'+
			'menubar=no,'+
			'scrollbars=no,'+
			'status=no,'+
			'toolbar=no,'+
			'resizable=yes,'+
			'left='+left+","+
			'top='+top
	);
	simple_popup_window.focus()
	return false;
}


function close_popups()
{
  if (simple_popup_window != null && simple_popup_window.open) simple_popup_window.close();
}

function window_load()
{
	MM_preloadImages('/images/about_cerense_mo.gif','/images/about_us_mo.gif','/images/news_views_mo.gif','/images/next_steps_mo.gif');
}




window.onload = window_load;
window.onfocus = close_popups;