//Used on desktop to load descriptions in msg window
descriptionArray = new Array();
var reloadPage = false;
var blnSendEmailErrors = 0; 

function showHideDiv (divID,showHide) {
	//1=show;2=hide;
	curDiv = document.getElementById(divID);
	curEdit = document.getElementById(divID + '_edit');
	
	if (!showHide) {
		if (curDiv.style.display == 'none' && (((curEdit && curEdit.style.display == 'none')) || !curEdit)){
			curDiv.style.display = 'block';
			curImage = document.getElementById(divID + '_img');
			if (curImage) curImage.src='/images/downArrow.gif';
			curEdit = document.getElementById(divID + '_edit');
			if (curEdit) curEdit.style.display='none';
			curText = document.getElementById(divID + '_text');
			if (curText && divID == 'filter') curText.innerHTML = '<a href="javascript:showHideDiv(\'filter\');"><img src="/images/filter_icon.gif" border="0" hspace="2" alt="Hide Filter" title="Hide Filter"></a>';
			
		}
		else {
			curDiv.style.display = 'none';
			curImage = document.getElementById(divID + '_img');
			if (curImage) curImage.src='/images/upArrow.gif';
			if (curEdit) curEdit.style.display='block';
			curText = document.getElementById(divID + '_text');
			if (curText && divID == 'filter') curText.innerHTML = '<a href="javascript:showHideDiv(\'filter\');"><img src="/images/filter_icon.gif" border="0" hspace="2" alt="Show Filter" title="Show Filter"></a>';
		}
	} else {
		if (showHide == 1) {
			curDiv.style.display = 'block';
			document.getElementById('topPopupShadow').style.display = 'inline';
			
		} else { 
			curDiv.style.display = 'none';
			document.getElementById('topPopupShadow').style.display = 'none';
			document.getElementById('topPopupWhite').style.display = 'none';
		}
	}

}

function showHideNote(divID,showHide) {
	curDiv1 = document.getElementById(divID);
	curDiv2 = document.getElementById(divID + '_hidden');
	     
	if (showHide) {
		curDiv1.style.display = 'block';
		curDiv2.style.display = 'none';
		
	} else {
		curDiv1.style.display = 'none';
		curDiv2.style.display = 'block';
	}
}

function deleteNote(noteID) {
	if (confirm('Are you sure you want to delete this note?')) {
		workerFrame.document.location.href = '/framework/includes/removeNoteAction.cfm?noteID=' + noteID;
	}	
}

function showHideCalendar (divID,showHide,theTop,theLeft) {
	//1=show;2=hide;
	curDiv = document.getElementById(divID);
	curDiv.style.top = theTop;
	curDiv.style.left = theLeft;
	
	curEdit = document.getElementById(divID + '_edit');
	if (!showHide) {
		if (curDiv.style.display == 'none' && (((curEdit && curEdit.style.display == 'none')) || !curEdit)){
			curDiv.style.display = 'block';
			curImage = document.getElementById(divID + '_img');
			if (curImage) curImage.src='/images/downArrow.gif';
			curEdit = document.getElementById(divID + '_edit');
			if (curEdit) curEdit.style.display='none';
			curText = document.getElementById(divID + '_text');
			if (curText && divID == 'filter') curText.innerHTML = '<a href="javascript:showHideDiv(\'filter\');"><img src="/images/filter_icon.gif" border="0" hspace="2" alt="Hide Filter" title="Hide Filter"></a>';
			document.getElementById('topPopupShadow').style.display = 'inline';
		}
		else {
			curDiv.style.display = 'none';
			curImage = document.getElementById(divID + '_img');
			if (curImage) curImage.src='/images/upArrow.gif';
			if (curEdit) curEdit.style.display='none';
			curText = document.getElementById(divID + '_text');
			if (curText && divID == 'filter') curText.innerHTML = '<a href="javascript:showHideDiv(\'filter\');"><img src="/images/filter_icon.gif" border="0" hspace="2" alt="Show Filter" title="Show Filter"></a>';
		}
	} else {
		if (showHide == 1) { 
			curDiv.style.display = 'block';
			document.getElementById('topPopupShadow').style.display = 'inline';
		} else {
			curDiv.style.display = 'none';
			document.getElementById('topPopupShadow').style.display = 'none';
		}
	}

}

