// Copyright (c) 2009 Firestorm Online Ltd 
// Author: Baz Firestorm
// For details, visit our web site web site: http://www.firestorm-online.com/

var $ = function(id) { return document.getElementById(id); };


function FP_preloadImgs() 
{//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FS_openBrWindow(theURL,winName,features)
{
  window.open(theURL,winName,features); 
  return false;
}
function chkNumeric(strString)
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function validateLogin(){
if ($('f_em').value == '')
	{
		alert('Your email is a required field');
		$('f_em').style.backgroundColor = 'pink';
		document.l_form.f_em.focus();
		return false;
	}
if ($('f_pw').value == '' || $('f_pw').value.length < 6)
	{
		alert('Your password must be at least 6 characters long');
		$('f_pw').style.backgroundColor = 'pink';
		document.l_form.f_pw.focus();
		return false;
	}
}
function valSU(){
	if ($('f_user').value == '' || $('f_user').value.length < 3)
	{
		alert('Please choose a user ID (ie. the carp catcher');
		$('f_user').style.backgroundColor = 'pink';
		document.su_form.f_user.focus();
		return false;
	}
	if ($('f_name').value == '' || $('f_name').value.length < 3)
	{
		alert('Your name is a required field');
		$('f_name').style.backgroundColor = 'pink';
		document.su_form.f_name.focus();
		return false;
	}
	if ($('f_mail').value == '')
	{
		alert('Your email address is a required field');
		$('f_mail').style.backgroundColor = 'pink';
		document.su_form.f_mail.focus();
		return false;
	}
	if ($('f_county').options[$('f_county').selectedIndex].value == 'Please choose')
	{
		alert('Please select your county');
		$('f_county').style.backgroundColor = 'pink';
		document.su_form.f_county.focus();
		return false;
	}
	if ($('f_pw').value == '' || $('f_pw').value.length < 5)
	{
		alert('Your password should be 6 charcters or more');
		$('f_pw').style.backgroundColor = 'pink';
		document.su_form.f_pw.focus();
		return false;
	}
	if ($('f_pw').value == $('f_pwc').value)
	{
		//alert('true');
	}
		else
			{
			alert('Your passwords do NOT match, please check and try again');
			$('f_pwc').style.backgroundColor = 'pink';
			document.su_form.f_pwc.focus();
			return false;
			}
}
function valContactForm(){
	if ($('c_name').value == '')
	{
		alert('Your name is a required field');
		$('c_name').style.backgroundColor = 'pink';
		document.c_form.c_name.focus();
		return false;
	}
	if ($('c_em').value == '')
	{
		alert('Your email is a required field');
		$('c_em').style.backgroundColor = 'pink';
		document.c_form.c_em.focus();
		return false;
	}
	if ($('c_ph').value == '')
	{
		alert('Your phone number is a required field');
		$('c_ph').style.backgroundColor = 'pink';
		document.c_form.c_ph.focus();
		return false;
	}
		else
			{
			if (chkNumeric($('c_ph').value ) == false)
				{
					alert('Your phone number must contain numbers only');
					$('c_ph').style.backgroundColor = 'pink';
					document.c_form.c_ph.focus();
					return false;
				}
			}
	if ($('c_mes').value == '')
	{
		alert('Your message is a required field');
		$('c_mes').style.backgroundColor = 'pink';
		document.c_form.c_mes.focus();
		return false;
	}
}
function Checkfiles(){
     var fup = document.getElementById('ccupload').value;
     var ext = fup.substring(fup.lastIndexOf('.') + 1);
     
     if (fup == '')
     {
     alert('Please choose a file to upload');
     return false;
     }
 
     if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG")
 
      {
 				$('isub').style.display = 'none';
 				$('loadingpleasewait').style.display = '';
                return true;
 
      }         
 
      else
 
      {
 
                alert("Upload Gif or Jpg images only");
                document.getElementById('ccupload').focus();
 				$('isub').style.display = '';
 				$('loadingpleasewait').style.display = 'none';
                return false;
 
       }
 
}
function Checkdetail(){
	if ($('species').options[$('species').selectedIndex].value == '0')
	{
		alert('Please select the species of fish (ie.. common carp, mirror carp etc)');
		$('species').style.backgroundColor = 'pink';
		document.u_form.species.focus();
		return false;
	}
	if ($('bait').value == '')
	{
		alert('Please enter the bait used to catch the fish');
		$('bait').style.backgroundColor = 'pink';
		document.u_form.bait.focus();
		return false;
	}
}
function remChars(){
var tl = $('text').value.length
var tf = $('text').value
if(tl > 3000)
	{
		$('charsRemaining').innerHTML = '0';
		$('text').value = String(tf).substring(0,3000);
	}
		else
			{
				$('charsRemaining').innerHTML = 3000 - tl;
			}

}
