function DoKeyDown(formObj, kc){
	var keyCompare = kc
	// alert(event.keyCode)
	var keyPressed = event.keyCode

	if(keyPressed == kc)
	{
		//alert("delete")
		//document.former.schedule.value = ""
		formObj.value = ""
	}else{
		formObj.value = ""
	}
	event.returnValue = ""

}

function OpenPopWindow(MediaUrl,MediaWinProperties) {
		POPWin = window.open(MediaUrl,"Popup", MediaWinProperties );
		POPWin.focus();
}
function initCMS()
{
	initEditor('txtContent');
	initEditor('txtContent_es');
}
function AddSiteAssociation()
{
	var WinProps =  "height=300,width=500,resizable=yes,scrollbars=yes";
	var WinURL = "Admin_StudySiteAssociation.aspx";
	OpenPopWindow(WinURL,WinProps)
}
function OpenPrintFriedly(){
	strStudyProfileID = document.forms[0].hid_study_profile_id.value;
	var WinProps =  "height=500,width=700,resizable=yes,scrollbars=yes";
	var WinURL = "StudyDetail.aspx?study_profile_id=" + strStudyProfileID + "&xmlTemplate=templates/printTemplate.xml"
	OpenPopWindow(WinURL,WinProps)

}
function UploadFlash(){
	var WinProps =  "height=200,width=400,resizable=yes,scrollbars=yes";
	var WinURL = "Admin_UploadFlash.aspx?xmlTemplate=templates/printTemplate.xml"
	OpenPopWindow(WinURL,WinProps)
}
function OpenUserView(strStudyProfileID){
	 
	var WinProps =  "height=500,width=700,resizable=yes,scrollbars=yes";
	var WinURL = "StudyDetail.aspx?study_profile_id=" + strStudyProfileID + "&xmlTemplate=templates/printTemplate.xml"
	OpenPopWindow(WinURL,WinProps)

}
function OpenEmailAgreement(){
	var WinProps =  "height=400,width=400,resizable=yes,scrollbars=yes";
	var WinURL = "emailAgreement.aspx";
	OpenPopWindow(WinURL,WinProps)
}
function OpenWebReports(){
	var WinProps =  "";
	var WinURL = "http://app3.etmxi.com/urchin/htdocs/report.cgi?profile=www.njctc.org&user=njctcadmin";
	OpenPopWindow(WinURL,WinProps)
}

function ccStudyList(intCallID){
	var WinProps =  "height=500,width=700,resizeable=yes,scrollbars=yes";
	var WinURL = "PrintStudies.aspx?call_id=" + intCallID+ "&xmlTemplate=templates/printTemplate.xml"
	OpenPopWindow(WinURL,WinProps)

}

function OpenFullFlashPreview(strHref){
	var WinProps =  "height=183,width=400,resizable=yes,scrollbars=yes";
	var WinURL = "flash/" + strHref;
	OpenPopWindow(WinURL,WinProps)
}
function getObject(objectId) {
	if (document.all && !document.getElementById) {
		return document.all(objectId)
	} else {
		return document.getElementById(objectId)
	}
}
function ConfirmDelete(strStudyProfileID){
	if(confirm('Are you sure you want to delete study '+strStudyProfileID+'?'))
		document.location.href='Admin_StudyQueue.aspx?PageAction=Delete&study_profile_id='+strStudyProfileID;
}
/*
function isValidUserName(objFormField){
	var strError = "";
	
	if(objFormField.value.length<4)
		strError = "Password must be at least 4 characters./n"
	
	var filter = /[<\>\"\&]/;
	if (!filter.test(objFormField.value))
		strError = "Password must contain only letters and numbers."
		
	if(strError != "")
		alert(strError);

}
*/

function minPassword(source, arguments){
	

	alert(source);
	alert(arguments)


}



function isValidEmail(EmailField){
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!(filter.test(EmailField.value))){
			alert('Please enter a valid email address.');
			EmailField.focus();
			return false;}
		else{
			return true;
		}
	}
function trapKeys(){
		window.captureEvents(Event.KEYUP);  //tells browser to capture keyup
        window.onKeyUp = HandleKey;    
}

function HandleKey(e){
	
	var xForm = document.forms[0];

     try{
		objFormFieldName = e.target.name;   //assigns name of element the event was captured in
	}catch(error){
		objFormFieldName = e.srcElement.name;		
	}
	//Check to see if the event happens in the password field
	if(objFormFieldName == "ucLogin:txtPassword" || objFormFieldName == "ucLogin:btnLogin"){
		var kc;
		if(typeof(e.which)!='undefined')
			kc = e.which;
		else
			kc = e.keyCode;
		
		//Check for the enter key event
		if(kc== 13){
			e.returnValue = false
			e.cancelBubble = true;
			getObject("ucLogin_btnLogin").click();
		}
	}
	if(objFormFieldName == "txtSearch"){
		var kc;
		if(typeof(e.which)!='undefined')
			kc = e.which;
		else
			kc = e.keyCode;
		
		//Check for the enter key event
		if(kc== 13){
			e.returnValue = false
			e.cancelBubble = true;
			getObject("ucSearch_btnSearch").click();
		}
	}
	//cancel all other enterkeys
	if(typeof(e.which)!='undefined')
			kc = e.which;
		else
			kc = e.keyCode;
		if(kc== 13){
		e.returnValue = false
		e.cancelBubble = true;
	}
}