function validateLogin(objForm){
	if (objForm.username.value != '' && objForm.password.value != '') {
		return true;
	} else if (objForm.username.value == ''){
		alert('Please enter a username.');
		objForm.username.focus();
		return false;
	} else if (objForm.password.value == ''){
		alert('Please enter a password.');
		objForm.password.focus();
		return false;
	}
}

function fncValidateUser(objForm){
	var arrErrors = new Array();
	
	try {
		if (!(objForm.strDisplayName.value.length)) arrErrors[arrErrors.length] = 'Display Name can not be empty.';
		if (!(objForm.strUsername.value.length)) arrErrors[arrErrors.length] = 'Username can not be empty.';
		if (!(objForm.strPassword.value.length)) arrErrors[arrErrors.length] = 'Password can not be empty.';
		if (objForm.strPasswordVerify && objForm.strPassword.value  != objForm.strPasswordVerify.value ) arrErrors[arrErrors.length] = 'The two password fields must be the same.';
		if (!(objForm.strEmail.value.length)) arrErrors[arrErrors.length] = 'Email can not be empty.';
		if (objForm.strEmailVerify && objForm.strEmail.value  != objForm.strEmailVerify.value ) arrErrors[arrErrors.length] = 'The two email fields must be the same.';
		
		if (arrErrors.length) {
			strErrorMessage = '<span style="color:Black;"><b>Please fix the following fields:</b></span><p>';
			
			for (var i=0;i < arrErrors.length;i++){
				strErrorMessage += arrErrors[i] + '<br>';
			}
			
			top.loadMsgWindow('msg1',strErrorMessage,parseInt(arrErrors.length,10) * 2,'red');
		} else return true;
	}catch (e) {
			alert ('The page had an error, please try again later.');
			try {
				if (blnSendEmailErrors) DWREngine._execute(_cfscriptLocation, null, 'fncSendJSErrorMsg',e.message, fncErrorReturn);
				else debugger;;
			} catch (E) {alert (E);}
			return false;
	}
	
}

function fncErrorReturn(results) {
	
}

function editDefect(divID,direction) {
	curDiv = document.getElementById(divID);
	curEdit = document.getElementById(divID + '_edit');
	
	
	if (direction == 1){
		curDiv.style.display='none';
		curEdit.style.display='block';
	} else {
		curDiv.style.display='block';
		curEdit.style.display='none';
	}
}

function createSite() {
	
	if (document.siteCreate.siteName.value == '') {
		alert('Please choose a site name.');
		return;	
	}
	
	if (document.siteCreate.adminUsername.value == '') {
		alert('Please choose an admin username.');
		return;	
	}
	
	if (document.siteCreate.adminPassword.value == '') {
		alert('Please choose an admin password.');
		return;
	}
	
	siteID = 0;
	for (i=0;i<document.siteTemplate.tempCreateSiteID.length;i++){
		if (document.siteTemplate.tempCreateSiteID[i].checked) siteID = document.siteTemplate.tempCreateSiteID[i].value;
	}
	if (siteID == 0) {
		alert('Please choose a template.');
		return;	
	}
	
	sectionList = '';	
	for (i=0;i<document.siteSection.elements.length;i++){
		curE = document.siteSection.elements[i];
		if (curE.type == 'checkbox' && curE.checked) sectionList = sectionList + ',' + curE.name;
	}
	if (sectionList == '') {
		alert('Please choose at least one section.');
		return;	
	}
	
	document.siteCreate.createSiteID.value = siteID;
	document.siteCreate.sectionList.value = sectionList;
	document.siteCreate.submit();
}

function fullEditDefect (defectID,openPosition) {
	if (!openPosition) openPosition = 'detailsWrapper';
	document.location.href = 'defectsFullEdit.cfm?defectID=' + defectID + '&oP=' + openPosition;
}

function resetFilter(f) {
	//for (i=0;i<f.elements.length;i++){
	//	curE = f.elements[i];
	//	if (curE.type == 'text') curE.value = '';
	//	else if (curE.type == 'select-one') curE.selectedIndex = 0;
	//}
	document.location.href = 'defects.cfm?rF=1';
}

function changeProject(form,curPage) {
	workerFrame.document.location.href = '/framework/includes/setActiveProject.cfm?newPID=' + form['changepid'][form['changepid'].selectedIndex].value + '&page=' + curPage;
}

