<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->		
function getChange(){
	document.getElementById('file_name').style.display='none';
	document.getElementById('file_link').innerHTML='<input type="checkbox" checked="checked"/> '+document.getElementById('fileField').value+'';
	document.getElementById('file_link').style.display='block';
}

 var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
		for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
		var tempobj=checkobj.form.elements[i]
		if(tempobj.type.toLowerCase()=="submit")
		tempobj.disabled=!checkobj.checked;
		}
	}
}

function defaultagree(el){
		if (!document.all&&!document.getElementById){
		if (window.checkobj&&checkobj.checked) {
		return true;
		}
		else{
		alert("Please Read/Accept our Terms of Service/Agreement to	continue.");
		return false;
		}
	}
}
$(document).ready(function() {
   // $("input#siteTypeSite").attr({ checked: "checked" });
   // $("input#buttonType5").attr({ checked: "checked" });
  //  $("input#siteTypeRegSite").attr({ checked: "checked" });

    $("#regForm").validate({

        messages: {
			 Email: {
                email: "Enter a valid email address",
                required: "Can't leave email address empty",
                minlength: "Enter a valid email address"
            },
			Password: {
                required: "Enter a password",
                minlength: "Enter a valid password(minimum 6 chars)",
                maxlength: "Enter a valid password(minimum 6 chars)"
            },
			Name: {
				required: "Enter a Name",
                minlength: "Required, at least 2 characters"
			}			         
            
        },

        errorPlacement: function(error, element) {
            error.appendTo(element.next("div"));
        },

        submitHandler: function() {
          //  $("input#submitRegistration").attr({ disabled: "disabled" });
            document.regForm.submit();
        }

    });

   
});

function checkData(){
	var bol=false;
	if(isEmpty(document.getElementById('entry_title').value)){
		document.getElementById('entry_title_div').innerHTML='Please enter Title';
		bol=true;
	}else{
		document.getElementById('entry_title_div').innerHTML='';
	}
	if(isEmpty(document.getElementById('fileField').value)){
		if(isEmpty(document.getElementById('path').value)){
			document.getElementById('filefieldname_div').innerHTML='Please specify File';
			bol=true;
		}
	}else{
		document.getElementById('filefieldname_div').innerHTML='';
	}
	if(isEmpty(document.getElementById('short_description').value)){
		document.getElementById('short_description_div').innerHTML='Please enter Description';
		bol=true;
	}else{
		document.getElementById('short_description_div').innerHTML='';
	}
	if(bol){
		return false;
	}else{
		document.getElementById('progress').innerHTML='This might take a few minutes. Please wait for the upload to complete';
		return true;
	}
}
function isEmpty(inputVal) {if (inputVal == null || inputVal=="")
{ return true} else { return false }}
var msg='Please provide ';
function validateForm(){
	if(isEmpty(document.getElementById('fname').value)){
		document.getElementById('err_div').innerHTML=msg+'Fisrt Name';
		return false;
	}
	if(isEmpty(document.getElementById('lname').value)){
		document.getElementById('err_div').innerHTML=msg+'Last Name';
		return false;
	}
	if(isEmpty(document.getElementById('email').value)){
		document.getElementById('err_div').innerHTML=msg+'Valid Email Address';
		return false;
	}
	if(isEmpty(document.getElementById('password').value)){
		document.getElementById('err_div').innerHTML=msg+'Valid Email Address';
		return false;
	}
	if(!isEmpty(document.getElementById('re_password').value)){
		if(document.getElementById('password').value!=document.getElementById('re_password').value){
			document.getElementById('err_div').innerHTML='Password does not match';
			return false;
		}
	}
}
function enableAgree(amt){

		if(amt>450){
			document.getElementById( 'active' ).style.display='';
			document.getElementById( 'disabled' ).style.display='none';
		}	
}
function setField(input){
		document.getElementById('file_name').style.display='block';
}
