<!--
var isLoaded = 1;

var Page_IsValid = true;

//alert(navigator.appName);
//alert(navigator.appVersion);

function doNothing()
{ return }

function editContent(m, Me){
	if(Me){
		var item = Me.split("|");
		var target = "/awp/web/Objects/System/EditMyContent.aspx?m=" + m + "&amp;";
		target += "p=" + item[0] + "&amp;sp=" + item[1] + "&amp;tc=" + item[2];
		win(target, 'EditContent', '650', '400');
	}
}

function minThis(strObj){
	//alert(item);
	var parId = strObj.parentNode.container;
	var row = document.getElementById(parId);
	var divlist = row.getElementsByTagName("div");
	divlist[1].style.display="none";
	divlist[1].expand="0";
	strObj.outerHTML = '<a href="#" onClick="maxThis(this)"><img src="images/i_max.gif" border="0" alt="Maximize this list"></img></a>';
}

function maxThis(strObj){
	var parId = strObj.parentNode.container;
	var row = document.getElementById(parId);
	var divlist = row.getElementsByTagName("div");
	divlist[1].style.display="";
	divlist[1].expand="1";
	strObj.outerHTML = '<a href="#" onClick="minThis(this)"><img src="images/i_min.gif" border="0" alt="Minimize this list"></img></a>';
}

function hideThis(strObj){
	var parId = strObj.parentNode.container;
	var row = document.getElementById(parId);
	var divlist = row.getElementsByTagName("div");
	var itemname = row.title;
	var itemtype = row.level;
	var msg = "";
	if(itemtype=="tc"){
		msg = "You're about to hide '" + itemname + "'.\nIf you wish to display this item in the future, please\nclick the 'Edit Content and Preferences' button at\nthe top right corner of your workspace.\n\nAre you sure you want to hide this item?"
	}
	if(confirm(msg)){
		for(var i=0; i<divlist.length; i++){
			divlist[i].style.display="none";
			divlist[i].show="0";
		}
	}
}

function getHelp(item){

}

function openObject(strObj){
	var fmsObj = document.getElementById(strObj);
	var target = fmsObj.targeturl;
	if(!fmsObj.targeturl)
	{
		target = fmsObj.attributes["targeturl"].value;
	}
	if(target.indexOf("?") > 0){
		if(fmsObj.sid)
		{
			target += "&loc=0&sid=" + fmsObj.sid;
			target += "&no=" + fmsObj.id;
		} else {
			target += "&loc=0&sid=" + fmsObj.attributes["sid"].value;
			target += "&no=" + fmsObj.id;
		}
	}
	//alert(target);
	win(target, 'widget', '700', '450','popup','1');
}

function openObjectNoPop(strObj){
	var fmsObj = document.getElementById(strObj);
	var target = fmsObj.targeturl;
	if(target.indexOf("?") > 0)
	{
		target += "&loc=0&sid=" + fmsObj.sid;
		target += "&no=" + fmsObj.id;
	}
	document.location.href = target;
	//alert(target);
	//win(target, 'widget', '700', '450','popup','1');
}

function toUpper(field){
	if(event.keyCode != 37 && event.keyCode != 39 && event.keyCode != 8 && event.keyCode != 46 && event.keyCode != 35 && event.keyCode != 36)
	{
		field.value = field.value.toUpperCase();
	}
}

function checkLength(field,maxlength){
	if(field.value.length > maxlength) {
		alert('Please do not enter more than ' + maxlength + ' characters');
		field.value = field.value.substring(0,maxlength);
	}
}

function closeAddMyp(){
	var myFrame = parent.frames.document.getElementById("addToMyp");
	myFrame = parent.frames.document.getElementById("addToMyPortalWindow");
	myFrame.style.display = "none";
}