function fncChangePhotoPage(objGroupSelect) {
	document.location.href = 'photos.cfm?photoGroupID=' + objGroupSelect[objGroupSelect.selectedIndex].value;
}

function saveForm (curForm) {
	document[curForm + '_form'].submit();
}

function saveMessage(curForm){
	objForm = document[curForm + '_form'];
	
	if (objForm.captcha.value == '') {
		fncCaptchaMessage(objForm);
		return false;
	}
	if (objForm.strName.value == '') objForm.strName.value = 'Anonymous';
	
	if (objForm.strMessage.value == ''){
		document.getElementById('divStrMessage').style.display = 'block';
		return false;
	}
	saveForm(curForm);
}

function fncCaptchaMessage(objForm) {
	objForm.captcha.className='redBorder';
	document.getElementById('captchaMessage').style.display = 'block';
}

function saveAllDefects (defectList) {
	alert('Save All coming soon.\n\nThis will save all the forms on the page in case you have to modify many items at once.');
}

function deleteForm (curForm,type) {
	if (confirm('Are you sure you want to delete this ' + type + '?\n\n**This ' + type + ' will be removed entirely from the system.')){
		document[curForm + '_form'].actionType.value = 'delete_' + type;
		document[curForm + '_form'].submit();
	}
}

function onLoadFunctions(projectID) {
	//Ajax init call
	init();
}

function loadSection(section) {
	if (objSections[section].innerHTML == ''){
		DWREngine._execute(_cfscriptLocation, null, 'loadSection', section, objSections[section].includeFile, loadSectionResult);
	} else {
		selectedSection = document.getElementById(section);
		selectedSection.innerHTML = objSections[section].innerHTML;
	}
}

function loadSectionResult(result) {
	selectedSection = document.getElementById(result.SECTION);
	selectedSection.innerHTML = result.SECTIONTEXT;
	objSections[result.SECTION].innerHTML = result.SECTIONTEXT;
}

function fncSaveGoalEvent(intGoalID,dteGoalDate) {
	
	
	if (!intGoalID) {
		goalID = document.getElementById('intGoalID').value;
		n_strDate = document.getElementById('dteCalendarDate').value;
		strNote = document.getElementById('strGoalNote').value;
	} else {
		goalID = intGoalID;
		n_strDate = dteGoalDate;
		strNote = document.getElementById('strGoalNotepopup').value
	}
	
	if (goalID == 0) {
		alert('Choose a goal, not a category.');
	} else {
		if (confirm('Are you sure you want to save the goal')){
			if (n_strDate != '') DWREngine._execute(_cfscriptLocation, null, 'fncSaveGoalEvent', goalID,strNote, n_strDate,saveGoalResult);
			else DWREngine._execute(_cfscriptLocation, null, 'fncSaveGoalEvent', goalID, strNote, saveGoalResult);
		}
	}
}

function saveGoalResult(result) {
	params = result.split('_');
	strDate = params[0] + "_" + params[1] + "_" + params[2];
	
	document.getElementById('strGoalNote').value = '';
	showHideDiv('msg1',2);
	
	//if using the calender, will change the color. 
	if (document.getElementById(strDate)) document.getElementById(strDate).style.backgroundColor = params[2];
	
	//if need to checkmark the event.
	if (document.getElementById('checkmark_' + params[3])){
		if(document.getElementById('checkmark_' + params[3]).innerHTML == '') document.getElementById('checkmark_' + params[3]).innerHTML = '1';
		else document.getElementById('checkmark_' + params[3]).innerHTML = parseInt(document.getElementById('checkmark_' + params[3]).innerHTML,10) + 1;
	}
	
	alert('Your goal has been saved.');
	document.location.href = document.location.pathname;
	//loadMsgWindow('msg1','Your goal has been saved.',3);
}

function fncLoadGoalCategory() {
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadGoalCategory', document.getElementById('categoryToEdit').value,fncLoadGoalCategoryResult);
}

function fncLoadGoalCategoryResult(result) {
	for (i in result){
		if (result[i].KEY == 'GOALCATEGORYID') {
			document.getElementById('goalCategoryID').value = result[i].VALUE;
		} else if (result[i].KEY == 'GOALCATEGORYNAME') {
			document.getElementById('editCategoryName').value = result[i].VALUE;
		} else if (result[i].KEY == 'GOALCATEGORYDESCRIPTION') {
			document.getElementById('editCategoryDesc').value = result[i].VALUE;
		} else if (result[i].KEY == 'PRIVATE') {
			if (result[i].VALUE == 1) document.getElementById('editPrivate').checked = true;
			else document.getElementById('editPrivate').checked = false;
		}
	}
	document.getElementById('editDelete').checked = false;
}

