function Chk_Empty()
{
	
 var msg1="------------------------------------     \nThe following fields are empty:";
 var msg2="";
 var msg3="\n------------------------------------     ";
 var date;
usrname=trimAll(document.getElementById('uname').value);
if(usrname=="")
 {
   document.getElementById('uname').value="";
   msg2=msg2+"\n - User Name";
 }

usremail=trimAll(document.getElementById('email').value);
 if(usremail=="")
 {
   document.getElementById('email').value="";
   msg2=msg2+"\n - Email Address";
 }
 
 if(document.frm_registration.password.value=="")
 {
   msg2=msg2+"\n - Password";
 }
 if(document.getElementById("verify_password").value=="")
 {
   msg2=msg2+"\n - Verify Password";
 }
 
 
 
 if(document.getElementById("day").value=="" || document.getElementById("month").value=="" || document.getElementById("year").value=="")
 {
   msg2=msg2+"\n - Date of Birth";
 }
 
	
 if(msg2!="")
 {
   alert(msg1+msg2+msg3);
   return false;
 }
 
  if(document.frm_registration.password.value.length<6)
 {
    alert("Password should be atleast six character!");
	document.getElementById("verify_password").focus();
	return false;
 }
 
 
 if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value)) && document.getElementById('email').value!="")
	{
		alert("Enter a valid email address!");
		document.getElementById('email').focus();
		return false;
	}

 if(document.frm_registration.password.value!=document.frm_registration.verify_password.value)
 {
    alert("Password does not match!");
	document.getElementById("verify_password").focus();
	return false;
 }
 if(document.getElementById("is_agree").checked==false)
 {
   alert("For registration you must accept our terms/conditions!");
   return false;
 }
 
 else
 {
   return true;
 }
}


function addLoadEvent(func) {


  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
	window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {

	var inputs = document.getElementsByTagName("input");
	
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint

			inputs[i].onfocus = function () {

				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
				/*useralreadyexist(this.id+'exist',this.name,this.value)*/
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}


	var textareas = document.getElementsByTagName("textarea");
	for (var k=0; k<textareas.length; k++){
		if (textareas[k].parentNode.getElementsByTagName("span")[0]) {
			textareas[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			textareas[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}

function updateCharCount( textField, displayArea, maxChars ){
if ( textField.value.length > maxChars ){
textField.value = textField.value.slice(0, maxChars);
}
displayArea.innerHTML = textField.value.length+" characters (maximum of "+maxChars+")";
}

/*function updateCharCountpass( textField, displayArea, minChars ){
if ( textField.value.length < minChars ){
textField.value = textField.value.slice(0, minChars);
}
displayArea.innerHTML = textField.value.length+" characters (minimum of "+minChars+")";
}*/


function timeDifference(laterdate,earlierdate) {
    var difference = laterdate.getTime() - earlierdate.getTime();

    var daysDifference = Math.floor(difference/1000/60/60/24);
    difference -= daysDifference*1000*60*60*24
    var hoursDifference = Math.floor(difference/1000/60/60);
    difference -= hoursDifference*1000*60*60
    var minutesDifference = Math.floor(difference/1000/60);
    difference -= minutesDifference*1000*60
    var secondsDifference = Math.floor(difference/1000);

    document.write('difference = ' + daysDifference + ' day/s ' + hoursDifference + ' hour/s ' + minutesDifference + ' minute/s ' + secondsDifference + ' second/s ');
}

var laterdate = new Date();     // 1st January 2000
var earlierdate = new Date(1998,2,13);

function trimAll(sString) 
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function Chk_validate()
{
 var msg1="------------------------------------     \nThe following fields are empty:";
 var msg2="";
 var msg3="\n------------------------------------     ";
 var date;
 
page_url=trimAll(document.getElementById('pageurl').value);

if(page_url=="")
 {
   document.getElementById('pageurl').value="";
   msg2=msg2+"\n - News URL";
 }

 news_tit=trimAll(document.getElementById('news_title').value);
 if(news_tit=="")
 {
   document.getElementById('news_title').value="";
   msg2=msg2+"\n - News Title";
 }
	

news_desc=trimAll(document.getElementById('news_description').value);

if(news_desc=="")
 {
   document.getElementById('news_description').value="";
   msg2=msg2+"\n - News Descripton";
 }
 	
 if(document.frmaddnews.news_category.value=="")
 {
   msg2=msg2+"\n - News Category";
 }
 
/*  if(document.getElementById("news_category").value=="")
 {
   msg2=msg2+"\n - News Category.";
 }*/
 	
	
	if(msg2!="")
	 {
	   alert(msg1+msg2+msg3);
	   return false;
	 }
	  else
	 {
	   return true;
	 }
}

function Chk_Contact()
{
 var msg1="------------------------------------     \nThe following fields are empty:";
 var msg2="";
 var msg3="\n------------------------------------     ";
 var date;
 if(document.getElementById("contact_name").value=="")
 {
   msg2=msg2+"\n - Contact Name";
 }
 if(document.getElementById("contact_email").value=="")
 {
   msg2=msg2+"\n - Contact Email";
 }
 if(document.getElementById("contact_subject").value=="")
 {
   msg2=msg2+"\n - Contact Subject";
 }
 
  if(document.getElementById("contact_message").value=="")
 {
   msg2=msg2+"\n - Conatct Message";
 }
 	
	 if(msg2!="")
	 {
	   alert(msg1+msg2+msg3);
	   return false;
	 }
	 
	
 if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('contact_email').value)) && document.getElementById('contact_email').value!="")
	{
		alert("Please enter a valid email address!");
		document.getElementById('contact_email').focus();
		return false;
	}

	 
	
	   return true;
	
}


function submitfrm(time,timenextmonth,frmname)
	{
	
	document.getElementById('date_sub').value=time;
	document.getElementById('date_sub_next').value=timenextmonth;
	document.getElementById(frmname).submit();
	}

function submitsearch(value,frmname,args,pageindex)
	{
		if(args!="")
		{
			var strar=args;
		}else
		{
			var strar="";
		}
		
		if(value=="hitcount" && args=="sort/add_date/")
		{
			 var strar="";
		}
		if(value=="id" && args=="sort/add_date/")
		{
			 var strar="";
		}
		if(value=="id" && args=="sort/hitcount/")
		{
			 var strar="";
		}
		if(value=="add_date" && args=="sort/hitcount/")
		{
			 var strar="";
		}
		if(value=="hitcount" && args=="sort/add_date/")
		{
			 var strar="";
		}
		
		if(value=="id")
		window.location.href=frmname+pageindex;
		else
		window.location.href=frmname+"sort/"+value+"/"+strar+pageindex;
		args="";
		value="";
		//document.getElementById(frmname).submit();
	}

function checksession(rule)
	{
		alert('Please login to '+ rule +' this!');
		return false;
	}


function submitindex(val,frmname)
	{
	document.getElementById('sportcat').value=val;
	document.getElementById(frmname).submit();
	}

function uploadpic()
	{
       document.getElementById("frmdiv").style.display = 'none'; 
		document.getElementById("frmimg").style.display = '';
		
	   // document.frmuploadpic.submit();
		
	  	//document.getElementById("frmdiv").style.display = '';
		//document.getElementById("frmimg").style.display = 'none';
		
	//	document.frameupload.submit();
		
	}