function init()
{
	$("#News").load("output.php?Sec=News");
}

function ReadNews(ID)
{
	$("#News").load("output.php?Sec=ReadNews&id="+ID);
}

function sendContact()
{
	if (document.contact.contactbox.value){
		if(document.contact.firstname.value){
			if(document.contact.lastname.value){
				if(IsEmail(document.contact.email.value)==true){
					document.contact.submit();
				} else {alert ('Please enter a valid email address'); document.contact.email.focus();return false;}
			} else {alert ('Please enter Last Name'); document.contact.lastname.focus();return false;}
		} else {alert ('Please enter First Name'); document.contact.firstname.focus();return false;}
	} else {alert ('Select Departments'); document.contact.contactbox.focus(); return false;}
}

function forgotPassword()
{
	if(IsEmail(document.forgot.femail.value)==true){
		document.forgot.submit();
	} else {alert ('Please enter a valid email address'); document.forgot.femail.focus();return false;}
}

function dologin()
{
	if (document.login.username.value){
		if (document.login.password.value){
			document.login.submit();
		} else {alert ('Please enter password'); document.login.password.focus();return false;}
	} else {alert ('Please enter username'); document.login.username.focus();return false;}
}

function AboutEdit(id)
{
	$("#about").load("/output.php?Sec=AboutMyself&todo=edit&id="+id);
}

function UploadPic(id)
{
	$("#about").load("/output.php?Sec=AboutMyself&todo=editpic&id="+id);
}

function AboutSave(id)
{
	$("#aboutform").ajaxSubmit(
		function()
		{
			$("#about").load("/output.php?Sec=AboutMyself&todo=show&id="+id);
		}
	);
}

function AboutUSave(id)
{
	$("#aboutform").ajaxSubmit(
		function()
		{
			$("#about").load("/output.php?Sec=AboutMyself&todo=show&id="+id);
			$("#swnpic").css("background","url(/media/userfiles/pictures/"+id+"_small.jpg) center no-repeat");
		}
	);
}

function IsEmail(sText)
{
	var at="@"
	var dot="."
	var lat=sText.indexOf(at)
	var lstr=sText.length
	var ldot=sText.indexOf(dot)
	if (sText=="" || sText==null){ return false }
	if (sText.indexOf(at)==-1 || sText.indexOf(at)==0 || sText.indexOf(at)==lstr){ return false }
	if (sText.indexOf(dot)==-1 || sText.indexOf(dot)==0 || sText.indexOf(dot)==lstr){ return false }
	if (sText.indexOf(at,(lat+1))!=-1){ return false }
	if (sText.substring(lat-1,lat)==dot || sText.substring(lat+1,lat+2)==dot){ return false }
	if (sText.indexOf(dot,(lat+2))==-1){ return false }
	if (sText.indexOf(" ")!=-1){ return false }
 	return true					
}


var currentMovie = "";
var initMovie = false;
function setMovie(url, id, cat, lst){
	 
	 cache = url+id+cat;
	 if(currentMovie == cache){
	  return;
	 } 
	 currentMovie = cache;
	
	document.getElementById('flvplayer').SetVariable('changeMovie',true);
	document.getElementById('flvplayer').SetVariable('nMovie',url);
//	alert("ID: "+id);
//	alert("CAT: "+cat);
	$("#moviebox").show("slow");
	$("#moviecat").show();
	if(lst==1) { $("#wtplayer").show(); }
	$("#movieinfo").load("/output.php?Sec=MovieInfo&id="+id);
	$("#moviecategory").load("/output.php?Sec=MoreVideos&id="+cat);
}

function ismaxlength(obj)
{
	var mlength=obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength) obj.value=obj.value.substring(0,mlength)
}

function uploaderSubmit()
{
	if (document.uploader.title.value){
		if(document.uploader.description.value){	
			window.open ("continue_upload.php","Upload","menubar=0,resizable=0,width=400,height=300");
			document.uploader.submit();
		} else {alert ('Please enter a Movie Description'); document.uploader.description.focus();return false;}
	} else {alert ('Please enter a Movie Title'); document.uploader.title.focus();return false;}

}