function fncLoadGoal() {
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadGoal', document.getElementById('goalToChange').value,fncLoadGoalResult);
}

function fncLoadGoalResult(result) {

	for (i in result){
		if (result[i].KEY == 'GOALNAME') {
			document.getElementById('strGoalName').value = result[i].VALUE;
		} else if (result[i].KEY == 'GOALID') {
			document.getElementById('goalID').value = result[i].VALUE;
		} else if (result[i].KEY == 'GOALDESCRIPTION') {
			document.getElementById('strGoalDescription').value = result[i].VALUE;
		} else if (result[i].KEY == 'GOALVALUE') {
			document.getElementById('intGoalValue').value = result[i].VALUE;
		} else if (result[i].KEY == 'PRIVATE') {
			if (result[i].VALUE == 1) document.getElementById('blnPrivate').checked = true;
			else document.getElementById('blnPrivate').checked = false;
		} else if (result[i].KEY == 'BLNDAILYGOAL') {
			if (result[i].VALUE == 1) document.getElementById('blnDaily').checked = true;
			else document.getElementById('blnDaily').checked = false;
		}
	}
	document.getElementById('editDelete').checked = false;
}



function saveLog(logText,eventid) {
	//DWREngine._execute(_cfscriptLocation, null, 'saveLog', logText,eventid, saveLogResult);
}

function saveLogResult(result) {
	alert('Saved');
}

function init() {
	//DWRUtil.useLoadingMessage();
	DWREngine._errorHandler =  errorHandler;
	strDay = '';
	strMonth = '';
	strYear = '';
}

var intGlobalSecs;

function loadMsgWindow(div,msg,n_intSecs,fontColor) {
	if (!n_intSecs) {
		n_intSecs = 0;
		document.getElementById(div + '_timer').innerHTML = '';
	}
	
	intGlobalSecs = n_intSecs;
	if (!fontColor) fontColor = 0;
	document.getElementById(div + '_text').innerHTML = msg;
	document.getElementById(div + '_text').style.color = fontColor;
	
	curDiv = document.getElementById(div);
	curDiv.style.top = 123;
	curDiv.style.left = 365;
	showHideDiv(div,1);
	if (n_intSecs != 0) startMessageTimer(div,n_intSecs);
	window.scrollTo(0,0);
}

function loadMsgWindowNoScroll(div,msg,n_intSecs,fontColor) {
	if (!n_intSecs) {
		n_intSecs = 0;
		document.getElementById(div + '_timer').innerHTML = '';
	}
	
	intGlobalSecs = n_intSecs;
	if (!fontColor) fontColor = 0;
	
	//yMousePos
	//xMousePos
	
	document.getElementById(div + '_text').innerHTML = msg;
	document.getElementById(div + '_text').style.color = fontColor;
	curDiv = document.getElementById(div);

	curDiv.style.top = yMousePos - 240;
	curDiv.style.left = xMousePos;
	showHideDiv(div,1);
	if (n_intSecs != 0) startMessageTimer(div,n_intSecs);
}

function loadPhotoWindow(intPhotoKey) {
	
	strMsg = '<table border="0" cellpadding="2" cellspacing="2" width="100%">';
	strMsg += '<tr class="filterResults">';
	if (intPhotoKey > 1) strMsg += '<td width="33%"><a href="javascript:loadPhotoWindow(' + (intPhotoKey - 1) + ')">Previous</a></td>';
	else strMsg += '<td width="33%"></td>';
	
	strMsg += '<td width="33%" align="center">' + intPhotoKey + ' of ' + objPhotos.intTotalImages + '</td>';
	
	if (intPhotoKey < objPhotos.intTotalImages) strMsg += '<td width="33%" align="right"><a href="javascript:loadPhotoWindow(' + (intPhotoKey + 1) + ')">Next</a></td></tr>';
	else strMsg += '<td width="33%"></td>';
	
	
	strMsg += '<tr><td colspan=3 align="center"><img src="' + objPhotos[intPhotoKey].path + '" width=' + objPhotos[intPhotoKey].width  + ' height=' + objPhotos[intPhotoKey].height + '><td></tr>';
	strMsg += '<tr><td colspan=3 align="center" class="noteText">' + objPhotos[intPhotoKey].description + '</tr>';
	strMsg += '</table>';
	
	document.getElementById('topPopupWhite').style.display = 'block';
	document.getElementById('msg1').style.width = objPhotos.intMaxWidth + 30;
	document.getElementById('msg1').style.top = 15;
	document.getElementById('msg1').style.left = (document.documentElement.offsetWidth - objPhotos.intMaxWidth + 30)/2;
	loadMsgWindow('msg1',strMsg,0,'red');
	
}