/************************************************************************/
/*  The following section contains functions related to drag layers     */
/************************************************************************/
/*
var checkZIndex = true;

var dragobject = null;
var tx;
var ty;

var ie5 = true;


if(document){
	ie5	 = document.all != null && document.getElementsByTagName == null;
}

function getReal(el) {
	temp = el;

	while ((temp != null) && (temp.tagName != "BODY")) {
		if ((temp.className == "moveme") || (temp.className == "handle")){
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}


function moveme_onmousedown() {
	el = getReal(window.event.srcElement)
	//alert("moveme_onmousedown");
	if (el.className == "moveme" || el.className == "handle") {
		if (el.className == "handle") {
			//alert(el.id);
			tmp = el.getAttribute("handlefor");
			if (tmp == null) {
				dragobject = null;
				return;
			}
			else { dragobject = eval(tmp); }
			//if (checkZIndex) makeOnTop(dragobject);
			
			ty = window.event.clientY - getTopPos(dragobject);
			tx = window.event.clientX - getLeftPos(dragobject);
			
			window.event.returnValue = false;
			window.event.cancelBubble = true;
		}
		else { dragobject = null; }
	}
	else { dragobject = null; }
}

function moveme_onmouseup() {
	if(dragobject) { dragobject = null; }
}

function moveme_onmousemove() {
	if (dragobject) {
		if (window.event.clientX >= 0 && window.event.clientY >= 0) {
			dragobject.style.left = window.event.clientX - tx;
			dragobject.style.top = window.event.clientY - ty;
		}
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
}

function getLeftPos(el) {
	if (ie5) {
		if (el.currentStyle.left == "auto")
			return 0;
		else
			return parseInt(el.currentStyle.left);
	}
	else {
		return el.style.pixelLeft;
	}
}

function getTopPos(el) {
	if (ie5) {
		if (el.currentStyle.top == "auto") return 0;
		else return parseInt(el.currentStyle.top);
	}
	else { return el.style.pixelTop; }
}

function makeOnTop(el) {
	var daiz;
	var max = 0;
	var da = document.all;
	
	for (var i=0; i<da.length; i++) {
		daiz = da[i].style.zIndex;
		if (daiz != "" && daiz > max) max = daiz;
	}
	
	el.style.zIndex = max + 1;
}

if (document.all) { //This only works in IE4 or better
	document.onmousedown = moveme_onmousedown;
	document.onmouseup = moveme_onmouseup;
	document.onmousemove = moveme_onmousemove;
}

/************************************************************/

function expandWidget(obj){
	// get widget's 
	var objCell = document.getElementById(obj.cellId);
	var objCell2 = document.getElementById(obj.cellId+"_size");
	var objDiv = document.getElementById(obj.divId);
	var objSpan = document.getElementById(obj.spanId);
	var parRow = objCell.parentNode;
	if(objCell.className==""){
		objCell.className="ti-expanded";
		objCell2.className="ti-expanded";
		objDiv.style.display="";
		objSpan.style.display="";
		parRow.className="";
	} else {
		objCell.className="";
		objCell2.className="";
		objDiv.style.display="none";
		objSpan.style.display="none";
		parRow.className="items";
	}
}

function enlargeThis(obj, id){
	var frameName = document.getElementById(obj.frameId);
	if (frameName == null)
		frameName = document.getElementById(id);
	if(frameName)
	{
		if(frameName.height)
		{
			//alert('changing height of ' + frameName.name + ' ' + frameName.height);
			frameName.height = frameName.height-(-100);
		} 
		else 
		{
			//alert(frameName.style.height);
			//alert('changing style-height of ' + frameName.name);
			var myHeight = frameName.style.height.replace(/px$/, "");
			frameName.style.height = myHeight - (-100);
			var iFrame = document.getElementById("addToMyp");
			iFrame.height = iFrame.height-(-100);
		}
	}
}

function reduceThis(obj, id){
	var frameName = document.getElementById(obj.frameId);
	if (frameName == null)
		frameName = document.getElementById(id);
	if(frameName)
	{
		if(frameName.height)
		{
			if(frameName.height > 200) frameName.height = frameName.height-100;
		} 
		else 
		{
			//alert(frameName.style.height);
			var myHeight = frameName.style.height.replace(/px$/, "");
			frameName.style.height = myHeight - 100;
			var iFrame = document.getElementById("addToMyp");
			iFrame.height = iFrame.height-100;
		}
	}
}

/************************************************************/
function checkThis(){ alert("yoyo"); }

/***********************************************************/
function resizeWidget(){
	var myContainer = document.getElementById("container");
	if (myContainer != null)
	{
	var myHeight = myContainer.myHeight ? myContainer.myHeight : myContainer.offsetHeight;
	var myWidth = myContainer.myWidth ? myContainer.myWidth : myContainer.offsetWidth;
	var myScroll = myContainer.myScroll ? myContainer.myScroll : "yes";
	myHeight = myHeight.toString().replace(/px$/, "");
	var myFrame = parent.frames.document.getElementsByTagName("iframe");
		if(myFrame && !parent.opener){
			if(myFrame.length > 0){
				for(var i = 0; i < myFrame.length; i++){
					if(myFrame[i].name == self.frames.name) {
						if(myHeight == "100%") myHeight = 550;
						if(myHeight >= screen.availHeight) myHeight = screen.availHeight - 200;
						myFrame[i].height=eval(myHeight);
						if(myScroll) myFrame[i].scrolling=myScroll;
						myFrame[i].status=1;
					}
				}
			}
		} else {
			if(parent.opener){
				if(myWidth == "100%")
					{
						myWidth = screen.availWidth;
						window.moveTo(0,0);
					}
				if(myHeight == "100%" || myHeight > screen.availHeight) myHeight = screen.availHeight;
				window.resizeTo(myWidth,myHeight);
			}
		}
	}
}


