
function changePassword(){
	alert('Change password');
}

function logout(){
	window.location.href="systemLogout.aspx";
}


function addNewTicket(){
	var objProjectList = document.getElementById('ddlProject')
	var projectid = 0;
	if(objProjectList.options.selectedIndex>-1){
		projectid = objProjectList.options[objProjectList.options.selectedIndex].value;
	}
	window.location.href = "supportTicket.aspx?intTicketID=" + 0  + "&searched_projectid=" + projectid;
}
function openTicket(ticketID){
	window.location.href = "supportTicket.aspx?intTicketID=" + ticketID;
}

function openTicketListing(projectID, priorityID){
	window.location.href = "supportTicketsListing.aspx?ProjectID=" + projectID + "&PriorityID=" + priorityID;
}

function openProjects(){
	window.location.href = "supportProjectsListing.aspx";
}

function displayAddComment(){

	//document.getElementById("butAddComment1").style.display = "none";
	document.getElementById("addnewcomment").style.display = "block";
	document.getElementById("butAddComment2").style.display = "none";
	//DA 21/06/07 - added extra button. This code makes the button invisible onclick
	document.getElementById("butAddComment3").style.display = "none";
	
	window.location.href="#commentbox";
	
	//alert(document.getElementById("rptComments:_ctl6:ddlCommentStatus"));
}

function openDownloadFile(FileID)
{
	var url = "systemDownload.aspx?FileID=" + FileID;
	var strWindowName = url;
	if (!isWindowOpen(strWindowName)){
		popupWindow(url,strWindowName,'height=500,width=550,top=10,left=10,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=yes');
	}
	try{window.event.cancelBubble = true;}catch(e){}
}

function popupWindow(strPage, strWindowName, strProps) {
	return window.open(strPage, removeInvalidChars(strWindowName, "_"), strProps);
}

function isWindowOpen(strWindowName) {
	return false;
	strFeatures = "width=1,height=1,left=9999,top=9999";
	testwindow = window.open("", removeInvalidChars(strWindowName, "_"), strFeatures);
	if(testwindow != null){
		if (testwindow.top.screenLeft >= 9999 || testwindow.top.screenLeft == void(0)) {
			testwindow.close();
			return false;
		} else {
			testwindow.focus();
			return true;
		}
	}
	
	return false;
}

function removeInvalidChars(string, replaceString) {
	for (var i=0, output='', valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; i<string.length; i++){
		if (valid.indexOf(string.charAt(i)) != -1){
			output += string.charAt(i);
		} else {
			output += replaceString;
		}
	}
	return output;
}