function startMessageTimer(div,secs) {
	if (secs = intGlobalSecs) {
		document.getElementById(div + '_timer').innerHTML = 'Closing in ' + secs + ' seconds.';
	
		if (secs > 1) {
			newSecs = secs - 1;
			intGlobalSecs = newSecs;
			setTimeout("startMessageTimer('" + div + "'," + newSecs + ")",1000);
		} else {
			setTimeout("top.showHideDiv('" + div + "',2)",1000);
		}
	}
}

function printListing() {
	//newWin = window.open("blank.cfm",'newWin', 'left=0,top=0,width=800,height=600,menubar=yes,toolbar=yes,locationbar=yes,statusbar=yes,scrollbars=yes,resizable=yes');
	//searchQuery.target = 'newWin';
	//searchQuery.action = 'printDefectList.cfm';
	//timeOut = setTimeout("loadPost();", 500);
	alert('Print coming soon.\n\nThis will print all the filtered defects for the page in a nice printable manner.');
}

function loadPage(n_strPage){
	DWREngine._execute(_cfscriptLocation, null, 'loadPage', n_strPage, loadPageResult);
	
}

function loadPageResult(result) {
	document.getElementById('pageBodyContent').innerHTML = result;
}

function fncLoadPreviousMonth(){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadPreviousMonth', fncLoadPreviousMonthResult);
}

function fncLoadPreviousMonthResult(result) {
	document.location = document.location.pathname;
}

function fncLoadPreviousBlogMonth(){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadPreviousMonth', fncLoadPreviousMonthBlogResult);
}

function fncLoadPreviousMonthBlogResult(result) {
	document.location = document.location.href=document.location.pathname;
}

function fncLoadPreviousDay(){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadPreviousDay', fncLoadPreviousDayResult);
}

function fncLoadPreviousDayResult(result) {
	document.location = document.location.pathname;
}

function fncLoadNextMonth(){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadNextMonth', fncLoadNextMonthResult);
}

function fncLoadNextMonthResult(result) {
	document.location = document.location.pathname;
}

function fncLoadNextBlogMonth(){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadNextMonth', fncLoadNextBlogMonthResult);
}

function fncLoadNextBlogMonthResult(result) {
	document.location = document.location.pathname;
}

function fncLoadNextDay(){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadNextDay', fncLoadNextDayResult);
}

function fncLoadNextDayResult(result) {
	document.location = document.location.pathname;
}

function fncLoadDay(n_intDay){
	DWREngine._execute(_cfscriptLocation, null, 'fncLoadDay',n_intDay, fncLoadDayResult);
}

function fncLoadDayResult(result) {
	document.location = document.location.pathname;
}

function fncGoToBlog(n_intEntityID) {
	document.location.href = 'blog.cfm?intEntityID=' + n_intEntityID;
}

function fncSetSessionScopeCFvar(n_strName, n_strValue) {
	DWREngine._execute(_cfscriptLocation, null, 'fncSetSessionScopeCFvar', n_strName, n_strValue, fncSetSessionScopeCFvarResult);
}

function fncLogOut() {
	DWREngine._execute(_cfscriptLocation, null, 'fncLogOut','',fncLogOutResult);
}

function fncLogOutResult() {
	document.location.href = 'index.cfm';
}

function fncClearSearch() {
	DWREngine._execute(_cfscriptLocation, null, 'fncClearSearch','',fncClearSearchResult);
}

function fncClearSearchResult() {
	alert('Search options cleared.');
	document.location = document.location;
}


function fncSetSessionScopeCFvarResult(result) {
	
}