function resizeEmbeddedTaskItem(myContainer){
	if (myContainer != null)
	{
		var myHeight = myContainer.myHeight ? myContainer.myHeight : myContainer.offsetHeight;
		var myWidth = myContainer.myWidth ? myContainer.myWidth : myContainer.offsetWidth;
		var myScroll = myContainer.myScroll ? myContainer.myScroll : "yes";
		myHeight = myHeight.toString().replace(/px$/, "");
		var myFrame = parent;//frames.document.getElementsByTagName("iframe");
		if(myFrame && !parent.opener){
			
			
						if(myHeight == "100%") myHeight = 550;
						if(myHeight >= screen.availHeight) myHeight = screen.availHeight - 200;
						if (myFrame.document.documentElement && myFrame.document.documentElement.clientWidth) {
							var clientWidth = myFrame.document.documentElement.clientWidth;
							if (clientWidth > myWidth)
							{
								myWidth = clientWidth;
							}
								
							
							//alert(myWidth);
						}
						myFrame.resizeTo(myWidth + 25, myHeight);
						if(myScroll) myFrame.scrolling=myScroll;
						myFrame.status=1;
			
		} else {
			if(parent.opener){
				if(myWidth == "100%")
					{
						myWidth = screen.availWidth;
						window.moveTo(0,0);
					}
				if(myHeight == "100%" || myHeight > screen.availHeight) myHeight = screen.availHeight;
				//alert('setting size');
				window.resizeTo(myWidth,myHeight);
			}
		}
	}
}


function oldresizeWidget(){
	var myContainer = document.getElementById("container");
	if (myContainer != null)
	{
		var myHeight = myContainer.myHeight ? myContainer.myHeight : 550;
		var myWidth = myContainer.myWidth ? myContainer.myWidth : 750;
		var myScroll = myContainer.myScroll ? myContainer.myScroll : "yes";
		myHeight = myHeight.toString().replace(/px$/, "");
		var myFrame = parent.frames.document.getElementsByTagName("iframe");
		if(myFrame && !parent.opener){
			if(myFrame.length > 0){
				for(var i = 0; i < myFrame.length; i++){
					if(myFrame[i].name == self.frames.name) {
						if(myHeight == "100%") myHeight = 550;
						myFrame[i].height=eval(myHeight);
						if(myScroll) myFrame[i].scrolling=myScroll;
						myFrame[i].status=1;
					}
				}
			}
		} else {
			if(parent.opener){
				if(myWidth == "100%")
					{
						myWidth = screen.availWidth;
						window.moveTo(0,0);
					}
				if(myHeight == "100%") myHeight = screen.availHeight;
				window.resizeTo(myWidth,myHeight);
			}
		}
	}
}

function changeDisplay(thisDiv,thisType){
	var el = document.getElementById(thisDiv);
	var elType = document.getElementById(thisType+"_"+thisDiv);
	if(el.style.display=='none'){
		el.style.display='';
		elType.innerHTML = '<img src="/web/shared/images/menu_folder_open.gif" border="0"></img>';
	}
	else { 
		el.style.display='none';
		elType.innerHTML = '<img src="/web/shared/images/menu_folder_closed.gif" border="0"></img>';
	}
}

function openStillLoading(){
	var w = stillLoading.style.width.replace("px", "");
	var h = stillLoading.style.height.replace("px", "");
	stillLoading.style.top=(screen.availHeight/2)-(eval(h)/2)-200;
	stillLoading.style.left=(screen.availWidth/2)-(eval(w)/2);
	stillLoading.style.display='';
}

function closeStillLoading(){
	stillLoading.style.display='none';
}

function showProgress(){	
	var createbar = "<TABLE BGCOLOR='#FFFFFF' WIDTH='" + 100 + "' HEIGHT='16' CELLPADDING='3' CELLSPACING='3' BORDER='1' BORDERCOLOR='#696969'><TR ID='progBar'>";
	for(var i=0;i<10;i++) {
		createbar += "<TD WIDTH='10' STYLE='background-color: #FFFFFF;'></TD>";
	}
	createbar += "</TR></TABLE>";
	progressBar.innerHTML=createbar;
}

function updateProgress(thisCol){
	if(isLoaded != "1"){
		var progbar = document.getElementById("progressBar"); 
		var eachbar = progbar.getElementsByTagName("td"); 
		var tmpCol = thisCol;
		for(var i=0; i < 10; i++){
			if(eachbar[i].style.backgroundColor=="#ffffff"){
				eachbar[i].style.backgroundColor="red";
				break;
			}
			if(i==9){
				for(var j=0; j < 10; j++){
					eachbar[j].style.backgroundColor="#ffffff";
				}
			}
		}
		setTimeout('updateProgress();',500);
	} else {
		closeStillLoading();
	}
}
function checkLoaded(){
	var eachFrame = document.getElementsByTagName("iframe");
	if(eachFrame.length == 0)
	{ isLoaded = 1; }
	else
	{
		var ctLoaded = 0;
		for(var i = 0; i < eachFrame.length; i++){
			if(eachFrame[i].status==1){ ctLoaded++; }
		}
		if(ctLoaded==eachFrame.length){ isLoaded = 1; }
		else { setTimeout('checkLoaded()',1000); }
	}
}

function checkLoadStatus(isLoaded) {
	msg = "Please wait until the page is loaded completely";

	if(isLoaded == 0) {
		alert(msg);
		return false;
	} else {
		return true;
	}
}



var ua, topOffset = 5, subOffset=topOffset+14, toolMenuShow=true, shiftMinimize=0, currentPopup="";
window.onload = doLoad;

function doLoad() {
switch(navigator.appName){
case "Netscape": ua="NN"; break;
case "Microsoft Internet Explorer": ua="IE"; break;
default: ua=""; return;
}
/*if(ua=="IE")
{document.all.pollDiv.style.pixelTop=158; document.all.pollDiv.style.pixelLeft=4;}*/
//setInterval("moveMenu()",30);
}

function moveMenu() {
var shiftPage, diff;
if(ua=="IE") shiftPage=document.body.scrollTop;
else if(ua=="NN") shiftPage=window.pageYOffset;
else return;
if(shiftPage != shiftMinimize){
//hideAll(); if(!toolMenuShow) popUptoolMenu();
dif=(shiftPage-shiftMinimize)>>2;
if(dif) shiftMinimize+=dif; else shiftMinimize=shiftPage;
if(ua=="IE") document.all.formpanel.style.pixelTop=shiftMinimize+topOffset;
if(ua=="NN") document.layers.formpanel.y=shiftMinimize+topOffset;
}}

function hideAll() {
if(currentPopup) popUp(currentPopup,false);
}

function popUptoolMenu() {
if(ua=="IE") {
document.all.toolMenu.style.pixelTop = shiftMinimize+subOffset;
document.all.toolMenu.style.visibility = toolMenuShow ? "visible" : "hidden";
if(document.all.pollDiv) document.all.pollDiv.style.visibility = toolMenuShow ? "hidden" : "visible";
}
if(ua=="NN") {
document.layers.toolMenu.y = shiftMinimize+subOffset;
document.layers.toolMenu.visibility = toolMenuShow ? "show" : "hide";
if(document.layers.pollLayer) {document.layers.pollLayer.visibility = toolMenuShow ? "hide" : "show";
document.layers.pollLayer.layers.pollDiv.visibility = toolMenuShow ? "hide" : "show";}
}
toolMenuShow=!toolMenuShow;
}

function popUp(menuName,on) {
if (on) {
hideAll();
if (ua=="NN") {
document.layers[menuName+'Layer'].y = shiftMinimize+subOffset;
document.layers[menuName+'Layer'].visibility = "show";
document.layers[menuName+'Layer'].layers[menuName+'Div'].visibility = "show";
} else {
document.all[menuName+'Div'].style.pixelTop = shiftMinimize+subOffset;
document.all[menuName+'Div'].style.pixelLeft = 138;
selRefresh();
document.all[menuName+'Div'].style.visibility = "visible";
}
currentPopup=menuName;
} else {
if(ua=="NN") {
document.layers[menuName+'Layer'].layers[menuName+'Div'].visibility = "hide";
document.layers[menuName+'Layer'].visibility = "hide";
} else {
document.all[menuName+'Div'].style.visibility = "hidden";
}
currentPopup="";
}
}

