// JavaScript Document

//Compatable with both browsers
// myObj = MM_findObj("object");
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;
}

//Changes visibility of a form element from an onclick event
//ex:  showElement(this, "specialChars", this.src.indexOf("_dn.gif") != -1);
function showElement(obj, obj_To_Change, modifier) { 
	var chng_Obj = MM_findObj(obj_To_Change);
	if(eval(modifier)){ eval("chng_Obj.style.visibility = 'visible'"); eval("chng_Obj.style.display = 'inline'"); }
	else{ eval("chng_Obj.style.visibility = 'hidden'"); eval("chng_Obj.style.display = 'none'"); }
}

function rowEffect(object) { 
  if (object.className.indexOf('Over') == -1) object.className = object.className+'Over';
  else object.className = object.className.substring(0, object.className.lastIndexOf('Over'));
}

function rowOverEffect(object) {
  if (object.className.indexOf('Over') == -1) object.className = object.className+'Over';
}

function rowOutEffect(object) {
  if (object.className.indexOf('Over') != -1) object.className = object.className.substring(0, object.className.lastIndexOf('Over'));
}

//Disables the submit buttons on a form
//  ex: <form onSubmit="disableSubmit(this)">
function disableSubmit(theform) {
	if (document.all || document.getElementById) {
	  for (i = 0; i < theform.length; i++) {
		var tempobj = theform.elements[i];
		if (tempobj.type != null)  if (tempobj.type.toLowerCase() == "submit")	tempobj.disabled = true;
	  }
	}
}

function update_and_close(){
	//window.opener.location.href = window.opener.location.href;
	window.opener.location.reload(true);
	if (window.opener.progressWindow){ window.opener.progressWindow.close(); } 
	parent.window.close();	
}

function open_popup(url, window_name, width, height){	
  window.open(url,window_name,'width='+width+',height='+height+',resizable=1, scrollbars=1');
}

function show_photo(id, total){
	var x, obj, cur_id;
	for(x=0;x<total;x++){
		obj = MM_findObj('photo'+x);
		//alert(obj.id);
		if(id == x){ 
			obj.style.visibility = "visible";
			obj.style.display = "block";
		}else{ 
			obj.style.visibility = "hidden";
			obj.style.display = "none";
			//alert(obj.id);
		}
	}
	nudgeFirefox(); 
}


function nudgeFirefox(){ 
    /* sort out a height problem in firefox */ 
    document.getElementsByTagName('body')[0].style.width='99%'; 
    document.getElementsByTagName('body')[0].style.width='auto'; 
}

function set_input(e, v){
	var obj;
	obj = MM_findObj(e);
	obj.value = v;
}

function _CF_hasValue(obj, obj_type){
    if (obj_type == "TEXT"){
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    }
    else if (obj_type == "EMAIL"){
       	if (obj.value.length == 0){ 
      		alert('Missing Email Field\r\n\nYou must fill this in.');
			return false;
		}else if ((obj.value.indexOf('@') < 0) || (obj.value.indexOf('.') < 0 )){
			alert("Email invalid");
			return false; 
		}else
	 	 	return true;	
	}
}


function _CF_onError(form_object, input_object, object_value, error_message){
	alert(error_message);
	input_object.focus(); input_object.select();
    return false;	
}


//Protect agenst frames
function unframe_page(){	
	if(window.top.location.href != window.location.href){ 
		window.top.location.href = window.location.href;
	}
}