function openPhotoWindow(groupID){
	
	document.location.href = 'photos.cfm?photoGroupID=' + groupID;
	//newWin = window.open('bodyImage.cfm?groupID=' + groupID + '&image=1' + image,'Photos', 'left=0,top=0,width=700,height=575,menubar=no,toolbar=no,locationbar=no,statusbar=yes,scrollbars=yes,resizable=yes');
	//newWin.focus();
}



function fncSendTextMessage(n_strMessage) {
	DWREngine._execute(_cfscriptLocation, null, 'fncSendTextMessage', n_strMessage, fncSendTextMessageResult);
}

function fncSendTextMessageResult() {
	
}

var g_intVideoClicks = 0;
function fncTurnOnCamera() {
	g_intVideoClicks++;
	
	if (g_intVideoClicks == 5) {
		fncSendTextMessage('Camera is getting turned on');
		document.getElementById('divWebCamera').innerHTML = '<span class="subhead">Click Click</span>';
		timer = setTimeout("document.getElementById('divWebCamera').innerHTML = fncCaptureImage('video')", 30000);
	}
}

function fncCaptureImage(strType) {
	// Set the BaseURL to the URL of your camera
	var BaseURL = "http://kenyork.blogdns.com:80/";
	
	// DisplayWidth & DisplayHeight specifies the displayed width & height of the image.
	// You may change these numbers, the effect will be a stretched or a shrunk image
	var DisplayWidth = "160";
	var DisplayHeight = "120";
	
	if (strType == 'image') {
		// This is the path to the image generating file inside the camera itself
		var File = "axis-cgi/jpg/image.cgi?resolution=160x120";
		
		
		
		// No changes required below this point
		
		var output = "";
			theDate = new Date();
			output  = '<IMG align="left" class="logPhoto" SRC="';
			output += BaseURL;
			output += File;
			output += '&dummy=' + theDate.getTime().toString(10);
			output += '" HEIGHT="';
			output += DisplayHeight;
			output += '" WIDTH="';
			output += DisplayWidth + '"';
			output += 'ALT="" onClick="fncTurnOnCamera();"'
			output +='>';
		
		
		//document.write(output);
		//document.Player.ToolbarConfiguration = "play,+snapshot,+fullscreen"
		// document.Player.UIMode = "MDConfig";
		// document.Player.MotionConfigURL = "/axis-cgi/operator/param.cgi?ImageSource=0"
		// document.Player.MotionDataURL = "/axis-cgi/motion/motiondata.cgi";
	} else if (strType == 'video') {
		// This is the path to the image generating file inside the camera itself
		var File = "axis-cgi/mjpg/video.cgi?resolution=160x120&username=cfuser&password=cfuser";
		
		var DisplayWidth = "640";
		var DisplayHeight = "480";
		
		// No changes required below this point
		
		var output = "";
		if ((navigator.appName == "Microsoft Internet Explorer") &&
		   (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k"))
		{
			// If Internet Explorer under Windows then use ActiveX 
			output  = '<OBJECT align="left" class="logPhoto" ID="Player" width='
			output += DisplayWidth;
			output += ' height=';
			output += DisplayHeight;
			output += ' CLASSID="CLSID:DE625294-70E6-45ED-B895-CFFA13AEB044" ';
			output += 'CODEBASE="';
			output += BaseURL;
			output += 'activex/AMC.cab#version=3,20,18,0">';
			output += '<PARAM NAME="MediaURL" VALUE="';
			output += BaseURL;
			output += File + '">';
			output += '<param name="MediaType" value="mjpeg-unicast">';
			output += '<param name="ShowStatusBar" value="0">';
			output += '<param name="ShowToolbar" value="0">';
			output += '<param name="AutoStart" value="1">';
			output += '<param name="StretchToFit" value="1">';
			output += '<BR><B>Axis Media Control</B><BR>';
			output += 'The AXIS Media Control, which enables you ';
			output += 'to view live image streams in Microsoft Internet';
			output += ' Explorer, could not be registered on your computer.';
			output += '<BR></OBJECT>';
		} else {
			// If not IE for Windows use the browser itself to display
			theDate = new Date();
			output  = '<IMG align="left" class="logPhoto" SRC="';
			output += BaseURL; 
			output += File;
			output += '&dummy=' + theDate.getTime().toString(10);
			output += '" HEIGHT="';
			output += DisplayHeight;
			output += '" WIDTH="';
			output += DisplayWidth;
			output += '" ALT="Camera Image">';
		}
		
		//document.write(output);
		//document.Player.ToolbarConfiguration = "play,+snapshot,+fullscreen"
		// document.Player.UIMode = "MDConfig";
		// document.Player.MotionConfigURL = "/axis-cgi/operator/param.cgi?ImageSource=0"
		// document.Player.MotionDataURL = "/axis-cgi/motion/motiondata.cgi";
	}
	
	return output;
}

var g_intCameraClicks = 0;
function fncCameraSwitch(strType) {
	g_intCameraClicks++;
	
	if (g_intCameraClicks == 3) {
		fncSendTextMessage('Picture on webcam just took.');
		if (strType == 'video') {
			newWin = window.open("/cameraPage.cfm",'newWin', 'left=0,top=0,width=800,height=600,menubar=yes,toolbar=yes,locationbar=yes,statusbar=yes,scrollbars=yes,resizable=yes');
			document.getElementById('divWebCamera').innerHTML = fncCaptureImage('image');
			
		} else if (strType == 'image')document.getElementById('divWebCamera').innerHTML =  fncCaptureImage('image');
	}
}

function fncDrawDefects(intDefectID){
	DWREngine._execute(_cfscriptLocation, null, 'fncDrawDefects',intDefectID,fncDrawDefectsReturn);
}

function fncDrawDefectsReturn(result) {
	//defects[i].writeTable();
	n_objDefect = result;
	fncSetDefectDetails(n_objDefect[0][0]);
	fncSetDefectMessage(n_objDefect[1],n_objDefect[0][0].DEFECTID);
	fncSetDefectFiles(n_objDefect[2],n_objDefect[0][0].DEFECTID);
	showHideDiv('defect_' + n_objDefect[0][0].DEFECTID);
}

function fncSetDefectDetails(m_objDefect) {
	document.getElementById('defectDesc_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.DESCRIPTION;
	document.getElementById('defectAddressedTo_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.ADDRESSEDTONAME;
	document.getElementById('defectdateEntered_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.DATEENTERED;
	document.getElementById('defectEnteredByName_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.ADDRESSEDTONAME;
	document.getElementById('defectImportance_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.IMPORTANCE;
	document.getElementById('defectStatus_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.DEFECTSTATUSNAME;
	document.getElementById('defectType_' + m_objDefect.DEFECTID).innerHTML = m_objDefect.DEFECTTYPENAME;
}

function fncSetDefectMessage(m_objDefectMessages,intDefectID){
	if (m_objDefectMessages.length > 0) {
		strMessageText = '';
		
		for (j in m_objDefectMessages) {
			cM=m_objDefectMessages[j];
			strMessageText += '<div class="defectMessageName" style="padding-bottom:15px;">' + cM.NAME;
			strMessageText += '<span class="messageDate" style="padding-left:5px;">(' + cM.DATEMODIFIED + ')</span><br>';
			strMessageText += '<span class="filterText" style="padding-left:15px;">' + cM.MESSAGE + '</span>';
			strMessageText += '</div>';
		}
		document.getElementById('defectMessage_' + intDefectID).innerHTML = strMessageText;
	} else {
		document.getElementById('defectMessage_' + intDefectID).innerHTML = 'No Comments';
	}
}

function fncSetDefectFiles(m_objDefectFiles,intDefectID){
	if (m_objDefectFiles.length > 0) {
		strFileText = '';
		for (j in m_objDefectFiles) {
			cF=m_objDefectFiles[j];
			strFileText += '<div class="defectMessageName" style="padding-bottom:15px;" ><a href="/documents/project_' + cF.PROJECTID  + '/defect_' + cF.DEFECTID + '/' + cF.DOCUMENTLOCATION + '" target="_defect_' + cF.DEFECTID + '">' + cF.DOCUMENTNAME + '</a>';
			strFileText += '<span class="filterText" style="padding-left:15px;">' + cF.NAME + '</span>';
			strFileText += '<span class="messageDate" style="padding-left:5px;">(' + cF.ENTEREDDATE + ')</span>';
			strFileText += '</div>';
			
		}
		document.getElementById('defectFile_' + intDefectID).innerHTML = strFileText;
	} else {
		document.getElementById('defectFile_' + intDefectID).innerHTML = 'No Files';
	}
}


// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.



/*
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
*/

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}




_editor_url = "/htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
	document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
	document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }