
//Pop Up
function popup(theURL,winName,features) {
	window.open(theURL,winName,features);
}


function CheckSearch() { 
	searchfield = document.searchform.clsearch.value
    if (searchfield.length == 0 || searchfield.toUpperCase() == " ENTER SEARCH TERM"){
        alert('Please enter a Search Term');
		return false;
	}
	else {
        return true;
    }
}

function clearfield(thisfield){ 
	thisfield.value = "";
}

function CheckSearchDrop() { 
	searchdrop = document.searchdrop.cl.value
    if (searchdrop == 0 ){
        alert('Please Choose a Player');
		return false;
	}
	else {
        return true;
    }
}

function ConForm()
{    
	var msg,submitFlag, f;
	msg = "";
	submitFlag = 0;
	f = document.contform;
	                 
	if(f.email.value.indexOf("@") == -1 || f.email.value.indexOf(".") == -1 || f.email.value ==  "") 
	{	
    	msg = msg +  "Please enter a valid e-mail address\n";
		submitFlag = 1;
	}
	
	if(f.name.value ==  "")
	{
		msg= msg + "Please enter your name\n";
		submitFlag = 1;
	}
	
	if(f.name.value ==  "")
	{
		msg= msg + "Please enter your enquiry\n";
		submitFlag = 1;
	}
	
			
	if(submitFlag == "1")
	{
		alert(msg);
		return (false);
	}

	else 
	{
	      return (true);
	}
}


function CheckClForm()
{    
	var msg,submitFlag, f;
	msg = "";
	submitFlag = 0;
	f = document.clientprofile;
	                 
	if(f.fname.value ==  "")
	{
		msg= msg + "Please enter a Firstname\n";
		submitFlag = 1;
	}

	if(f.sname.value ==  "")
	{
		msg= msg + "Please enter a Surname\n";
		submitFlag = 1;
	}
	
	if(f.tposition.value ==  "")
	{
		msg= msg + "Please enter a Position\n";
		submitFlag = 1;
	}
			
	if(f.club.value ==  "")
	{
		msg= msg + "Please enter a Club\n";
		submitFlag = 1;
	}
			
	if(submitFlag == "1")
	{
		alert(msg);
		return (false);
	}
	
}


function CheckLogForm()
{    
	var msg,submitFlag, f;
	msg = "";
	submitFlag = 0;
	f = document.loginform;
	                 
	if(f.username.value ==  "")
	{
		msg= msg + "Please enter a Username\n";
		submitFlag = 1;
	}

	if(f.password.value ==  "")
	{
		msg= msg + "Please enter a Password\n";
		submitFlag = 1;
	}
	
			
	if(submitFlag == "1")
	{
		alert(msg);
		return (false);
	}
}



function confirmDel(str1){
	var msg = "Are you sure you want to delete this client?";
	if (confirm(msg)) 	{
		document.location.href = 'clients_profiles_update.asp?delete=true&cl='+str1;
	} 
}

function confirmDelNews(str1){
	var msg = "Are you sure you want to delete this News Item?";
	if (confirm(msg)) 	{
		document.location.href = 'news-story-update.asp?delete=true&id='+str1;
	}
}

function confirmDelPress(str1){
	var msg = "Are you sure you want to delete this Press Release?";
	if (confirm(msg)) 	{
		document.location.href = 'press-edit-update.asp?delete=true&id='+str1;
	} 
}

// Change Client Order
function ChangeClientOrder(str1, str2, str3){
	
	var cur_client_no;
	var new_client_no;
	var client_to_change;
	
	//Current Client Number
	cur_client_no = str2;
	
	// New Client Number
	new_client_no = document.getElementById('clientorder' + str1).value;
	
	// Loop through records
	for (i=0;i<=str3-1;i++){
		
	client_to_change = document.getElementById('clientorder' + i).value;
	document.getElementById('clientorder' + i).setAttribute('class','');
	document.getElementById('clientorder' + i).className = '';
	
		if (new_client_no==client_to_change){
			
			document.getElementById('clientorder' + i).value = cur_client_no;
			document.getElementById('clientorder' + i).setAttribute('class','changecolor');
			document.getElementById('clientorder' + i).className = 'changecolor';
			
			document.getElementById('clientorder' + str1).value = new_client_no;
			document.getElementById('clientorder' + str1).setAttribute('class','');
			document.getElementById('clientorder' + str1).className = '';
			
		}
		
	}
		
}

// Determine Browser Height and Width definition

function GetHeightDef()
{

	if (self.innerHeight){ // FF and Safari
		HeightDef = self.innerHeight;
		WidthDef = self.innerWidth;
	}

	else if (document.documentElement && document.documentElement.clientHeight) { // IE 6 
		HeightDef = document.documentElement.clientHeight;
		WidthDef = document.documentElement.clientWidth;
	}

	else if (document.body){ // IE
		HeightDef = document.body.clientHeight;
		WidthDef = document.body.clientWidth;
	}

}





// Open Div

function openDiv(str1)

{

	GetHeightDef();

	// Set the height of the opaque div to the height of the entire page
	//document.getElementById('opaquediv').style.height = (HeightDef - 0) + "px";
	document.getElementById('opaquediv').style.height = document.body.scrollHeight + "px";
	document.getElementById('opaquediv').style.width = document.body.clientWidth + "px";

	// Show opaque div
	document.getElementById('opaquediv').className = "block";
	document.getElementById(str1).className = "block";

	positionDiv(str1);

}





// Position Inner Div and set new width/height on resize/scroll

function positionDiv(str1){

	var divtop;
	var divleft;
	var box;

	box = document.getElementById(str1);
	
	GetHeightDef();
	
	// Set position of div
	if (box.className != "hide"){

		// Calculate top and left position depending on browser window and scroll

		if (self.innerHeight){ // FF and Safari
			divtop = ((HeightDef/2) - (box.offsetHeight/2)) + self.pageYOffset ;
			divleft = (self.innerWidth/2) - (box.offsetWidth/2);
		}

		else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 
			divtop = ((HeightDef/2) - (box.offsetHeight/2)) + document.documentElement.scrollTop;
			divleft = (WidthDef/2) - (box.offsetWidth/2);
	    }

		else if (document.body){ // IE
			divtop = ((HeightDef/5) - (box.offsetHeight/2)) + document.body.scrollTop;
			divleft = (WidthDef/3) - (box.offsetWidth/2);
		}

		// set minimum top position

		if (divtop < 50){
			divtop = 50;
	    }
		

		// Set top and left
		box.style.top = (divtop - 30) + "px";
		box.style.left = divleft + "px";

		// Set the height of the opaque div to the new height of the entire page
		//document.getElementById('opaquediv').style.height = (HeightDef - 0) + "px";
		document.getElementById('opaquediv').style.height = document.body.scrollHeight + 70 + "px";
		document.getElementById('opaquediv').style.width = document.body.clientWidth + "px";

	}

}





function closeDivs(str1){

	document.getElementById(str1).className = "hide";
	document.getElementById('opaquediv').className = "hide";

}