/*-----------------------------------------------------------------------
   Portal Functions
   June 24, 2004
-----------------------------------------------------------------------*/

/*=================================
-- Forum Methods
=================================*/

//Used to offer prompt/verification when submitting a form.
//Mainly used for delete confirmation requests.
function confirmSubmit(strPrompt){
	var bAgree=confirm(strPrompt);
	if (bAgree) 
		return true;
	else
		return false;
}

// Used by Add and Update Pages to count the
// number of charcters in an input field.
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else 
	countfield.value = maxlimit - field.value.length;
}

function UpdateUidPwd() {
	if (Form1.fldUidPwd.checked) {
		document.all.divUID.innerHTML = '<strong>' + Form1.fldUIDLocal.value + '</strong>';
		document.all.divUID.style.display = 'inline';
		document.all.divPWD.innerHTML = '<strong>' + Form1.fldPWDLocal.value + '</strong>';
		document.all.divPWD.style.display = 'inline';
	} else {
		document.all.divUID.innerHTML = '';
		document.all.divUID.style.display = 'inline';
		document.all.divPWD.innerHTML = '';
		document.all.divPWD.style.display = 'inline';
	}
}

/*=================================
-- Popup Methods
=================================*/

// Used to Popup a window at a fixed size
// with the Operation overview.
function PopupOperations(strURL) {
	var oPop = window.open(strURL, 'Operations_Preview', 'resizable,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,top=50,left=50,width=525,height=650', true);
	oPop.focus();
}

// Used to Popup a window at a fixed size
function PopupWindow(strURL) {
	winLeft = 250;
	winTop = 150;
	var oPop = window.open(strURL, 'Popup', 'resizable,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,top=' + winTop + ',left=' + winLeft + ',width=700,height=500', true);
	oPop.focus();
}

// Used to Popup window at an adjustable size
function PopupWindowSizable(strURL, iHeight, iWidth) {
	winLeft = 250;
	winTop = 150;
	var oPop = window.open(strURL, 'Popup', 'resizable,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,top=' + winTop + ',left=' + winLeft + ',width=' + iWidth + ',height=' + iHeight, true);
	oPop.focus();
}

// Used to Popup window with the test results
function PopupTestResults(sId) {
	var oPop = window.open('tf_TestLogPreview.aspx?testlogid=' + sId, 'Test_Results', 'resizable,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,top=50,left=50,width=520,height=450', true);
	oPop.focus();
}

// Used to Popup a new window
function newWindow(sPopupUrl) {
	var myHeight, myWidth;
	myWidth  = 600;
	myHeight = 450;
	winLeft  = 50;
	winTop  = 50;
	zoomPopupWin = window.open(sPopupUrl,'AAIA', 
		'scrollbars=yes,width=' + myWidth + ',height=' + myHeight
		+ ',top=' + winTop + ',left=' + winLeft);
	if (parseInt(navigator.appVersion) >= 4) { zoomPopupWin.focus(); }
}

// Used to Show HTML Popup Editor window
function PopupHTMLEditor(theField) {
	window.inputContent = theField;
	var oPop = window.open('htmlEditor/editHTML.aspx', 'HTML_Editor', 'resizable,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,top=25,left=25,width=645,height=430', true);
	oPop.opener = window.self;	
	oPop.focus();
}

// Used to Show HTML Popup Preview window
function PopupPreview(theField) {
	winLeft = 250;
	winTop = 150;
	window.inputContent = theField;
	var oPop = window.open('htmlEditor/previewHTML.aspx', 'HTML_Preview', 'resizable,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,top=' + winTop + ',left=' + winLeft + ',width=450,height=450', true);
	oPop.opener = window.self;	
	oPop.focus();
}

/*=================================
-- Popup Help Methods
=================================*/
function b_ieTrueBody(){
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}

function b_toggleSelects(state) {
	if (btt_ie || btt_ns6)	{
		selects = document.getElementsByTagName("select");
		for (var i = 0; i < selects.length; i++)
		{
			selects[i].style.visibility = state;
		}
	}
}

function showHelp(thetext, thecolor, thewidth) {
	if (btt_ns6 || btt_ie) {
		if (typeof thewidth != "undefined") {
			btt_tipobj.style.width = thewidth + "px";
		}
		if (typeof thecolor != "undefined" && thecolor != "") {
			btt_tipobj.style.backgroundColor = thecolor;
		}
		btt_tipobj.innerHTML = thetext;
		btt_enabletip = true;
		return false;
	}
}

function b_PositionTip(e) {
	if (btt_enabletip){
		var btt_curX = (btt_ns6) ? e.pageX : event.x + b_ieTrueBody().scrollLeft;var btt_curY = (btt_ns6) ? e.pageY : event.y + b_ieTrueBody().scrollTop;var btt_rightedge = btt_ie && !window.opera ? b_ieTrueBody().clientWidth - event.clientX - btt_offsetxpoint : window.innerWidth - e.clientX - btt_offsetxpoint - 20;
		var btt_bottomedge = btt_ie && !window.opera ? b_ieTrueBody().clientHeight - event.clientY - btt_offsetypoint : window.innerHeight - e.clientY - btt_offsetypoint - 20;
		var btt_leftedge = (btt_offsetxpoint < 0)? btt_offsetxpoint * (-1) : -1000;
		if (btt_rightedge < btt_tipobj.offsetWidth) {
			btt_tipobj.style.left = btt_ie? b_ieTrueBody().scrollLeft + event.clientX - btt_tipobj.offsetWidth + "px" : window.pageXOffset + e.clientX - btt_tipobj.offsetWidth + "px";
		}
		else if (btt_curX < btt_leftedge) {btt_tipobj.style.left = "5px";
		}
		else
		{
			btt_tipobj.style.left = btt_curX + btt_offsetxpoint + "px";
		}
		if (btt_bottomedge < btt_tipobj.offsetHeight){btt_tipobj.style.top = ie? b_ieTrueBody().scrollTop + event.clientY - btt_tipobj.offsetHeight - btt_offsetypoint + "px" : window.pageYOffset + e.clientY - btt_tipobj.offsetHeight - btt_offsetypoint + "px";
		}
		else {btt_tipobj.style.top = btt_curY + btt_offsetypoint + "px"; btt_tipobj.style.visibility = "visible";
		}
	}
}

function hideHelp() {
	if (btt_ns6 || btt_ie) {
		btt_enabletip = false;
		btt_tipobj.style.visibility = "hidden";btt_tipobj.style.left = "-1000px";
		btt_tipobj.style.backgroundColor = '';
		btt_tipobj.style.width = '';
	}
}

/*=================================
-- Flash Methods
=================================*/
// Detect Flash
var requiredVersion = 6;  
var useRedirect = false;   

var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false; 
var flash7Installed = false;
var maxVersion = 7; 
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0; 
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
jsVersion = 1.1;
if(isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('</SCR' + 'IPT\> \n'); 
}

function detectFlash() {  
	if (navigator.plugins) {
	if (navigator.plugins["Shockwave Flash 2.0"]
	    || navigator.plugins["Shockwave Flash"]) {
	    var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
	    var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
	    var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
	    flash2Installed = flashVersion == 2;    
	    flash3Installed = flashVersion == 3;
	    flash4Installed = flashVersion == 4;
	    flash5Installed = flashVersion == 5;
	    flash6Installed = flashVersion >= 6;
		flash7Installed = flashVersion >= 7;
	}
	}
	for (var i = 2; i <= maxVersion; i++) {  
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  
		if (actualVersion >= requiredVersion) {
			hasRightVersion = true;                
	}
}

