function isNumberKey(evt) {

var charCode = (evt.which) ? evt.which : event.keyCode

if (charCode > 31 && (charCode < 48 || charCode > 57))

return false;



return true;

}

function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 

function chkPhoneNumber(strString)

// check for valid numeric strings

{

var strValidChars = "0123456789-";

var strChar;

var blnResult = true;



if (strString.length == 0) return false;

// test strString consists of valid characters listed above

for (i = 0; i < strString.length && blnResult == true; i++)

{

strChar = strString.charAt(i);

if (strValidChars.indexOf(strChar) == -1)

{

blnResult = false;

}

}

return blnResult;

}

	  

function check_form_register() {

if (document.register.first_name.value.length < 1) {

alert("Please Enter Your First Name");

document.register.first_name.focus()

return false;

}

if (document.register.last_name.value.length < 1) {

alert("Please Enter Your Last Name");

document.register.last_name.focus()

return false;

}

if (document.register.email.value.length < 1) {

alert("Please Enter Your Email");

document.register.email.focus()

return false;

}



if (document.register.email.value.indexOf("@") < 2) {

alert("Please Enter Valid Email Address");

document.register.email.focus()

return false;

}

if (document.register.username.value.length < 1) {

alert("Please Enter Your Username");

document.register.username.focus()

return false;

}

if (document.register.password.value.length < 1) {

alert("Please Enter Your Password");

document.register.password.focus()

return false;

}



if ((document.register.password.value.length < 6) || (document.register.password.value.length > 40)) {

alert("Password length needs to be between 6-40 characters");

document.register.password.focus()

return false;

}

if (document.register.password.value != document.register.confirm_password.value) {

alert("Values Mismatch confimation of Password.")

document.register.confirm_password.focus()

return false;

}

if (document.register.a1.checked == false && document.register.a2.checked == false) {

alert("Select account type");

return false;

}	

function hideAndDisplayOrganization(radioId)

{

	//alert(radioId);

	if(radioId == 'a1')

		document.getElementById('org').style.display = 'none';

	else

		document.getElementById('org').style.display = 'block';

}



if (document.register.sc.value.length < 1) {

alert("Please Enter Your Security Code");

document.register.sc.focus()

return false;

}

return true;

}	  





function check_form_add_video() {



if (document.form.sport.selectedIndex < 1) {

alert("Please Select Sport Category");

document.form.sport.focus()

return false;

}



if (document.form.title.value.length < 1) {

alert("Please Enter Your Title");

document.form.title.focus()

return false;

}



if (document.form.code.value.length < 1) {

alert("Please Enter Youtube Embedded Code");

document.form.code.focus()

return false;

}





if (document.form.thumbnail.value.length < 1) {

alert("Please Upload Video Thumbnail");

document.form.thumbnail.focus()

return false;

}



return true;

}	  







function CheckFormComments() {



if (document.form_comments.name.value.length < 1) {

alert("Please Enter Name");

document.form_comments.name.focus()

return false;

}



if (document.form_comments.email.value.length < 1) {

alert("A valid email address is required to complete this comment. Please keep in mind that it will not be given out or displayed in this comment");

document.form_comments.email.focus()

return false;

}



if (document.form_comments.comments.value.length < 1) {

alert("Please Enter Comments");

document.form_comments.comments.focus()

return false;

}



return true;

}	  



function check_form_organisation() {

	//alert(document.organisation.a1.checked);

	//alert(document.getElementById('a1').checked);

	//return false;

if (document.organisation.name.value.length < 1) {

alert("Please Enter Orgnization Name");

document.organisation.name.focus()

return false;

}

if(document.organisation.address.value.length < 1) {

alert("Please Enter Organization Address");

document.organisation.address.focus()
return false;
}

if(document.organisation.state.value.length < 1){
alert("Please Enter State/Zip Code");
document.organisation.state.focus()
return false;
}

if (document.organisation.phone.value.length < 1) {

alert("Please Enter Your Phone Number");

document.organisation.phone.focus()

return false;

}

if (document.organisation.phone.value.length >0) {

	

	if(chkPhoneNumber(document.getElementById('phone').value)==false)

	{

		alert('Enter correct phone number');

		document.organisation.phone.focus()

		return false;

	}

}


if (document.organisation.website.value.length < 1) {

alert("Please Enter Website URL ");

document.organisation.website.focus()

return false;
}

if (document.organisation.website.value.length > 0) {

if(isValidURL(document.getElementById('website').value)==false)
{
	alert('Enter valid URL');
	document.organisation.website.focus()
	return false;
}
}
	
if (document.organisation.idnum.value.length < 1) {

alert("Please Enter Your Employee-ID ");

document.organisation.idnum.focus()

return false;

}
if (document.organisation.organization.value.length < 1) {

alert("Please Enter the answer ");

document.organisation.organization.focus()

return false;

}

if(document.organisation.about.value.length < 1) {
alert("Please give brief description about your organization");
document.organisation.about.focus()
return false;
}


if (document.organisation.contact.value.length < 1) {

alert("Please Enter Your Organization Contact Number");

document.organisation.contact.focus()

return false;

}

if (document.organisation.contact.value.length >0) {

	

	if(chkPhoneNumber(document.getElementById('contact').value)==false)

	{

		alert('Enter correct Organization Contact number');

		document.organisation.contact.focus()

		return false;

	}

}

if (document.organisation.title.value.length < 1) {
	
alert("Please enter title");
document.organisation.title.focus()
return false;
}


if (document.organisation.email.value.length < 1) {

alert("Please Enter Your Email");

document.organisation.email.focus()

return false;

}

if (document.organisation.email.value.indexOf("@") < 2) {

alert("Please Enter Valid Email Address");

document.organisation.email.focus()

return false;

}

if (document.organisation.username.value.length < 1) {

alert("Please Enter Your Username");

document.organisation.username.focus()

return false;

}



if (document.organisation.password.value.length < 1) {

alert("Please Enter Your Password");

document.organisation.password.focus()

return false;

}



if ((document.organisation.password.value.length < 6) || (document.organisation.password.value.length > 40)) {

alert("Password length needs to be between 6-40 characters");

document.organisation.password.focus()

return false;

}



if (document.organisation.password.value != document.organisation.cpassword.value) {

alert("Values Mismatch confirmation of Password.")

document.organisation.cpassword.focus()

return false;

}

if (document.organisation.sc.value.length < 1) {

alert("Please Enter Your Security Code");

document.organisation.sc.focus()

return false;

}

if (document.organisation.a1.checked == false && document.organisation.a2.checked == false) {

alert("Select account type");

return false;

}

return true;

}	  





function hideAndDisplayOrganization(radioId)

{

	//alert(radioId);

	if(radioId == 'a1')

		document.getElementById('org').style.display = 'none';

	else

		document.getElementById('org').style.display = 'block';

}