function openWin(href,name,top,left,width,height){
var wnd=window.open(href,name,'top='+top+',left='+left+',width='+width+',height='+height+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no');
wnd.focus();
}

function openWin1(href,name,top,left,width,height){
var wnd=window.open(href,name,'top='+top+',left='+left+',width='+width+',height='+height+',status=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes');
wnd.focus();
}

function loginfocus() {if (ua=="IE") document.loginform.login.focus();}

function searchfocus() {if (ua=="IE") document.searchform.search.focus();}

function openWaitMsg()
{
	//if(Page_isValid == "undefined"){ Page_IsValid = true; }
	if(Page_IsValid){
		if(content)
		{ if(waitmsg) content.style.display = 'none'; waitmsg.style.display = '';
		}
		
	}
}

function removeMeFirst(remBtn, ctlID)
{
	var selId = remBtn.id;
	var	selName = remBtn.origID;
	var prefix = selId.substring(0, (selId.length - selName.length));

	var contextVal = document.getElementById(prefix + ctlID);
	if (contextVal) removeMe(contextVal);

}
function removeMe(tbox) {
	var boxLength = tbox.length;
	if(boxLength==0 || (boxLength == 1 && tbox.options[0].value == "")) { doNothing(); }
	else {
		var tb = document.getElementById(tbox.id + "_tb");
		if(tb) tb.value = "";
		arrSelected = new Array();
		var count = 0;
		for (i = 0; i < boxLength; i++) {
			if (tbox.options[i].selected) {
				arrSelected[count] = tbox.options[i].value;
			}
			count++;
		}
		var x;
		for (i = 0; i < boxLength; i++) {
			for (x = 0; x < arrSelected.length; x++) {
				if (tbox.options[i].value == arrSelected[x]) {
					tbox.options[i] = null;
				}
			}
			boxLength = tbox.length;
		}
		if(tb)
		{	
			for (i = 0; i < boxLength; i++)
			{	
				if(tb.value != "") tb.value += "|";
				tb.value += tbox.options[i].value;
			}
		}
		//if(arrSelected.length==0){alert("Please first select craftsperson/contractor to be removed");}
	}
	
}

function closeWin() {
	if(parent.opener){
		if(parent.opener.document.selform) {
			if(parent.opener.document.selform.viewallrecords)
			{
				if(parent.opener.document.selform.viewallrecords.value == "1")
				{
					if(parent.opener.document.selform.viewAllBtn) parent.opener.document.selform.viewAllBtn.click();
				
				} else {
					if(parent.opener.document.selform.nextButton) parent.opener.document.selform.nextButton.click();
				}
			} else {
				if(parent.opener.document.selform.nextButton) parent.opener.document.selform.nextButton.click();
			}
		}
	}
	self.window.close(); 
}

// Getting rid of unwanted characters in a textbox
function stringFilter (input, filteredValues) {
	s = input.value;
	if (filteredValues == "") filteredValues = "'!@#$%^&*=+()\/?<>,.:;[]|`~";     // Characters stripped out
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
	var c = s.charAt(i);
	if (filteredValues.indexOf(c) == -1) returnString += c;
	}
	input.value = returnString;
}

function stringFilterFromValue (s, filteredValues) {
	if (filteredValues == "") filteredValues = " '!@#$%^&*=+()\/?<>,.:;[]|`~";     // Characters stripped out
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
	var c = s.charAt(i);
	if (filteredValues.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function stringEnd (input, endValue){
	s = input.value;
	//alert(s.substring((s.length - endValue.length), s.length));
	if(s.substring(s.length, endValue.length) != endValue){
		s = s.substring(0, s.indexOf("."));
		//alert(s);
		input.value = s + endValue;
	}
}

function isEmail(thisfield) {
	thisemail = thisfield.value;
    if (thisemail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


//Validate date format

var start_date;
var start_month;
var start_year;
var stop_date;
var stop_month;
var stop_year;

function isValidDate(dateField) {

	var dateStr = dateField.value;

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year

	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert("'" + dateStr + "' Date is not in a valid format.  Please use MM/DD/YYYY format.");
		dateField.focus();
		return false;
	}
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
	}	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn't have " + day + " days!");
			return false;
		}
	}
	return true;
}

function clearCache(cacheString)
{
	//win("/awp/web/clearCache.aspx?items=" + cacheString, 'ClearContent', '1', '1');
}

var is_logging_out = "0";

function logmeout(logout_type)
{
	if(logout_type == "1")
	{
		is_logging_out = "1";
		document.location.replace("logout_message.aspx");
	} else
	{
		if(is_logging_out == "0")
		{ win('/awp/Web/logout_message.aspx', 'widget', '600', '350','popup','1'); }
	}
}
//-->

