function check_frm_video(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	
	
	if(frm.title.value.length < 1){
		if (fsub == true)
			fld_focus = frm.title;
		fsub = false;
		err += ++ctr + ". Title \n";
	}
	
	if (frm.videoURL.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.videoURL;
		fsub = false;
		err += ++ctr + ". Video URL \n";
	}
	
	if (frm.videoOrder.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.videoOrder;
		fsub = false;
		err += ++ctr + ". Video Order \n";
	}
	
	var tags = document.getElementsByName('tag[]')
	var hasTagSelection = false;
	for (i = 0; i < tags.length; i++) {
		if(tags[i].checked){
			hasTagSelection = true;
			break;
		}
	}

    if(!hasTagSelection){
    	if (fsub == true)
			fld_focus = tags[0];
		fsub = false;
		err += ++ctr + ". Tag \n";
    }
	
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}
function check_frm_gallery(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if (frm.pic.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.pic;
		fsub = false;
		err += ++ctr + ". Pic \n";
	}
	
	if(frm.title.value.length < 1){
		if (fsub == true)
			fld_focus = frm.title;
		fsub = false;
		err += ++ctr + ". Title \n";
	}
	
	if(frm.imageOrder.value.length < 1){
		if (fsub == true)
			fld_focus = frm.imageOrder;
		fsub = false;
		err += ++ctr + ". Order \n";
	}
	
	var tags = document.getElementsByName('tag[]')
	var hasTagSelection = false;
	for (i = 0; i < tags.length; i++) {
		if(tags[i].checked){
			hasTagSelection = true;
			break;
		}
	}

    if(!hasTagSelection){
    	if (fsub == true)
			fld_focus = tags[0];
		fsub = false;
		err += ++ctr + ". Tag \n";
    }
	
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}

function check_frm_sponsor(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if(frm.name.value.length < 1){
		if (fsub == true)
			fld_focus = frm.name;
		fsub = false;
		err += ++ctr + ". Name \n";
	}
	
	if(frm.imageLink.value.length < 1){
		if (fsub == true)
			fld_focus = frm.imageLink;
		fsub = false;
		err += ++ctr + ". Link \n";
	}
	
	if(frm.imageOrder.value.length < 1){
		if (fsub == true)
			fld_focus = frm.imageOrder;
		fsub = false;
		err += ++ctr + ". Image Order \n";
	}
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}

function check_frm_cms(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if(frm.title.value.length < 1){
		if (fsub == true)
			fld_focus = frm.title;
		fsub = false;
		err += ++ctr + ". Title \n";
	}
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}
function check_frm_resources(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if(frm.title.value.length < 1){
		if (fsub == true)
			fld_focus = frm.title;
		fsub = false;
		err += ++ctr + ". Title \n";
	}
	
	var chks = document.getElementsByName('cat[]')
	var hasSelection = false;
	for (i = 0; i < chks.length; i++) {
		if(chks[i].checked){
			hasSelection = true;
			break;
		}
	}

    if(!hasSelection){
    	if (fsub == true)
			fld_focus = chks[0];
		fsub = false;
		err += ++ctr + ". Category \n";
    }
    
    
    var tags = document.getElementsByName('tag[]')
	var hasTagSelection = false;
	for (i = 0; i < tags.length; i++) {
		if(tags[i].checked){
			hasTagSelection = true;
			break;
		}
	}

    if(!hasTagSelection){
    	if (fsub == true)
			fld_focus = tags[0];
		fsub = false;
		err += ++ctr + ". Tag \n";
    }

	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
	
}


function check_frm_categories(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if(frm.cat_name.value.length < 1){
		if (fsub == true)
			fld_focus = frm.cat_name;
		fsub = false;
		err += ++ctr + ". Category Name \n";
	}
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}


function check_frm_admin_user(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if(frm.name.value.length < 1){
		if (fsub == true)
			fld_focus = frm.name;
		fsub = false;
		err += ++ctr + ". Name \n";
	}
	if(frm.username.value.length < 1){
		if (fsub == true)
			fld_focus = frm.username;
		fsub = false;
		err += ++ctr + ". Username \n";
	}
	if(frm.password.value.length > 1 && frm.rpassword.value.length > 1 ){
		if(frm.password.value != frm.rpassword.value){
			if(fsub == true) fld_focus = frm.password;
			fsub = false;
			err += ++ctr+". Passwords are not the same \n";
		}
		
	}
	else{
		if(fsub == true) fld_focus = frm.password;
		fsub = false;
		err += ++ctr+". Password \n";
	}
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}


function check_frm_tags(frm) {
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	
	if(frm.tag_name.value.length < 1){
		if (fsub == true)
			fld_focus = frm.tag_name;
		fsub = false;
		err += ++ctr + ". Tag Name \n";
	}
	
	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}


