//Make sure that the current page is at the very top of the frame.
function breakOut()
{
if (self != top) window.open("/screenwritersmanifesto/inc_gbl_code/inc.gblJavaScript.asp","_top","");
}
function isArray(a)
{
return isObject(a) && a.constructor == Array;
}
function isObject(a)
{
return (typeof a == 'object' && !!a) || isFunction(a);
}
function isFunction(a)
{
return typeof a == 'function';
}
function keyRestricted(event, strType, strCharList)
{
//Note these only work for onKeyPress event. onKeyUp and onKeyDown have different keyCode values for some reason.
var strReturn = false;
if (document.all)
{
var numkey = event.keyCode;
var blnIsShiftKeyPressed = event.shiftKey;
}
else
{
var numkey = event.which;
var blnIsShiftKeyPressed = event.modifiers & Event.SHIFT_MASK;
}
if (strCharList != "") var strChars = strCharList.split(",")
//KEYCODES:
//Numbers 0-9, regularkeys & numericpad: 48-57
//Letters: a-z 97-122, and A-Z, 65-90
//("-" 45), ("/" 47)
//("." 46), ("," 44)
// 0 is Tab Key
switch (strType)
{
case "letters":
if ((numkey==8) || (numkey==46) || ((numkey>=37) && (numkey<=40)))
{
if (((numkey>=65) && (numkey<=90)) && ((numkey>=97) && (numkey<=122))) strReturn = true;
}
break;
case "numbers":
if (blnIsShiftKeyPressed == false)
{
if ((numkey==0) || (numkey==8) || (numkey==46) || ((numkey>=37) && (numkey<=40)) || ((numkey>=48) && (numkey<=57))) strReturn = true;
}
break;
case "numbersonly":
if (blnIsShiftKeyPressed == false)
{
if (((numkey>=48) && (numkey<=57)) || (numkey==8) || (numkey==0)) strReturn = true;
}
break;
case "date":
if (blnIsShiftKeyPressed == false)
{
if (((numkey==8) || ((numkey>=37) && (numkey<=40))) || ((numkey==47) || (((numkey>=48) && (numkey<=57))))) strReturn = true;
}
break;
case "phone":
if (blnIsShiftKeyPressed == false)
{
if (((numkey==8) || ((numkey>=37) && (numkey<=40))) || ((numkey==45) || (((numkey>=48) && (numkey<=57))))) strReturn = true;
}
break;
default:
break;
}
return strReturn;
}
function restrictCharLimit(event, curObj, charLimit)
{
var retVal = true;
if (document.all)
var numkey = event.keyCode;
else
var numkey = event.which;
//alert(numkey);
//numkey = 8 (backspace key)
//numkey = 0 (delete key)
if ((curObj.value.length == charLimit) && (numkey != 8) && (numkey !=0)) retVal = false;
return retVal;
}
function trim(str)
{
return str.replace(/^\s*|\s*$/g,"");
}
//finds current XML version on client machine
function findXMLVersion()
{
var xmlVersion = ["4.0", "3.0", "2.6", "2.5", "2", "Microsoft", "MSXML"];
var xmlDoc = "hellow World";
var i, objXml, objXmlDom, strRetVal="";
for (i=0; i <= xmlVersion.length-1; i++)
{
if (xmlVersion[i] == "Microsoft")
{
try
{
objXML = new ActiveXObject("Microsoft.XMLDOM");
objXML.async = false;
if (objXML.loadXML(xmlDoc))
{
if (strRetVal == "") strRetVal = "Microsoft";
}
}
catch (e)
{
}
}
else if (xmlVersion[i] == "MSXML")
{
try
{
objXML = new ActiveXObject("Msxml.DOMDocument");
objXML.async = false;
if (objXML.loadXML(xmlDoc))
{
if (strRetVal == "") strRetVal = "Msxml";
}
}
catch (e)
{
}
}
else if (xmlVersion[i] == "2")
{
try
{
objXML = new ActiveXObject("Msxml2.DOMDocument");
objXML.async = false;
if (objXML.loadXML(xmlDoc))
{
if (strRetVal == "") strRetVal = "Msxml2";
}
}
catch (e)
{
}
}
else
{
try
{
objXML = new ActiveXObject("Msxml2.DOMDocument." + xmlVersion[i]);
objXML.async = false;
if (objXML.loadXML(xmlDoc))
{
if (strRetVal == "") strRetVal = "Msxml2";
}
}
catch (e)
{
}
}
}
return strRetVal;
}
//dynamically fill object and display
function RebuildMain(objFilled, strPath, strPassfilterValue, nodeStatus)
{
var strBuild="", strAnswer="";
if (document.all)
var poster = new ActiveXObject(findXMLVersion() + ".XMLHTTP")
else
var poster = new XMLHttpRequest();
if (objFilled != "") objFilled = document.getElementById(objFilled);
if (strPassfilterValue == "")
strBuild = "";
else
{
switch (nodeStatus)
{
case "doDelete":
strBuild = "" + strPassfilterValue + "";
break;
case "getTable":
strBuild = "" + strPassfilterValue + "";
break;
case "getValue":
strBuild = "" + strPassfilterValue + "";
break;
case "verifyDragToTargetID":
strBuild = "" + strPassfilterValue + "";
break;
case "copymoveconfirm":
strBuild = "" + strPassfilterValue + "";
break;
default:
strBuild = "" + strPassfilterValue + "||" + nodeStatus + "";
break;
}
}
poster.open("POST", strPath, "false");
poster.onreadystatechange=function() {
//States of readyState:
//0 - UNINITIALIZED, The object has been created, but not initialized (open method has not been called).
//1 - LOADING, The object has been created, but the send method has not been called.
//2 - LOADED, The send method has been called and the status and headers are available, but the response is not yet available.
//3 - INITIALIZED, Some data has been received. You can call responseBody and responseText to get the current partial results.
//4 - COMPLETED, All the data has been received, and the complete data is available in responseBody and responseText.
if (poster.readyState == 4)
{
if (poster.status == 200)
{
strBuild = strAnswer + poster.responseText;
if (objFilled != "") objFilled.innerHTML = strBuild;
}
}
}
poster.send(strBuild);
if ((nodeStatus == "verifyDragToTargetID") || (nodeStatus == "getTable") || (nodeStatus == "doDelete")) return strBuild;
}
//==================================================================================================================
//This is a series of function used for moving HTML Elements on the page, namely DIVs correctly.
var dragObj = new Object();
dragObj.zIndex = 0;
function dragStart(e, id)
{
var el, x, y;
if (id)
dragObj.elNode = document.getElementById(id);
else
{
if (document.all)
dragObj.elNode = window.event.srcElement;
else
dragObj.elNode = e.target;
// If this is a text node, use its parent element.
if (dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode;
}
// Save starting positions of cursor and element.
dragObj.elWidth = parseInt(dragObj.elNode.style.width);
dragObj.elHeight = parseInt(dragObj.elNode.style.height);
dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);
if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0;
dragObj.diffValX = (e.clientX - dragObj.elStartLeft);
dragObj.diffValY = (e.clientY - dragObj.elStartTop);
// Capture mousemove and mouseup events on the page.
if (document.all)
{
document.attachEvent("onmousemove", dragGo);
document.attachEvent("onmouseup", dragStop);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
else
{
document.addEventListener("mousemove", dragGo, true);
document.addEventListener("mouseup", dragStop, true);
e.preventDefault();
}
}
function dragGo(event)
{
var x, y, newLeft, newRight, newTop, newBottom, intWinHeight, intWinWidth;
if (document.all)
{
var intWinHeight = document.body.clientHeight-10;
var intWinWidth = document.body.clientWidth-9;
}
else
{
var intWinHeight = window.innerHeight-10;
var intWinWidth = window.innerWidth-9;
}
//alert(intWinWidth + " : " + intWinHeight);
// Move drag element by the same amount the cursor has moved.
newLeft = (event.clientX - dragObj.diffValX);
newTop = (event.clientY - dragObj.diffValY);
newRight = (newLeft + dragObj.elWidth);
newBottom = (newTop + dragObj.elHeight);
if ((newLeft>=0) && (newTop>=0) && (newRight<=intWinWidth) && (newBottom<=intWinHeight))
{
dragObj.elNode.style.left = newLeft + "px";
dragObj.elNode.style.top = newTop + "px";
}
if (newLeft<0) dragObj.elNode.style.left = "0px";
if (newTop<0) dragObj.elNode.style.top = "0px";
if (newRight>intWinWidth) dragObj.elNode.style.left = (intWinWidth - dragObj.elWidth) + "px";
if (newBottom>intWinHeight) dragObj.elNode.style.top = (intWinHeight - dragObj.elHeight) + "px";
if (document.all)
{
window.event.cancelBubble = true;
window.event.returnValue = false;
}
else
event.preventDefault();
}
function dragStop(event)
{
// Stop capturing mousemove and mouseup events.
if (document.all)
{
document.detachEvent("onmousemove", dragGo);
document.detachEvent("onmouseup", dragStop);
}
else
{
document.removeEventListener("mousemove", dragGo, true);
document.removeEventListener("mouseup", dragStop, true);
}
}