//THE FOLLOWING SCRIPTS ARE USED THROUGHOUT THE WEBSITE.  IT IS INCLUDED IN GLOBAL. MANY VARIABLES ARE DECLARED IN CONFIGURE.PHP


//FUNCTION CHECKREQUIRED: CHECKS IF REQUIRED FIELDS IN A FORM WERE CORRECTLY FILLED

function checkrequired(which) { //onSubmit="return checkrequired(this)"
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.id.substring(0,3)=="req") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(3,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return true;
}
//  End -->

//FUNCTION CHECKMAIL: CHECKS IF AN E-MAIL ADDRESS HAS BEEN CORRECTLY INTRODUCED 
function checkMail()
{
	var x = document.form_get.t_email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(x)){
	alert('Incorrect email address');}
}

//FUNCTION POPTASTIC: CREATES NEW WINDOWS
var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','height=400,width=400,left=50, top=20,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}


//FUNCTION EDIT: DISPLAYS MESSAGES FOR EDIT/CHANGE RECORD IN DB 
function edit(url, cond){
if (cond=="delete"){

 if (confirm("Are you sure you want to delete this movie?")){
 	document.location.href=url;	
 }
}

if (cond=="status"){
	if (confirm("Are you sure you want to activate/deactivate this ad?")){
	document.location.href=url;
	}
}
}

function expandCollapseFrame(name, value, DIR_WS_URL){  //This function is used throughout the website to hide or show the left frame, which contains the main navigation panel
	if (value==0){
		parent.document.body.cols='155,*';
		document.getElementById(name).src=DIR_WS_URL + "images/hide_nav_frame.gif";
		document.getElementById(name).alt="Click to Hide Navigation Panel";
		document.getElementById(name).value=1;
		
	} else if (value==1){
		parent.document.body.cols='0,*';
		document.getElementById(name).src=DIR_WS_URL + "images/show_nav_frame.gif";
		document.getElementById(name).alt="Click to Show Navigation Panel";
		document.getElementById(name).value=0;
	}

}
