var checkflag = "false";

function check(field) {
	if (checkflag == "false")
	{
		for (i = 0; i < field.length; i++)
		{
			field[i].checked = true;
		}
		checkflag = "true";
		return "Uncheck All"; 
	}else{
		for (i = 0; i < field.length; i++)
		{
			field[i].checked = false;
		}
		checkflag = "false";
		return "Check All";
	}
}

function confirm_do()
{
	var confirmed = confirm("Are you sure you want to do that?");
	if(confirmed)
	{
		return true;
	}else{
		return false;
	}
}

function check_form(error, get_field)
{
	if(get_field=="")
	{
		alert(error);	
		return false;
	}else{
		return true;
	}

}

/*validate the contact form*/
function  validate_contact()
{
	if(document.contact.name.value!="")
	{
		var email_reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(email_reg.test(document.contact.email.value))
		{
			if(document.contact.body_txt.value!="")
			{					
				return true;
			}else{
				alert("Please enter content");
				return false;
			}
		}else{
			alert("Please enter a real email");
			return false;
		}
	}else{
		alert("Please enter your name");
		return false;
	}			
}		

/*this will get the style attributes of a css element - ussualyl a div or span */
function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

      
function load_admin(div, url_in)
{
	height = document.getElementById(div).offsetHeight + 100 + 'px';
	var url = url_in + '&height=' + height;
	window.location.href = url;
}			

/* Nav Hack for IE */
function startList() 
{
	if(document.all && document.getElementById)
	{
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI")
			{
				node.onmouseover=function()
				{
					this.className+=" over";
				}
				node.onmouseout=function()
				{
					this.className=this.className.replace
					(" over", "");
			 	}
			}
		}
	}
}
/* End Nav Hack for IE */

/*preload images function*/
var preloaded = new Array();
function preload_images()
{
    for (var i = 0; i < arguments.length; i++)
	{
        preloaded[i] = document.createElement('img');
        preloaded[i].setAttribute('src',arguments[i]);
    };
};

/*delete*/
function uploader_delete(file)
{
	var confirmed = confirm("Are you sure you want delete that file?");
	if(confirmed)
	{
		ajax('ajax/uploader_delete.php?file=' + file, 'sfd_status');
		document.getElementById('sfd_file_list_loader').innerHTML ="";
	}
}

