function openSimplePopup(winName) {
		var popup = window.open('/Forms/'+winName+'.aspx',winName,'top=25,left=25,width=600,height=475,scrollbars=no,menu=no');
	    return popup != null && typeof(popup) != "undefined";	
	}
	
	
function openPopup(winName) {
		var popup = window.open('/Forms/'+winName+'.aspx',winName,'top=25,left=25,width=810,height=600,scrollbars=yes,menu=no');
		return popup != null && typeof(popup) != "undefined";	
	}
		
function openSUY14Popup(winName) {
		var popup = window.open('/Forms/'+winName+'.aspx',winName,'top=25,left=25,width=600,height=760,scrollbars=yes,menu=no');
		return popup != null && typeof(popup) != "undefined";	
	}
	
function openPage(winName) {
		window.open('/Pages/'+winName+'.aspx',winName,'top=25,left=25,width=810,height=600,scrollbars=yes,menu=no');
	}
	
function getLength(l,m){
		window.status = l + " of " + m + " maximum characters.";
		return l < m;
	}
	
function maxLength(t,m){
		var l = t.value.length;
		if (l > m){
			alert("Your entry of " + l + " characters exceeds the maximum of " + m + ".\n" + "It will now be truncated.");
			t.value = t.value.substring(0,m);
		}
		getLength(t.value.length,m);
	}
	

$(document).ready(function() {
String.prototype.endsWith = function(str)
{return (this.match(str+"$")==str)}

  $("#submitButtonVideo").click(function () {
     var obj = document.getElementById("File");
     url = obj.value.toLowerCase();
	 
	 alert

     if (url == "" || url.endsWith(".avi") || url.endsWith(".mov") || url.endsWith(".mp4"))
     {
       return true;
     }
     alert('"' + obj.value + '" is an invalid file type.<br />  Valid file types are: mov, avi, mp4');
     return false;
  });
  
  $("#submitButtonPhoto").click(function () {
     var obj = document.getElementById("File");
     url = obj.value.toLowerCase();
	 
	 alert

     if (url == "" || url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".gif") || url.endsWith(".png") || url.endsWith(".bmp"))
     {
       return true;
     }
     alert('"' + obj.value + '" is an invalid file type.<br />  Valid file types are: jpg, jpeg, gif, png, bmp');
     return false;
  });

});

function requireCheckboxChecked (checkbox_id, msg) {
	
	var forms = document.getElementsByTagName("form");
	for(var i =0; i < forms.length; i++) {
	var valid = forms[i][checkbox_id].checked == true;
		if(!valid) {
			alert(msg);
			return false;
		}
	}
	return true;
}


function scrollToTop(){
	var scrollTop = (document.documentElement.scrollTop>=document.body.scrollTop)?document.documentElement.scrollTop:document.body.scrollTop;
	if(scrollTop>0){
		if(scrollTop>=30){
			window.scrollBy(0,-30);
			scrolldelay = setTimeout('scrollToTop()',30);
		} else {
			window.scrollBy(0, scrollTop*(-1));
		}
	}
}

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;
}