/*
 * WysiwygPro 3.0.3.20080303 (c) Copyright Chris Bolt and ViziMetrics Inc. All Rights Reserved.
 * Unlicensed distribution, copying, reverse engineering, re-purposing or otherwise stealing of this code is a violation of copyright law.
 * Get yourself a license at www.wysiwygpro.com
 */

if (!String.prototype.trim) {
String.prototype.trim=function () {
return this.replace(/^\s+|\s+$/g,"");
};
};
if (!Array.prototype.push) {
Array.prototype.push = function(){
for(var i = 0; i < arguments.length; i++){
this[this.length] = arguments[i];
};
return this.length;
};
};
if (!wproWinOpen) {
var wproWinOpen = eval('wi'+'nd'+'ow.'+'op'+'en')
}
if (!wproModelessDialog) {
var wproModelessDialog = eval('wi'+'nd'+'ow'+'.s'+'ho'+'wM'+'od'+'el'+'es'+'sD'+'ia'+'log')
}
if (!wproModalDialog) {
var wproModalDialog = eval('wi'+'nd'+'ow'+'.s'+'ho'+'wM'+'od'+'al'+'Dia'+'log')
}
wproDialogRecord = {};
wproDialogRecord['frames'] = [];
wproDialogRecord['windows'] = [];
function wproCloseOpenDialogs(dialog) {
if (typeof(dialog) != 'undefined') {
if (wproDialogRecord['frames'][dialog]) {
var n = wproDialogRecord['frames'][dialog].length;
for (var i=0; i<n; i++) {
if (wproDialogRecord['frames'][dialog][i]) {
var iframe = wproDialogRecord['frames'][dialog][i];
if (iframe.parentNode) {
try{iframe.parentNode.removeChild(iframe);
wproDialogRecord['frames'][dialog][i]=null;
}catch(e){}
}
}
}
wproDialogRecord['frames'][dialog] = [];
}
} else {
var n = wproDialogRecord['windows'].length;
for (var i=0; i<n; i++) {
if (wproDialogRecord['windows'][i] ) {
if (typeof(wproDialogRecord['windows'][i].close) != 'undefined') {
wproDialogRecord['windows'][i].close();
wproDialogRecord['windows'][i]=null;
}
}
}
wproDialogRecord['windows'] = [];
}
}
var WPRO_FB_RETURN_FUNCTION = {}
var WPRO_FB_GET_FUNCTION = {}
function wproOpenFileBrowser(type, returnFunction, getFunction, baseurl, sid, iframe, phpsid, appendToQueryStrings, route) {
if (!type) type = 'link';
WPRO_FB_RETURN_FUNCTION[sid] = returnFunction
WPRO_FB_GET_FUNCTION[sid] = getFunction
var url = wproEditorLink('dialog.php?dialog=wproCore_fileBrowser&action=link&chooser=true&dirs='+type + '&' + sid + (phpsid ? '&' + phpsid : '') + (appendToQueryStrings ? '&' + appendToQueryStrings : ''), baseurl, route);
if (iframe) {
var frame = 'wpfileBrowser_dialogFrame';
}
wp_openDialog(url, 'modal', 760, 480-55, '', frame);
}
function wpro_sessTimeout (internalId, sid, phpsid, url, appendToQueryStrings, sessRefresh, route) {
var tag
if (tag = document.getElementById(internalId+'_sessTag')) {
tag.parentNode.removeChild(tag);
}
setTimeout('try{wpro_createSessTag("touch", "'+wproAddSlashes(internalId)+'", "'+wproAddSlashes(sid)+'", "'+wproAddSlashes(phpsid)+'", "'+wproAddSlashes(url)+'", "'+wproAddSlashes(appendToQueryStrings)+'", "'+wproAddSlashes(route)+'");}catch(e){}', sessRefresh*1000);
}
function wpro_createSessTag (action, internalId, sid, phpsid, baseurl, appendToQueryStrings, route) {
var h = document.getElementsByTagName('BODY')[0];
var tag;
if (tag = document.getElementById(internalId+'_sessTag')) {
tag.parentNode.removeChild(tag);
}
var s = document.createElement('SCRIPT');
s.setAttribute('type', 'text/javascript');
s.setAttribute('id', this._internalId+'_sessTag');
var srcStr = 'core/touch.php?' + sid + (phpsid ? '&' + phpsid : '');
if (action == 'destroy') {
srcStr += '&action=destroy';
} else {
srcStr += '&action=touch';
}
srcStr += '&name='+internalId;
srcStr += '&rand='+Math.random();
if (appendToQueryStrings) srcStr += '&' + appendToQueryStrings;
h.appendChild(s);
s.src = wproEditorLink(srcStr, baseurl, route);
}
function wproEditorLink(url, base, route) {
if (route && route!='') {
var a = url.split(/\?/);
var u = a[0];
var q = (typeof(a[1])=='undefined') ? '' : a[1];
return route + (route.match(/\?/) ? '&' : '?') + 'wproroutelink=' + escape(u.replace(/\//g,'-').replace(/\.php/,'')) + '&'+q;
} else {
return base + url;
}
}
function wp_openDialog(url, modal, width, height, features, iframe, dialog) {
if (!modal) {
modal = 'modal';
}
if (!features) {
features = '';
}
var win = false;
if (iframe) {
width +=4;
height += 20;
if (window.showModalDialog) {
height += 5;
}
var left = 0;
var top = 0;
iframe = document.getElementById(iframe);
iframe.setAttribute('scrolling', 'no');
iframe.setAttribute('bgColor', '#ffffff;');
if (iframe.contentWindow.document.body) {
iframe.contentWindow.document.body.style.display="none";
}
iframe.contentWindow.document.location.replace( url );
iframe.style.width = width +'px';
iframe.style.height = height +'px';
iframe.style.visibility = 'visible';
iframe.style.display = 'block';
var scrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft
var scrollTop = document.body.scrollTop + document.documentElement.scrollTop
var winDim = wproGetWindowInnerHeight();
var availHeight = winDim['height'];
var availWidth = winDim['width'];
if (width < availWidth) {
left = (availWidth/2)-(width/2);
}
if (height < availHeight) {
top = (availHeight/2)-(height/2);
}
left += scrollLeft
top += scrollTop
iframe.style.top = top+'px';
iframe.style.left = left+'px';
if (typeof(dialog) != 'undefined') {
if (typeof(wproDialogRecord['frames'][dialog])=='undefined') {
wproDialogRecord['frames'][dialog] = [];
}
wproDialogRecord['frames'][dialog].push(iframe);
}
} else {
wproCloseOpenDialogs();
if (/\?/.test(url)) {
url+='&dWidth='+width+'&dHeight='+height;
} else {
url+='?dWidth='+width+'&dHeight='+height;
}
if (window.showModalDialog&&/msie/i.test(navigator.appVersion)) {
if (parseInt(navigator.appVersion.replace(/[\s\S]*?MSIE ([0-9\.]*)[\s\S]*?/gi, "$1") ) < 7) {
var nWidth = width + 12;
var nHeight = height + 56;
} else {
var nWidth = width;
var nHeight = height;
}
var params = 'dialogWidth:'+nWidth+'px;dialogHeight:'+ nHeight + 'px;help:no;';
features = features.replace(/\,/gi, ';');
features = features.replace(/\=/gi, ':');
features = features.replace(/scrollbars/gi, 'scroll');
features = features.replace(/left/gi, 'dialogLeft');
features = features.replace(/top/gi, 'dialogTop');
features = features.replace(/width/gi, 'dialogWidth');
features = features.replace(/height/gi, 'dialogHeight');
if ((features.search('scroll')) == -1) {
params += "scroll:no;";
}
if (features.search('status') == -1) {
params += "status:yes;";
}
if (features.search('resizable') == -1) {
params += "resizable:yes;";
}
params += features;
if (modal == 'modeless') {
win=wproModelessDialog(url, window, params);
} else {
win=wproModalDialog(url, window, params);
}
} else {
var name = url.split('?');
var params = '';
if (features.search('left') == -1) {
params = "left="+((screen.width/2)-(width/2))+",";
}
if (features.search('top') == -1) {
params += "top="+((screen.height/2)-(height/2))+",";
}
if ((features.search('scrollbars')) == -1) {
params += "scrollbars=no,";
}
if (features.search('status') == -1) {
params += "status=yes,"
}
if (features.search('resizable') == -1) {
params += "resizable=yes,";
}
if (modal == 'modeless') {
win = wproWinOpen(url, name[1], "dependent=yes,width="+width+"px,height="+height+"px,"+features+","+params);
} else {
win = wproWinOpen(url, name[1], "dependent=yes,modal=yes,width="+width+"px,height="+height+"px,"+features+","+params);
}
if (!win) {alert('This feature requires you to enable p'+'o'+'p'+'u'+'p windows.');return false;}
win.focus();
wproDialogRecord['windows'].push(win);
}
}
return win;
}
function wproTimer () {
this.timerIds = [];
}
wproTimer.prototype.addTimer = function (func, delay) {
var id = setTimeout(func,delay);
this.timerIds.push(id);
return id;
}
wproTimer.prototype.stopTimer = function (id) {
clearTimeout(id);
}
wproTimer.prototype.clearAllTimers = function () {
var n = this.timerIds.length;
for (var i=0; i<n; i++) {
if (this.timerIds[i]) {
clearTimeout(this.timerIds[i]);
this.timerIds[i]=null;
}
}
this.timerIds = [];
}
function wproEvents() {
this.events = [];
}
wproEvents.prototype.addEvent = function (node, trigger, func) {
if (trigger.substr(0,2) == 'on') {
trigger = trigger.substr(2);
}
if (node.addEventListener) {
node.addEventListener(trigger, func, false);
} else if (node.attachEvent) {
node.attachEvent('on'+trigger, func);
}
this.events.push(arguments);
return arguments;
}
wproEvents.prototype.removeEvent = function (node, trigger, func) {
if (node) {
if (trigger.substr(0,2) == 'on') {
trigger = trigger.substr(2);
}
if (node.removeEventListener) {
node.removeEventListener(trigger, func, false);
} else if (node.detachEvent) {
node.detachEvent('on'+trigger, func);
}
try{if (node['on'+trigger])
node['on'+trigger] = null;}catch(e){}
}
}
wproEvents.prototype.removeEventById = function (id) {
if (id) {
this.removeEvent (id[0], id[1], id[2]);
}
}
wproEvents.prototype.removeAllEvents = function () {
var l = this.events.length;
for (var i = this.events.length - 1; i >= 0; i--) {
if (this.events[i]) {
this.removeEventById(this.events[i]);
}
}
this.events=[];
}
wproEvents.prototype.preventDefault = function (e) {
if (e.stopPropagation) e.stopPropagation();
if (e.preventDefault) e.preventDefault();
e.cancelBubble = true;
e.returnValue = false;
}
function wproGetWindowInnerHeight(win) {
if (!win) win = window;
var doc = window.document;
var availHeight, availWidth
if (window.innerHeight) {
availHeight = window.innerHeight;
availWidth = window.innerWidth;
} else if (document.documentElement.clientHeight) {
availHeight=document.documentElement.clientHeight;
availWidth=document.documentElement.clientWidth;
} else {
availHeight=document.body.clientHeight;
availWidth=document.body.clientWidth;
}
return {'width':availWidth, 'height':availHeight};
}
function wproCreateStyleSheet(url) {
var head = document.getElementsByTagName('HEAD')[0];
var link = document.createElement('LINK');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('href', url);
link.setAttribute('type', 'text/css');
head.appendChild(link);
}
function wproLoadMessage(name,width,height,text,image,show){
if(!show) {
show='none';
} else {
show='block';
}
if (!height) {
height = '200px';
}
if (!width) {
width = '100%';
}
if (!width.toString().match(/(%|px)/)) {
width = width + 'px';
}
if (height=='0') {
height='200px'
}
if (!height.toString().match(/(px|%)/)) {
height = height + 'px';
}
document.write('<div id="'+name+'_loadMessage" class="wproLoadMessageHolder" style="'+(width?'width:'+width+';':'')+'height:'+(height)+';display:'+show+'"><div class="wproLoadMessage" style="margin-top:'+(parseInt(height.replace(/[px %]/gi, ''))/2 - 40)+'px"><img src="'+image+'" alt="" /> '+text+'</div></div>');
}
function wproResizeLoadMessageTo(name, width, height) {
if (!width) {
width = '100%';
}
if (!width.toString().match(/(%|px)/)) {
width = width + 'px';
}
if (!height||height=='0') {
height='200px'
}
if (!height.toString().match(/(px|%)/)) {
height = height + 'px';
}
document.getElementById(name+'_loadMessage').style.height=height;
document.getElementById(name+'_loadMessage').style.width=width;
document.getElementById(name+'_loadMessage').firstChild.style.marginTop = (parseInt(height.replace(/[px %]/gi, ''))/2 - 40)+'px';
}
function wproGetNodeAttributesString (node, events) {
if(events==undefined)events=true;
var str = '';
var a = node.attributes;
var n = a.length
if (node.className) {
str += ' class="'+wproHtmlSpecialChars(node.className)+'"';
}
if (node.style.cssText) {
if (node.style.cssText.length) str += ' style="'+wproHtmlSpecialChars(node.style.cssText)+'"';
}
if (node.onload!=null&&node.onload!=undefined) {
str += ' onload="'+wproHtmlSpecialChars(String(node.onload))+'"';
}
for (var i=0; i < n; i++) {
if(!events&&a[i].nodeName.substr(0,2)=='on')continue;
if (a[i].specified && a[i].nodeName != 'class' && a[i].nodeName != 'style') {
str += ' '+a[i].nodeName.toLowerCase()+'="'+wproHtmlSpecialChars(a[i].nodeValue)+'"';
}
}
return str;
}
function wproQuoteMeta (str) {
str = str.replace( /([^A-Za-z0-9])/g , "\\$1" );
return str;
}
function wproRgbToHex(R,G,B) {return this.toHex(R)+this.toHex(G)+this.toHex(B)}
function wproToHex(N) {
if (N==null) return "00";
N=parseInt(N); if (N==0 || isNaN(N)) return "00";
N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
return "0123456789abcdef".charAt((N-N%16)/16)
+ "0123456789abcdef".charAt(N%16);
}
function wproHexToR(h) {return parseInt((this.cutHex(h)).substring(0,2),16)}
function wproHexToG(h) {return parseInt((this.cutHex(h)).substring(2,4),16)}
function wproHexToB(h) {return parseInt((this.cutHex(h)).substring(4,6),16)}
function wproCutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}
function wproHexToRGB(h) {return 'rgb('+this.hexToR(h)+', '+this.hexToG(h)+', '+this.hexToB(h)+')'}
function wproStyleFormatting (str, raw) {
if (/style="/.test(str)) {
str = str.substring(7);
}
if (raw) {
str = this.htmlSpecialCharsDecode(str);
}
var arr = {};
str = str.replace(/url\([\s\S]*?\)/gi, function(x){return '[WP'+escape(x)+'WP]';});
str = str.replace(/"[\s\S]*?"/g, function(x){return '[WP'+escape(x)+'WP]';});
str = str.replace(/'[\s\S]*?'/g, function(x){return '[WP'+escape(x)+'WP]';});
var styles = str.match(/([A-Za-z\-]*:[^;]*)/gi);
if (styles) {
var n = styles.length;
for (var i=0; i<n; i++) {
s = styles[i].split(':');
if (s[0] && s[1]) {
if (/^\s*mso-/.test(s[0])) continue;
arr[s[0].toLowerCase()] = s[1].replace(/^([^\s]+)/, ' $1');
}
}
this._compressBoxStyles(arr, 'border', '-width', 'border-width');
this._compressBoxStyles(arr, 'border', '-color', 'border-color');
this._compressBoxStyles(arr, 'border', '-style', 'border-style');
this._compressBoxStyles(arr, 'border', '', 'border');
this._compressBoxStyles(arr, 'padding', '', 'padding');
this._compressBoxStyles(arr, 'margin', '', 'margin');
this._shorthandStyles(arr, 'list-style', ['-type','-position','-color']);
this._shorthandStyles(arr, 'border', ['-color','-width','-style']);
this._shorthandStyles(arr, 'border-top', ['-color','-width','-style']);
this._shorthandStyles(arr, 'border-right', ['-color','-width','-style']);
this._shorthandStyles(arr, 'border-bottom', ['-color','-width','-style']);
this._shorthandStyles(arr, 'border-left', ['-color','-width','-style']);
this._shorthandStyles(arr, 'background', ['-color','-image','-repeat','-attachment','-position']);
var str = '';
for (var key in arr) {
var val = arr[key];
if (!val) continue;
str += key + ':'+val+'; ';
}
if (/; $/.test(str)) {
str = str.substring(0, str.length - 2);
}
}
str = str.replace(/\[WP[\s\S]*?WP\]/g, function(x){return unescape(x).replace(/\[WP/g, '').replace(/WP\]/g, '');});
var urls = str.match(/url\([\s\S]*?\)/gi);
if (urls) {
var n = urls.length;
for (var i=0; i<n; i++) {
var url = urls[i].replace(/url\([\s"']*([\s\S]*?)[\s"']*\)/gi, "$1");
if (this.urlFormatting) {
url = this.urlFormatting(url);
} else if (this.currentEditor.urlFormatting) {
url = this.currentEditor.urlFormatting(url);
} else {
}
str = str.replace(urls[i], 'url(\''+url+'\')');
}
}
if (raw) {
str = this.htmlSpecialChars(str);
}
return str;
}
function wp_shorthandStyles(arr, pr, sArr) {
var n = sArr.length
var fCount = new Array;
for (var i=1; i<n; i++) {
if (arr[pr+sArr[i]]) {
fCount.push(pr+sArr[i]);
}
}
if (fCount.length < 3) return;
arr[pr]='';
var n = fCount.length;
for (var i=1; i<n; i++) {
arr[pr] += arr[fCount[i]];
arr[fCount[i]] = null;
}
}
function wp_compressBoxStyles (arr, pr, sf, res) {
var box = new Array();
box[0] = arr[pr + '-top' + sf];
box[1] = arr[pr + '-right' + sf];
box[2] = arr[pr + '-bottom' + sf];
box[3] = arr[pr + '-left' + sf];
if (box[0]==null||box[1]==null||box[2]==null||box[3]==null) {
return;
}
if (pr=='margin'||pr=='padding') {
if (box[0]==box[2]&&box[1]==box[3]) {
box[2]='';box[3]='';
} else if (box[1]==box[3]) {
box[3] = '';
}
if (box[0]==box[1]) box[1]='';
arr[res] = box[0] + box[1] + box[2] + box[3];
} else {
var n = box.length
for (var i=1; i<n; i++) {
if (box[i] != box[0]) {
return;
}
}
arr[res] = box[0];
}
arr[pr + '-top' + sf] = null;
arr[pr + '-left' + sf] = null;
arr[pr + '-right' + sf] = null;
arr[pr + '-bottom' + sf] = null;
}
function wp_setBrowserTypeStrings () {
this.isIE = (this.browserType=='msie') ? true : false;
this.isGecko = (this.browserType=='gecko') ? true : false;
this.isSafari = (this.browserType=='safari') ? true : false;
this.isOpera = (this.browserType=='opera') ? true : false;
if (this.isIE) {
try{document.execCommand("BackgroundImageCache", false, true);}catch(e){}
}
}
wproUrlEncode = function (sStr) {
return escape(sStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
}
wproUrlDecode = function (psEncodeString) {
return unescape(psEncodeString);
}
wproAddSlashes = function (str) {
return String(str).replace(/\\/gi, "\\\\").replace(/'/gi, "\\'").replace(/"/gi, '\\"');
}
wproHtmlSpecialChars = function (str) {
return String(str).replace(/&/gi, '&amp;').replace(/\xA0/gi, '&nbsp;').replace(/</gi, '&lt;').replace(/>/gi, '&gt;').replace(/"/gi, '&quot;')
}
wproHtmlSpecialCharsDecode =  function (str) {
return String(str).replace(/&nbsp;/gi, String.fromCharCode(160)).replace(/&lt;/gi, '<').replace(/&gt;/gi, '>').replace(/&quot;/gi, '"').replace(/&amp;/gi, '&')
}
function wproFMenuOver () {
var c = this.className;
if (c=='wproLatched') {
this.className = 'wproOver wproLatched';
} else {
this.className = 'wproOver';
}
}
function wproFMenuOut () {
var c = this.className;
if (c=='wproOver wproLatched' || c=='wproLatched' ) {
this.className = 'wproLatched';
} else {
this.className = '';
}
}
/*
 * WysiwygPro 3.0.3.20080303 (c) Copyright Chris Bolt and ViziMetrics Inc. All Rights Reserved.
 * Unlicensed distribution, copying, reverse engineering, re-purposing or otherwise stealing of this code is a violation of copyright law.
 * Get yourself a license at www.wysiwygpro.com
 */

function wproPMenu (editor) {
this.PMenu = null;
this.editor = editor;
this.inDialog = false;
this.rangeToReselect = null;
this.reselect = true;
this.onclose = null;
}
wproPMenu.prototype.reselectRange = function () {
if (this.reselect && this.rangeToReselect && WPro.isIE) {
try{this.rangeToReselect.select();}catch(e){}
}
}
wproPMenu.prototype.getLocation = function (oWidth, oHeight, posx, posy) {
var scrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft
var scrollTop = document.body.scrollTop + document.documentElement.scrollTop
var winDim = wproGetWindowInnerHeight();
var availHeight = winDim['height'];
var availWidth = winDim['width'];
if (oWidth>availWidth) {
oWidth = availWidth;
oHeight +=18;
}
if (oHeight>availHeight) {
oHeight = availHeight;
oWidth +=18;
}
availHeight += scrollTop;
availWidth += scrollLeft;
availWidth-= 25
availHeight-= 25
var leftPos; var rightPos;
if (posx + oWidth > availWidth) {
leftPos = availWidth - oWidth;
} else {
leftPos = posx;
}
if (posy + oHeight > availHeight) {
topPos = availHeight - oHeight;
} else {
topPos = posy;
}
return {width:oWidth,height:oHeight,left:leftPos,top:topPos}
}
wproPMenu.prototype.showDropDown = function (popframe, head, body, width, height, posx, posy) {
wp_current_obj = WPro.editors[this.editor];
WPro.currentEditor = WPro.editors[this.editor];
this._removeEvents();
var doc = popframe.contentWindow.document;
var wproWritten = false;
try{wproWritten = doc.wproWritten}catch(e){};
if (wproWritten) {
doc.body.innerHTML = body;
} else {
doc.open();
doc.write('<html><head>'+head+'</head><body unselectable="on">'+body+'</body></html>');
doc.close();
}
popframe.style.width = width+'px';
popframe.style.height = height+'px'
this.showPMenu (popframe, width, height, posx, posy, 'dropdown');
if (WPro.isIE) {
var keyhandler = 'keydown';
} else {
var keyhandler = 'keypress';
}
if (wproWritten) {
WPro.events.addEvent(doc,keyhandler,this.dropDownKeyHandler);
} else {
try{doc.wproWritten = true;}catch(e){};
}
this.popDoc = doc;
return {width:width, height:height, posx:posx, posy:posy};
}
wproPMenu.prototype.dropDownKeyHandler = function (evt) {
var keyCode = evt.keyCode;
var dir = 'down';
if (keyCode == 38) {
dir='up'
} else if (keyCode == 40) {
dir='down'
} else if (keyCode == 13) {
dir='enter'
} else {
return;
}
var doc
if (evt.target) {
doc = evt.target
} else {
doc = evt.srcElement
}
var divs = doc.getElementsByTagName('DIV');
var n=divs.length;
var found = false;
var newNode
for (var i=0; i < n; i++) {
if (divs[i].className=='wproOn') {
divs[i].className = 'wproOff';
newNode = divs[i];
var found = true;
if (dir=='enter') {
divs[i].onclick();
return;
}
if (dir=='down') {
if (divs[i].nextSibling!=null) {
if (divs[i].nextSibling.className=='wproHeading') {
newNode = divs[i].nextSibling.nextSibling
} else {
newNode = divs[i].nextSibling
}
} else {
for (var j=0; j < n; j++) {
if (divs[j].className=='wproOff') {
newNode = divs[j]
break;
}
}
}
}
if (dir=='up') {
if (divs[i].previousSibling!=null) {
if (divs[i].previousSibling.className=='wproHeading') {
newNode = divs[i].previousSibling.previousSibling
} else {
newNode = divs[i].previousSibling
}
} else {
for (var j=n-1; j > 0; j--) {
if (divs[j].className=='wproOff') {
newNode = divs[j]
break;
}
}
}
}
break;
}
}
if (!found) {
for (var i=0; i < n; i++) {
if (divs[i].className=='wproOff') {
newNode = divs[i];
break;
}
}
}
if (newNode) {
newNode.className = 'wproOn';
var pos = WPro.getElementPosition(newNode);
var PMenu = WPro.currentEditor.PMenu.PMenu
if (PMenu.contentWindow) {
PMenu.contentWindow.scrollTo(pos['left'],pos['top']-(newNode.offsetHeight));
}
}
WPro.preventDefault(evt);
}
wproPMenu.prototype.showPMenu = function (node, width, height, posx, posy, type) {
if (this.editor) wp_current_obj = WPro.editors[this.editor];
if (this.editor) WPro.currentEditor = WPro.editors[this.editor];
if (WPro) {
if (WPro.isIE&&this.editor) {
this.rangeToReselect = WPro.currentEditor.editDocument.selection.createRange();
}
}
this.closePMenu();
var loc = this.getLocation(width, height, posx, posy);
node.style.top = loc['top']+'px';
node.style.left = loc['left']+'px';
node.style.width = loc['width']+'px';
node.style.height = loc['height']+'px';
this.PMenu = node;
this.PMenu.style.visibility = 'visible';
if (type != 'dropdown') {
if (this.editor) {
if (WPro.isIE) {
var keyhandler = 'keydown';
} else {
var keyhandler = 'keydown';
}
WPro.events.addEvent(this.PMenu,keyhandler,this.menuKeyHandler);
setTimeout("try{if(typeof(WPro.editors['"+this.editor+"'].PMenu.PMenu.firstChild)!='undefined')WPro.editors['"+this.editor+"'].PMenu.PMenu.firstChild.focus();}catch(e){}", 1);
} else {
if (dialog.isIE) {
var keyhandler = 'keydown';
} else {
var keyhandler = 'keydown';
}
dialog.events.addEvent(this.PMenu,keyhandler,this.menuKeyHandler);
setTimeout("try{if(typeof(dialog.PMenu.PMenu.firstChild)!='undefined')dialog.PMenu.PMenu.firstChild.focus();}catch(e){}", 1);
}
}
}
wproPMenu.prototype.menuKeyHandler = function (evt) {
var keyCode = evt.keyCode;
var dir = 'down';
if (keyCode == 38) {
dir='up'
} else if (keyCode == 40) {
dir='down'
} else {
return;
}
var doc
if (evt.target) {
doc = evt.target.parentNode
} else {
doc = evt.srcElement.parentNode
}
var divs = doc.getElementsByTagName('A');
var n=divs.length;
var found = false;
var newNode
for (var i=0; i < n; i++) {
if (divs[i].className == 'wproOver' || divs[i].className == 'wproOver wproLatched') {
if (divs[i].className == 'wproOver wproLatched') {
divs[i].className = 'wproLatched';
} else {
divs[i].className = '';
}
newNode = divs[i];
var found = true;
if (dir=='down') {
if (i+1 < n) {
newNode = divs[i+1]
} else {
newNode = divs[1]
}
}
if (dir=='up') {
if (i-1 >= 1) {
newNode = divs[i-1]
} else {
newNode = divs[n-1]
}
}
break;
}
}
if (!found) {
newNode = divs[1];
}
if (newNode) {
newNode.focus();
}
WPro.preventDefault(evt);
}
wproPMenu.prototype.closePMenu = function () {
if (this.PMenu) {
if (this.PMenu != null) {
this.PMenu.style.display = 'none';
this.PMenu = null;
if (this.onclose!=null) {
this.onclose();
}
}
}
this._removeEvents();
}
wproPMenu.prototype._removeEvents = function() {
}
/*
 * WysiwygPro 3.0.3.20080303 (c) Copyright Chris Bolt and ViziMetrics Inc. All Rights Reserved.
 * Unlicensed distribution, copying, reverse engineering, re-purposing or otherwise stealing of this code is a violation of copyright law.
 * Get yourself a license at www.wysiwygpro.com
 */


var WPRO_DIF_dragging=false;
var WPRO_DIF_iframeBeingDragged="";
var WPRO_DIF_iframeObjects=new Object();
var WPRO_DIF_iframeWindows=new Object();
var WPRO_DIF_iframeMouseDownLeft = new Object();
var WPRO_DIF_iframeMouseDownTop = new Object();
var WPRO_DIF_pageMouseDownLeft = new Object();
var WPRO_DIF_pageMouseDownTop = new Object();
var WPRO_DIF_handles = new Object();
var WPRO_DIF_highestZIndex=99;
var WPRO_DIF_raiseSelectedIframe=false;
var WPRO_DIF_allowDragOffScreen=false;
function WPRO_DIF_addHandle(o, win) {
if (arguments.length==2 && win==window) {
var p = win;
while (p=p.parent) {
if (p.WPRO_DIF_addHandle) { p.WPRO_DIF_addHandle(o,win,true); return; }
if (p==win.top) { return; }
}
return;
}
var topRef=win;
var topRefStr = "window";
while (topRef.parent && topRef.parent!=window) {
topRef = topRef.parent;
topRefStr = topRefStr + ".parent";
}
if (typeof(win.WPRO_DIF_mainHandlersAdded)=="undefined" || !win.WPRO_DIF_mainHandlersAdded) {
with (win) {
eval("function OnMouseDownHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.WPRO_DIF_begindrag(evt, "+topRefStr+") }");
eval("document.onmousedown = OnMouseDownHandler;");
eval("function OnMouseUpHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.WPRO_DIF_enddrag(evt, "+topRefStr+") }");
eval("document.onmouseup = OnMouseUpHandler;");
eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.WPRO_DIF_iframemove(evt, "+topRefStr+") }");
eval("document.onmousemove = OnMouseMoveHandler;");
win.WPRO_DIF_handlersAdded = true;
win.WPRO_DIF_mainHandlersAdded = true;
}
}
if (typeof(window.WPRO_DIF_handlersAdded)!="undefined" || !window.WPRO_DIF_handlersAdded) {
eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}WPRO_DIF_mouseMove(evt, window) }");
eval("document.onmousemove = OnMouseMoveHandler;");
eval("function OnMouseUpHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}WPRO_DIF_enddrag(evt, window) }");
eval("document.onmouseup = OnMouseUpHandler;");
window.WPRO_DIF_handlersAdded=true;
}
var name = WPRO_DIF_getIframeId(topRef);
if (WPRO_DIF_handles[name]==null) {
WPRO_DIF_handles[name] = new Array();
WPRO_DIF_iframeMouseDownLeft[name] = 0;
WPRO_DIF_iframeMouseDownTop[name] = 0;
WPRO_DIF_pageMouseDownLeft[name] = 0;
WPRO_DIF_pageMouseDownTop[name] = 0;
}
WPRO_DIF_handles[name][WPRO_DIF_handles[name].length] = o;
}
function WPRO_DIF_getEventPosition(evt) {
var pos=new Object();
pos.x=0;
pos.y=0;
if (!evt) {
evt = window.event;
}
if (typeof(evt.pageX) == 'number') {
pos.x = evt.pageX;
pos.y = evt.pageY;
} else {
pos.x = evt.clientX;
pos.y = evt.clientY;
if (!top.opera) {
if ((!window.document.compatMode) || (window.document.compatMode == 'BackCompat')) {
pos.x += window.document.body.scrollLeft;
pos.y += window.document.body.scrollTop;
} else {
pos.x += window.document.documentElement.scrollLeft;
pos.y += window.document.documentElement.scrollTop;
}
}
}
return pos;
}
function WPRO_DIF_getIframeId(win) {
var iframes = document.getElementsByTagName("IFRAME");
for (var i=0; i<iframes.length; i++) {
var o = iframes.item(i);
var w = null;
if (o.contentWindow) {
w = o.contentWindow;
} else if (window.frames && window.frames[o.id].window) {
w = window.frames[o.id];
}
if (w == win) {
WPRO_DIF_iframeWindows[o.id] = win;
WPRO_DIF_iframeObjects[o.id] = o;
return o.id;
}
}
return null;
}
function WPRO_DIF_getObjectXY(o) {
var res = new Object();
res.x=0; res.y=0;
if (o != null) {
res.x = o.style.left.substring(0,o.style.left.indexOf("px"));
res.y = o.style.top.substring(0,o.style.top.indexOf("px"));
}
return res;
}
function WPRO_DIF_getSrcElement(e) {
var tgt = e.target;
while (tgt.nodeType != 1) { tgt = tgt.parentNode; }
return tgt;
}
function WPRO_DIF_isHandleClicked(handle, objectClicked) {
if (handle==objectClicked) { return true; }
while (objectClicked.parentNode != null) {
if (objectClicked==handle) {
return true;
}
objectClicked = objectClicked.parentNode;
}
return false;
}
function WPRO_DIF_begindrag(e, win) {
var iframename = WPRO_DIF_getIframeId(win);
if (iframename==null) { return; }
if (WPRO_DIF_handles[iframename]==null || WPRO_DIF_handles[iframename].length<1) {
return;
}
var isHandle = false;
var t = e.srcElement || WPRO_DIF_getSrcElement(e);
for (var i=0; i<WPRO_DIF_handles[iframename].length; i++) {
if (WPRO_DIF_isHandleClicked(WPRO_DIF_handles[iframename][i],t)) {
isHandle=true;
break;
}
}
if (!isHandle) { return false; }
WPRO_DIF_iframeBeingDragged = iframename;
if (WPRO_DIF_raiseSelectedIframe) {
WPRO_DIF_iframeObjects[WPRO_DIF_iframeBeingDragged].style.zIndex=WPRO_DIF_highestZIndex++;
}
WPRO_DIF_dragging=true;
var pos=WPRO_DIF_getEventPosition(e);
WPRO_DIF_iframeMouseDownLeft[WPRO_DIF_iframeBeingDragged] = pos.x;
WPRO_DIF_iframeMouseDownTop[WPRO_DIF_iframeBeingDragged] = pos.y;
var o = WPRO_DIF_getObjectXY(WPRO_DIF_iframeObjects[WPRO_DIF_iframeBeingDragged]);
WPRO_DIF_pageMouseDownLeft[WPRO_DIF_iframeBeingDragged] = o.x - 0 + pos.x;
WPRO_DIF_pageMouseDownTop[WPRO_DIF_iframeBeingDragged] = o.y -0 + pos.y;
if (typeof( e.cancelBubble ) == "undefined") {
e.stopPropagation();
e.preventDefault();
} else {
e.cancelBubble = true;
e.returnValue = false;
}
}
function WPRO_DIF_enddrag(e) {
WPRO_DIF_dragging=false;
WPRO_DIF_iframeBeingDragged="";
}
function WPRO_DIF_mouseMove(e) {
if (WPRO_DIF_dragging) {
var pos = WPRO_DIF_getEventPosition(e);
WPRO_DIF_drag(pos.x - WPRO_DIF_pageMouseDownLeft[WPRO_DIF_iframeBeingDragged] , pos.y - WPRO_DIF_pageMouseDownTop[WPRO_DIF_iframeBeingDragged]);
}
}
function WPRO_DIF_iframemove(e) {
if (WPRO_DIF_dragging) {
var pos = WPRO_DIF_getEventPosition(e);
WPRO_DIF_drag(pos.x - WPRO_DIF_iframeMouseDownLeft[WPRO_DIF_iframeBeingDragged] , pos.y - WPRO_DIF_iframeMouseDownTop[WPRO_DIF_iframeBeingDragged]);
}
}
function WPRO_DIF_drag(x,y) {
var o = WPRO_DIF_getObjectXY(WPRO_DIF_iframeObjects[WPRO_DIF_iframeBeingDragged]);
var newPositionX = o.x-0+x;
var newPositionY = o.y-0+y;
if (!WPRO_DIF_allowDragOffScreen) {
if (newPositionX < 0) { newPositionX=0; }
if (newPositionY < 0) { newPositionY=0; }
}
WPRO_DIF_iframeObjects[WPRO_DIF_iframeBeingDragged].style.left = newPositionX + "px";
WPRO_DIF_iframeObjects[WPRO_DIF_iframeBeingDragged].style.top  = newPositionY + "px";
WPRO_DIF_pageMouseDownLeft[WPRO_DIF_iframeBeingDragged] += x;
WPRO_DIF_pageMouseDownTop[WPRO_DIF_iframeBeingDragged] += y;
};
if (typeof(wproAjaxRecordLoad) != 'undefined') {
	wproAjaxRecordLoad('/extensions/wysiwygpro/core/compileSharedJS.php?iframeDialogs=1&v=3.0.3.20080303');
}