// // IASP 5.0 Base Javascript // // Copyright (C) IASP 2007. // Unauthorised reproduction or use // on external websites will // be subject to rigorous prosecution // // Create namespace root function CMS() { } CMS.appRoot = '/'; CMS.resUrl = 'https://secure.iasp.com.au/v5/'; // Create dollar sign alias function $(strId) { return document.getElementById(strId); } // Implement Array.indexOf [].indexOf || (Array.prototype.indexOf = function(v,n) { n = (n==null)?0:n; var m = this.length; for(var i = n; i < m; i++) if(this[i] == v) return i; return -1; }); String.prototype.trim = function() { // Strip leading and trailing white-space return this.replace(/^\s*|\s*$/g, ""); } // // IASP Browser Detection // 11/10/06 KM // IASP_DetectBrowser.agt = navigator.userAgent.toLowerCase(); IASP_DetectBrowser.is_ie = ((IASP_DetectBrowser.agt.indexOf("msie") != -1) && (IASP_DetectBrowser.agt.indexOf("opera") == -1)); function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function IASP_DetectBrowser(redir_url) { var browsercap = getCookie('browserCaps'); if (browsercap == null) browsercap = ''; //alert(browsercap); //if (IASP_DetectBrowser.is_ie) { // if (browsercap != null) return; //} else { // if (browsercap == null) return; //} // // Mark browser-level-processing done, and Javascript capable. // browsercap += 'JB'; // // Detect DOM // if (document.getElementById) { browsercap += 'D'; } // // Detect XMLHTTP (AJAX) // if (GetXMLHTTP()) { //obj.innerHTML += 'Yes.'; browsercap += 'X'; } else { //obj.innerHTML += 'No.'; browsercap += 'x'; } // // Detect ContentEditable (WYSIWYG Editor) // if (document.designMode) browsercap += 'C'; else browsercap += 'c'; // // Detect flash // if (navigator.mimeTypes && navigator.mimeTypes.length) { var x = navigator.mimeTypes['application/x-shockwave-flash']; if (x && x.enabledPlugin) { browsercap += 'F'; } else { browsercap += 'f'; } } else { // try ActiveX detection in IE if (IASP_DetectBrowser.is_ie) { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); if (axo != null) { browsercap += 'F'; } else { browsercap += 'f'; } } catch (e) { browsercap += 'f'; } } } //window.alert('BrowserCap: ' + browsercap); document.cookie = 'browserCaps=' + browsercap; if (redir_url != null) { redir_url = unescape(redir_url); //window.alert('Redirecting to: ' + redir_url); window.location.href = redir_url; } } // XMLHTTP object loader. Required for Browser Detection function GetXMLHTTP() { var xh; // Gecko/KHTML/DOM if(typeof XMLHttpRequest != "undefined") { xh = new XMLHttpRequest(); } // IE if (!xh) { try { xh = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xh = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { xh = null; } } } return xh; } CMS.GetXMLHTTP = GetXMLHTTP; // // popDown function for expandable boxes in Site Builder // function popDown(strId) { if (document.getElementById('pdI_' + strId).style.display != 'block') { document.getElementById('pdI_' + strId).style.display = 'block'; document.getElementById('pdP_' + strId).style.width = 'none'; document.getElementById('pdT_' + strId).src = 'images/box_uplt.gif'; } else { document.getElementById('pdI_' + strId).style.display = 'none'; document.getElementById('pdP_' + strId).style.width = '400px'; document.getElementById('pdT_' + strId).src = 'images/box_dnrt.gif'; } } function insertTemplateField(mergeField, textBox) { //Update the message display by adding the merge tag //IE support if (document.selection) { textBox.focus(); sel = document.selection.createRange(); sel.text = mergeField; } //MOZILLA/NETSCAPE support else if (textBox.selectionStart || textBox.selectionStart == '0') { var startPos = textBox.selectionStart; var endPos = textBox.selectionEnd; textBox.value = textBox.value.substring(0, startPos) + mergeField + textBox.value.substring(endPos, textBox.value.length); } else { textBox.value += mergeField; } //Set the focus to the messageBox so the user can enter more characters textBox.focus(); } function insertTemplateFieldEditor(mergeField, textBox) { var ex_html = mergeField; var editObj = $(textBox+'_edit'); if (editObj.tagName == 'IFRAME') { /*if (IASPeditor.is_ie) { var cur = editObj.contentWindow.document.body.innerHTML; editObj.contentWindow.document.body.innerHTML = cur + ex_html; } else { var cur = editObj.contentWindow.document.body.innerHTML; editObj.contentWindow.document.body.innerHTML = cur + ex_html; }*/ editObj.contentWindow.focus(); var doc = editObj.contentWindow.document; if (doc.selection && doc.selection.createRange) { // IE var range = doc.selection.createRange(); range.pasteHTML(ex_html); } else { // FF doc.execCommand('insertHTML', false, ex_html); } } else { editObj.value += ex_html; } } // // derived from nodeengine 0.7.0-b3 : /ui/dropdown.js // function dm_cvx(strId) { document.getElementById(strId).dmEnable = 0; setTimeout('cvis(\''+strId+'\',document.getElementById(\''+strId+'\').dmEnable)',100); } function r_dm_ovx(strIdn) { strId = 'dm_'+strIdn; strTopId = 'ml_'+strIdn; return r_dm_ovx_i(strId,strTopId); } function a_fm_ovx(strIdn) { strId = 'dm_'+strIdn; strTopId = 'ml_'+strIdn; $(strId).fmEnable = 1; $(strId).style.top=findPosY($(strTopId)) + "px"; $(strId).style.left=(findPosX($(strTopId)) + $(strTopId).offsetWidth + 1) + "px"; $(strId).style.display='block'; } // make a dropdown menu or IFRAME appear to the top right of another object function r_dm_ovx_i(strId, strTopId) { var otop = findPosY(document.getElementById(strTopId)); document.getElementById(strId).dmEnable = 1; document.getElementById(strId).style.top= otop + "px"; document.getElementById(strId).style.left=(findPosX(document.getElementById(strTopId)) + document.getElementById(strTopId).offsetWidth) + "px"; document.getElementById(strId).style.display='block'; /* var bheight = document.getElementById(strId).offsetHeight; var th = 0; if (navigator.appName.indexOf("Microsoft")!=-1) { th = document.body.offsetHeight - 20; } else { th = window.innerHeight - 16; } if (otop + bheight > th) { var n_otop = otop - bheight + document.getElementById(strTopId).offsetHeight; if (n_otop > 0) document.getElementById(strId).style.top= n_otop + "px"; } */ } // make a dropdown menu or IFRAME appear over the top (same top/left position) of another object. function o_dm_ovx_i(strId, strTopId) { var dest_obj = document.getElementById(strId); // catch wrapping shadow div if available var pos_obj = document.getElementById('sw_' + strId); if (pos_obj == null) pos_obj = dest_obj; var ref_obj = document.getElementById(strTopId); dest_obj.dmEnable = 1; pos_obj.style.top= findPosY(ref_obj) + "px"; pos_obj.style.left=findPosX(ref_obj) + "px"; dest_obj.style.height = ref_obj.offsetHeight + "px"; dest_obj.style.width = ref_obj.offsetWidth + "px"; pos_obj.style.display='block'; } function b_dm_ovx(strIdn) { strId = 'dm_'+strIdn; strTopId = 'ml_'+strIdn; return b_dm_ovx_i(strId,strTopId); } function b_dm_ovx_i(strId, strTopId) { document.getElementById(strId).dmEnable = 1; document.getElementById(strId).style.top=(findPosY(document.getElementById(strTopId)) + document.getElementById(strTopId).offsetHeight) + "px"; document.getElementById(strId).style.left=findPosX(document.getElementById(strTopId)) + "px"; document.getElementById(strId).style.display='block'; } function br_dm_ovx_i(strId, strTopId, noSwap) { var s_width = parseInt(parent.document.documentElement.clientWidth); if (s_width == 0) s_width = parseInt(parent.document.body.clientWidth); var idO = document.getElementById(strId); if (noSwap == null && idO.className == 'iasp_tooltip_Right') { brr_dm_ovx_i(strId,strTopId,1); } else { idO.dmEnable = 1; idO.style.top=(findPosY(document.getElementById(strTopId)) + document.getElementById(strTopId).offsetHeight) + "px"; idO.style.left = '12px'; var lVal = (findPosX(document.getElementById(strTopId)) + document.getElementById(strTopId).offsetWidth); idO.style.display='block'; idO.style.left=lVal + "px"; if (idO.className == 'iasp_tooltip_Left' && noSwap != 1) { if (lVal + idO.offsetWidth > s_width || lVal + 200 > s_width) { idO.className = 'iasp_tooltip_Right'; brr_dm_ovx_i(strId,strTopId); } } else if (idO.className == 'iasp_tooltip_Right') idO.className = 'iasp_tooltip_Left'; } } function brr_dm_ovx_i(strId, strTopId) { var idO = document.getElementById(strId); idO.dmEnable = 1; idO.style.top=(findPosY(document.getElementById(strTopId)) + document.getElementById(strTopId).offsetHeight) + "px"; //idO.style.left=findPosX(document.getElementById(strTopId)) + "px"; idO.style.left = '12px'; idO.style.display='block'; var lVal = (findPosX(document.getElementById(strTopId)) - idO.offsetWidth); if (idO.className == 'iasp_tooltip_Left') idO.className = 'iasp_tooltip_Right'; if (idO.className == 'iasp_tooltip_Right' && lVal < 0) { idO.className = 'iasp_tooltip_Left'; br_dm_ovx_i(strId,strTopId,1); } else { idO.style.left=lVal + 'px'; } } function dm_svx(strId,strParent) { if (document.getElementById(strId).forcehide != 1) { document.getElementById(strId).dmEnable = 1; if (strParent != null) document.getElementById('dm_' + strParent).dmEnable = 1; } } // // Automatic dropdown code // function a_dm_cvx(strIdn) { strId = 'dm_' + strIdn; document.getElementById(strId).dmEnable = 0; setTimeout('cvis(\'dm_'+strIdn+'\',document.getElementById(\''+strId+'\').dmEnable)',100); } function cvis(strId, dmx) { if (dmx != 1) { document.getElementById(strId).style.display='none'; } } function a_dm_ovx(strIdn) { strId = 'dm_'+strIdn; strTopId = 'ml_'+strIdn; document.getElementById(strId).dmEnable = 1; document.getElementById(strId).style.top=(findPosY(document.getElementById(strTopId)) + document.getElementById(strTopId).offsetHeight + 1) + "px"; document.getElementById(strId).style.left=findPosX(document.getElementById(strTopId)) + "px"; document.getElementById(strId).style.display='block'; } function a_dm_svx(strIdn) { strId = 'dm_'+strIdn; document.getElementById(strId).dmEnable = 1; } // // Basic general-purpose functions // // // Find Position // from quirksmode.org // with improvements to catch absolute/relative positioned parents // function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { if (document.defaultView && document.defaultView.getComputedStyle) { // is Gecko / W3C DOM var cs = document.defaultView.getComputedStyle(obj,''); if ((cs.getPropertyValue('position') == 'absolute' && cs.getPropertyValue('left') != null) || cs.getPropertyValue('position') == 'relative') { break; } } else if (obj.currentStyle) { // is IE if ((obj.currentStyle.position == 'absolute' && obj.currentStyle.left != null) || obj.currentStyle.position == 'relative') { break; } } curleft += obj.offsetLeft; obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } CMS.findPosX = findPosX; function findPosY(obj) { var curtop = 0; //alert(obj.tagName + '---' + obj.id); if (obj.offsetParent) { while (obj.offsetParent) { if (document.defaultView && document.defaultView.getComputedStyle) { // is Gecko / W3C DOM var cs = document.defaultView.getComputedStyle(obj,''); if ((cs.getPropertyValue('position') == 'absolute' && cs.getPropertyValue('top') != null) || cs.getPropertyValue('position') == 'relative') { break; } } else if (obj.currentStyle) { // is IE if ((obj.currentStyle.position == 'absolute' && obj.currentStyle.top != null) || obj.currentStyle.position == 'relative') { break; } } curtop += obj.offsetTop; obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } CMS.findPosY = findPosY; function findAbsPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft; obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } CMS.findAbsPosX = findAbsPosX; function findAbsPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop; obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } CMS.findAbsPosY = findAbsPosY; function parentFindPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { if (parent.document.defaultView && parent.document.defaultView.getComputedStyle) { // is Gecko / W3C DOM var cs = parent.document.defaultView.getComputedStyle(obj,''); if ((cs.getPropertyValue('position') == 'absolute' && cs.getPropertyValue('left') != null) || cs.getPropertyValue('position') == 'relative') { break; } } else if (obj.currentStyle) { // is IE if ((obj.currentStyle.position == 'absolute' && obj.currentStyle.left != null) || obj.currentStyle.position == 'relative') { break; } } curleft += obj.offsetLeft; obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } function parentFindPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { if (parent.document.defaultView && parent.document.defaultView.getComputedStyle) { // is Gecko / W3C DOM var cs = parent.document.defaultView.getComputedStyle(obj,''); if ((cs.getPropertyValue('position') == 'absolute' && cs.getPropertyValue('top') != null) || cs.getPropertyValue('position') == 'relative') { break; } } else if (obj.currentStyle) { // is IE if ((obj.currentStyle.position == 'absolute' && obj.currentStyle.top != null) || obj.currentStyle.position == 'relative') { break; } } curtop += obj.offsetTop; obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } // // DEPRECATED Auto-resizing Image Popup // PositionX = 100; PositionY = 100; defaultWidth = 500; defaultHeight = 500; var AutoClose = true; if (parseInt(navigator.appVersion.charAt(0))>=4) { var isNN=(navigator.appName=="Netscape")?1:0; var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0; } var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY; var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY; function i_popImage(imageURL,imageTitle){ if (imageTitle == null) imageTitle = 'View Image'; if (isNN){imgWin=window.open('about:blank','',optNN);} if (isIE){imgWin=window.open('about:blank','',optIE);} with (imgWin.document){ writeln('