function ek_check_form(form){
	if(inForm(form.item_title) && (trim(form.item_title.value) == "" )){
	alert('please enter a title.'); return false;}
	
	if((inForm(form.item_folder) && (trim(form.item_folder.value) == "" ))&& !(inForm(form.folder_unnecessary) && (trim(form.folder_unnecessary.value) == "true" ))){
		alert('please enter a folder for this collection.'); 
		return false;
	}
	
	if((inForm(form.button_goes_to_url) && (trim(form.button_goes_to_url.value) == "" ))&& (inForm(form.is_link) && (trim(form.is_link.value) == "true" ))){
		alert('please enter an url for this link.'); 
		return false;
	}
	/*
	
	if(inForm(form.password) && (form.password.value.length<4 ||(trim(form.password.value)=="password" && trim(form.newuser.value)!=""))){
		alert('the password must be at least 4 characters long.'); 
		return false;
		}
	if(inForm(form.first_name) && (trim(form.first_name.value) == "" || trim(form.first_name.value) == "First Name")){
		alert('please enter your first name.'); return false;}
	if(inForm(form.last_name) && (trim(form.last_name.value) == "" || trim(form.last_name.value) == "Last Name")){
	alert('please enter your last name.'); return false;}
	if(inForm(form.email) && !(/[A-Za-z0-9_\.\-]+@+[A-Za-z0-9_\-]+\.[A-Za-z]+/.test(form.email.value))){
		alert('please enter a valid email address');
		return false;}

	if(inForm(form.listing_title)&& (trim(form.listing_title.value)) == ""){
		alert('Please enter a title for this listing.'); return false;}
	
	if(inForm(form.listing_category) && form.listing_category.value == ""){
		alert('please select a category for this listing.'); return false;}
*/
	return true;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
	  retValue = retValue.substring(1, retValue.length);
	  ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
	  retValue = retValue.substring(0, retValue.length-1);
	  ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function super_duper_doublecheck_delete(){
	var answer = confirm ("Are you sure you want to delete this? \nThis will delete this item along with all items inside it. \n\nThis operation is not undoable.")
	if (answer){
		
	}else{
		return false;
	}

}

function open_multimedia_archives_popup_window(url){
	var ma_popup_window=null
	config = 'scrollbars=no, resizable=no, toolbar=no, location=no, directories=no, status=no, menubar=no';
	ma_popup_window = window.open(url,'ma_window',config); 
}

function spawn_email_popup(section,subsection,sub_subsection){
	var email_popup_window=null
	config = 'scrollbars=no, resizable=no, toolbar=no, location=no, directories=no, status=no, menubar=no, width=500, height=400';
	email_popup_window = window.open('email_popup.php?s='+section+'&ss='+subsection+'&sss='+sub_subsection,'email_window',config);
	email_popup_window.focus();
}

function check_image_collection_form(form){
	if(trim(form.collection_name.value)==""){
		alert("Please enter a collection name");
		return false;
	}
	if(trim(form.collection_folder.value)==""){
		alert("Please enter a collection folder");
		return false;
	}
	return true;
}

//**********************************************store prints *******************************************
var detailed_url_to_show="";
var detailed_anchor="";
var magnifying_glass_rolled_over=false;

function check_paypal_print_button(form){
	if(trim(form.amount.value) == "" ){
		alert('Please choose dimensions for this print before attempting to purchase it.'); 
		return false;
	}
	return true;
}

function print_rolled_off_actions(){
	setTimeout("check_should_we_hide_magnifying_glass()",20);
}

function check_should_we_hide_magnifying_glass(){
	//alert("magnifying_glass_rolled_over: "+magnifying_glass_rolled_over);
	if(magnifying_glass_rolled_over==false){
		hide_magnifying_glass();
	}
}

function poster_rolled_over_actions(target_object,detailed_url){
	detailed_url_to_show=detailed_url;
	detailed_anchor=target_object;
	put_magnifying_glass_on(target_object,true);
}

function print_rolled_over_actions(target_object,detailed_url){
	detailed_url_to_show=detailed_url;
	detailed_anchor=target_object;
	put_magnifying_glass_on(target_object,false);
}

function print_clicked_actions(){
	show_detailed_picture(detailed_anchor,detailed_url_to_show);
	hide_magnifying_glass();
}

function magnifying_glass_rolled_over_actions(){
	magnifying_glass_rolled_over=true;
}

function magnifying_glass_rolled_off_actions(){
	magnifying_glass_rolled_over=false;
	hide_magnifying_glass();
}

function magnifying_glass_clicked_actions(){
	show_detailed_picture(detailed_anchor,detailed_url_to_show);
	hide_magnifying_glass();
}

function test(){
	alert("testing");
}

function put_magnifying_glass_on(target_object,is_poster_page){
	var anchor_object=document.getElementById(target_object);
	var anchor_location=findPos(anchor_object);
	var mag_div=document.getElementById("magnifying_glass_div");
	mag_div.style.visibility="visible";
	mag_div.style.position="absolute";
	mag_div.style.left=anchor_location[0];
	mag_div.style.top=anchor_location[1]-80;
	var mag_pic=document.getElementById("magnifying_glass_picture");
	mag_pic.style.width=anchor_object.offsetWidth;
	mag_pic.style.height=anchor_object.offsetHeight;
	
}

function hide_magnifying_glass(){
	var mag_div=document.getElementById("magnifying_glass_div");
	mag_div.style.visibility="hidden";
	magnifying_glass_rolled_over=false;
}

function show_detailed_picture(object_name,image_url){
	var detailed_div=document.getElementById("big_img");
	detailed_div.style.visibility="visible";
	detailed_div.style.position="absolute";
	
	//position the div
	var scroll_amount=get_page_scroll();
	
	//top
	var pic_height=400;
	var scroll_y=scroll_amount[1];
	if(winH > pic_height){
		var target_y=winH/2-pic_height/2+scroll_y;
	}else{
		var target_y=scroll_y;
	}
	detailed_div.style.top=target_y;
	
	//left
	var pic_width=600;
	var scroll_x=scroll_amount[0];
	if(winW > pic_width){
		var target_x=winW/2-pic_width/2+scroll_x;
	}else{
		var target_x=scroll_x;
	}
	detailed_div.style.left=target_x;
	detailed_div.innerHTML="<img src='"+image_url+"'><br /><br /><a style='cursor:pointer;' onclick='close_detailed_picture();'>X - close</a>";
}

function close_detailed_picture(){
	detailed_div=document.getElementById("big_img");
	detailed_div.style.visibility="hidden";
	detailed_div.innerHTML="";
}

function close_display_shipping_div(){
	shipping_div=document.getElementById("shipping_info");
	shipping_div.style.visibility="hidden";
	shipping_div.innerHTML="";
}

function display_shipping_div(message){
	var shipping_div=document.getElementById("shipping_info");
	shipping_div.style.visibility="visible";
	shipping_div.style.position="absolute";
	shipping_div.style.left='580px';
	shipping_div.style.top='50px';
	shipping_div.style.width='300px';
	shipping_div.innerHTML=message;
}
/***********************************************************navbar stuff******************************************/

function keep_navbar_open(){
	clearInterval(goodbye_navbar);
}

function open_navbar_menu(target_item,navbar_item_name){
	document.getElementById("navbar_html_holder").innerHTML="";
	var this_array=eval(navbar_item_name+"_navbar_items_array");
	this_link_array=eval(navbar_item_name+"_navbar_links_array");
	this_link_target_array=eval(navbar_item_name+"_navbar_links_target_array");
	
	if(this_array.length>0){
		keep_navbar_open();
		var item_height=20;
		var space_between_items=2;
		var button_location=findPos(target_item);
		
		//alert("number of array items:"+this_array.length);
		
		for(var i=0;i<this_array.length;i++){
			if(this_link_target_array[i] != ""){
				var link_target = "target="+this_link_target_array[i];
			}else{
				link_target = ""
			}
			var this_y=i*(item_height+space_between_items)-18;
			var this_style="position:absolute; left:"+button_location[0]+"px; top:"+this_y+"px; height:"+item_height+"px; ";
			
			
			var javascript_code=" onmouseover='keep_navbar_open(); this.className=navbar_rollover_class;' onmouseout='set_navbar_clear_out_timer(); this.className=base_navbar_class' ";
			//javascript_code+=" onclick='location.href=this_link_array["+i+"];' ";
			var this_html="<div class='navbar_dropdown_item' "+javascript_code+" style='"+this_style+"'><a href='"+this_link_array[i]+"' class='navbar_link' "+link_target+"><span style='height:100%; vertical-align:middle; color:white;'>"+this_array[i]+"</span></a></div>";
			document.getElementById("navbar_html_holder").innerHTML+=this_html;
		}
		
		
	}
	//alert("x:"+button_location[0]+","+"y:"+button_location[1]);
}

function set_navbar_clear_out_timer(){
	clearInterval(goodbye_navbar);
	goodbye_navbar=setTimeout("clear_out_navbar()",navbar_close_delay);
}
function clear_out_navbar(){
	document.getElementById("navbar_html_holder").innerHTML="";
}

function openMenu(target){
	var toShow = document.getElementById(target);
	toShow.style.display = "block";
}

function hideMenu(target){
	var toShow = document.getElementById(target);
	toShow.style.display = "none";
}

function setMenuText(target, newText){
	document.getElementById(target).innerHTML = newText;
}

function setValue(target, value){
	target.value=value;
	// sets the value of the hidden form element to the print size
}

/**************************************from quirksmode ********************************************/
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function get_page_scroll(){
	var x,y;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	my_output=new Array(x,y);
	return my_output;
}
