function uc(){
	alert("This feature is not available in the prototype.")
}

function evoid(){
	return
}

function test(e){
	var key = document.all ? e.keyCode : e.which ;
	
	if (key == 13){
	document.forms.login.submit()
	}
}

function confirmDelete(template,id,title,initiativeID){
	var response = confirm("You are about to permanently delete the item '"+title+"'.\nProceed?")
	if ((confirmDelete.arguments.length==3)&&(response)){
		document.location.href=template+"?id="+id
	} 
	else if((confirmDelete.arguments.length==4)&&(response)){
		document.location.href=template+"?id="+id+"&initiativeID="+initiativeID
	}
	else {
		return
	}	
} 


//Inform the user that the file will be renamed as ARCHIVED
function confirmDeleteTpck(template,id,title,initiativeID){
	var response = confirm("You are about to archive the item '"+title+"'.\nProceed?")
	if ((confirmDelete.arguments.length==3)&&(response)){
		document.location.href=template+"?id="+id
	} 
	else if((confirmDelete.arguments.length==4)&&(response)){
		document.location.href=template+"?id="+id+"&initiativeID="+initiativeID
	}
	else {
		return
	}	
} 
//delete newsletter, user has option to delte other 'same' newsletters
function confirmNewsletterDelete(template,id,title, more){
	var response = confirm("You are about to permanently delete the item '"+title+"'.\nProceed?")
	if (response){
		document.location.href=template+"?id="+id+"&all=no";
		}
	/*
		if((more!='')&&(more!=0)){
			var response2 = confirm("Would you also like to delete the other identical newsletters in the same primary cmm areas'.\nProceed?")
			if(response2){
				document.location.href=template+"?id="+id+"&all=yes";
			}
			else
				document.location.href=template+"?id="+id+"&all=no";
		}
		else{
			document.location.href=template+"?id="+id+"&all=no";
		}
	}
*/
	else {
		return
	}	
} 



function confirmWorkflowDelete(template,id,title){
	var response = confirm("You are about to permanently delete the item '"+title+"' from workflow.\nProceed?")
	if (response){
		document.location.href=template+"?id="+id
	}
	else{
		return
	}	
} 

function infoResourceAddItem(){
	var msg="To add a new Teacher and Trainer Resource please contact TSN support."
	alert(msg);
	
}

function checksearch(){
	if (document.searchform.searchparameter.value == ""){
		alert("Please enter your search term.")
		return false
	}
	else{
		return true
	}
}

function checkSelect(frm,elem,msg){
	if(document.getElementById(elem).value==""){
		alert(msg);
		return false;
	}
	return true;
}	


//====================================================================================================
// Checks if a string is alphanumeric, returns true or false 
function searchAlphaNumeric(searchparameter){
	
	var isLetter=false
    var alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
	if (searchparameter.value == ""){
		alert("Please enter your search term.")
		return false
	}
	else{

		// compare each letter of string with letters of alphabet, set flag 
			for (i=0;i<searchparameter.value.length;i++){
				for(j=0;j<alpha.length;j++){
					alphaChar=alpha.charAt(j);
					if (searchparameter.value.charAt(i)==alphaChar){
					    isLetter=true
						break;
					}
					else{
						isLetter=false
					}
				}
				if(!isLetter)break;
			}
		
	}

	if (isLetter==false){
		alert("Your search terms can only contain letters and numbers.\n\nFor best results type in words separated by a space.")
	 	return false
	}
	else{
		return true
	}
}


function displayFeedback(title,heading1,heading2,feedback,width,height){
	var imgHeight = 0
	var offset = 35
	
	imgHeight = (height < offset)? 0 : height - offset
	
	feedbackpop("",width,height)
	msg2.document.open()
	msg2.document.write('<html><head><title>'+title+'</title>')
	msg2.document.writeln('<style>')
	msg2.document.writeln('h2 {font-family:verdana,tahoma,helvetica,arial; font-size:11pt; color:#000000;}')
	msg2.document.writeln('h1 {font-family:verdana,tahoma,helvetica,arial; font-size:13pt;}')
	msg2.document.writeln('p {font-family:verdana,tahoma,helvetica,arial; font-size:10pt}')
	msg2.document.writeln('</style></head><body onload="window.focus()" onblur="window.close()">')
	msg2.document.write('<table border="0" width="100%" cellspacing="0">')
	msg2.document.write('<tr><td valign="top"></td><td rowspan="5"><img src="../genimages/spacer.gif" width="1" height="'+imgHeight+'" border="0" alt=""></td></tr>')
	msg2.document.write('<tr><td valign="top"><h2>'+heading1+'</h2><p><b>'+heading2+'</b></p>')
	msg2.document.write('<p>'+feedback+'</p></td></tr>')
	msg2.document.write('<tr><td align="right" valign="top"><a href="#" onclick="self.close()"><img src="../../genimages/close.gif" name="btnClose" width="51" height="19" border="0"></a></td></tr></table></body></html>')
	msg2.document.close()
}

function feedbackpop(pageName,width,height)
{
  msg=basicpopup3(pageName,350,150,width,height,"yes","yes");
}

function basicpopup3(pageName,x_pos,y_pos,win_width,win_height,allow_resize,allow_sbars)
{
	var popuparguments = "toolbar=no,width="+win_width+",height="+win_height+",directories=no,status=no,scrollbars="+allow_sbars+",resizable="+allow_resize+",menubar=no,left="+x_pos+",top="+y_pos;
	msg2=window.open(pageName,"Feedback",popuparguments);
}
function formSubmit(form){
	form.submit();
}

/*** SUrvey *************************************/			





// ------------------------------------------------- Industry skills council --------------------------------------------------------------

// change drop down when adding a new Industry skills council (id=0 for add, else edit)
function changeDropDown(obj,id){
	
	var selectObjs=document.getElementsByName("sel_tp");
	var optPos=0;
	if(id!=0)optPos=findDropDownOption(selectObjs,id);
	
	for(var i=0;i<selectObjs.length;i++){
		var optionsObj=document.getElementById("sel_tp_"+(i+1)).options;
		optionsObj[optPos].text=obj.value;
	}
	
}
//find option position in drop down list
function findDropDownOption(selectObjs,id){
	var optionPos=0;
	for(var i=0;i<selectObjs.length;i++){
		var count=0;
		var optionObj=document.getElementById("sel_tp_"+(i+1)).options;
		for(var j=0;j<optionObj.length;j++){
			if(optionObj[j].id==id){
				optionPos=count;
				break;
			}
			count++;
		}
	}	
	return optionPos;
}


// industry skills council delete function
function confirmDeleteWithCmmAreaID(template,id,title,cmmarea,deletelist){

	if(deletelist!=""){
		var newArray=deletelist.split("|");
		var str="You cannot permanently delete the item '"+title+"'.\n\n";
		if(newArray.length>0)str+="This industry skills council is linked to the following training packages:\n";
		for(var i=0;i<newArray.length;i++){
			str+="\n"+String.fromCharCode(9)+String.fromCharCode(8226)+" "+newArray[i];
		}
		str+="\n\nTo permanently delete the item it must not be linked to any training packages.";
		alert(str);
	}else{
		var response=confirm("You are about to permanently delete the item '"+title+"'.\nProceed?");
		if(response){document.location.href=template+"?id="+id+"&cmmid="+cmmarea}else{return;}
	}
} 