function check_frm_application_edit(frm) {
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	

	if (frm.proj_title.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.proj_title;
		fsub = false;
		err += ++ctr + ". Project Title \n";
	}
	
	if (frm.proj_fund_need.value.length < 1 || !IsNumeric(frm.proj_fund_need.value) ) {
		if (fsub == true)
			fld_focus = frm.proj_fund_need;
		fsub = false;
		err += ++ctr + ". Project Fund Need \n";
	}
	
//	if (frm.proj_fund_start.value.length < 1 || !IsNumeric(frm.proj_fund_start.value) ) {
//		if (fsub == true)
//			fld_focus = frm.proj_fund_start;
//		fsub = false;
//		err += ++ctr + ". Project Fund Start \n";
//	}
	
//	if (frm.age.value.length < 1 || !IsNumeric(frm.age.value) ) {
//		if (fsub == true)
//			fld_focus = frm.age;
//		fsub = false;
//		err += ++ctr + ". Age \n";
//	}
	
	
	
    var chks = document.getElementsByName('cat[]')
	var hasSelection = false;
	for (i = 0; i < chks.length; i++) {
		if(chks[i].checked){
			hasSelection = true;
			break;
		}
	}

    if(!hasSelection){
    	if (fsub == true)
			fld_focus = chks[0];
		fsub = false;
		err += ++ctr + ". Category \n";
    }


	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}

function check_frm_application(frm) {
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	if (frm.proj_pic.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.proj_pic;
		fsub = false;
		err += ++ctr + ". Project Pic \n";
	}

	if (frm.proj_title.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.proj_title;
		fsub = false;
		err += ++ctr + ". Project Title \n";
	}
	
	if (frm.proj_fund_need.value.length < 1 || !IsNumeric(frm.proj_fund_need.value) ) {
		if (fsub == true)
			fld_focus = frm.proj_fund_need;
		fsub = false;
		err += ++ctr + ". Project Fund Need \n";
	}
	
//	if (frm.proj_fund_start.value.length < 1 || !IsNumeric(frm.proj_fund_start.value) ) {
//		if (fsub == true)
//			fld_focus = frm.proj_fund_start;
//		fsub = false;
//		err += ++ctr + ". Project Fund Start \n";
//	}
	
//	if (frm.age.value.length < 1 || !IsNumeric(frm.age.value) ) {
//		if (fsub == true)
//			fld_focus = frm.age;
//		fsub = false;
//		err += ++ctr + ". Age \n";
//	}
	
	
	
    var chks = document.getElementsByName('cat[]')
	var hasSelection = false;
	for (i = 0; i < chks.length; i++) {
		if(chks[i].checked){
			hasSelection = true;
			break;
		}
	}

    if(!hasSelection){
    	if (fsub == true)
			fld_focus = chks[0];
		fsub = false;
		err += ++ctr + ". Category \n";
    }


	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}

function IsNumeric(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 limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function checkAll(elem, chks){
	if(elem.checked) {
		for (i = 0; i < chks.length; i++) {
			if(!chks[i].checked){
				chks[i].checked = true;
			}
		}
	}
	else{
		for (i = 0; i < chks.length; i++) {
			if(chks[i].checked){
				chks[i].checked = false;
			}
		}
	}
}

function check_reg_application(frm){
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";

	if (frm.name.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.name;
		fsub = false;
		err += ++ctr + ". Name \n";
	}
	
	if(frm.email.value.length < 1 || frm.email.value.indexOf('@') == -1){
		if(fsub == true) fld_focus = frm.email;
		fsub = false;
		err += ++ctr+". Email \n";
	}
	
	if(frm.password.value.length > 1 && frm.rpassword.value.length > 1 ){
		if(frm.password.value != frm.rpassword.value){
			if(fsub == true) fld_focus = frm.password;
			fsub = false;
			err += ++ctr+". Passwords are not the same \n";
		}
		
	}
//	else{
//		if(fsub == true) fld_focus = frm.password;
//		fsub = false;
//		err += ++ctr+". Password \n";
//	}
	
	
	

	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}


function check_frm_application_admin(frm) {
	var fsub = true, err, ctr = 0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";
	

	if (frm.proj_title.value.length < 1) {
		if (fsub == true)
			fld_focus = frm.proj_title;
		fsub = false;
		err += ++ctr + ". Project Title \n";
	}
	
	if (frm.proj_fund_need.value.length < 1 || !IsNumeric(frm.proj_fund_need.value) ) {
		if (fsub == true)
			fld_focus = frm.proj_fund_need;
		fsub = false;
		err += ++ctr + ". Project Fund Need \n";
	}
	
//	if (frm.proj_fund_start.value.length < 1 || !IsNumeric(frm.proj_fund_start.value) ) {
//		if (fsub == true)
//			fld_focus = frm.proj_fund_start;
//		fsub = false;
//		err += ++ctr + ". Project Fund Start \n";
//	}
	
//	if (frm.age.value.length < 1 || !IsNumeric(frm.age.value) ) {
//		if (fsub == true)
//			fld_focus = frm.age;
//		fsub = false;
//		err += ++ctr + ". Age \n";
//	}
	
	
	
    var chks = document.getElementsByName('cat[]')
	var hasSelection = false;
	for (i = 0; i < chks.length; i++) {
		if(chks[i].checked){
			hasSelection = true;
			break;
		}
	}

    if(!hasSelection){
    	if (fsub == true)
			fld_focus = chks[0];
		fsub = false;
		err += ++ctr + ". Category \n";
    }
    
    var tags = document.getElementsByName('tag[]')
	var hasTagsSelection = false;
	for (i = 0; i < tags.length; i++) {
		if(tags[i].checked){
			hasTagsSelection = true;
			break;
		}
	}

    if(!hasTagsSelection){
    	if (fsub == true)
			fld_focus = tags[0];
		fsub = false;
		err += ++ctr + ". Tags \n";
    }


	if (fsub == false) {
		alert(err);
		fld_focus.focus();
	}
	return (fsub);
}