//
//  iWeb - iWebSite.js
//  Copyright (c) 2007-2008 Apple Inc. All rights reserved.
//
//
//  This file includes a copy of the Prototype JavaScript framework:
//
//
//
//
// IL FAUT LE SCRIPT PROTOTYPE.JS POUR QUE CELUI CI FONCTIONNE !!!



try {if(NodeList&&NodeList.prototype&&!NodeList.prototype._each)
{Object.extend(NodeList.prototype,{_each:function(iterator){for(var i=0,length=this.length;i<length;++i)
iterator(this[i]);}});Object.extend(NodeList.prototype,Enumerable);}}
catch(exception)
{}
var windowsInternetExplorer=false;var isGecko=false;var isMozilla=false;var isFirefox=false;var isCamino=false;var isSafari=false;var isNS=false;var isWebKit=false;var isOpera=false;var isiPhone=false;var isEarlyWebKitVersion=false;var browserDetected=false;var listOfIE7FloatsFix=[];function detectBrowser()
{if(browserDetected===false)
{windowsInternetExplorer=false;var appVersion=navigator.appVersion;if((appVersion.indexOf("MSIE")!=-1)&&(appVersion.indexOf("Macintosh")==-1))
{var temp=appVersion.split("MSIE");browserVersion=parseFloat(temp[1]);windowsInternetExplorer=true;}
else
{var ua=navigator.userAgent.toLowerCase();isGecko=(ua.indexOf('gecko')!=-1);isMozilla=(this.isGecko&&ua.indexOf("gecko/")+14==ua.length);isFirefox=(this.isGecko&&ua.indexOf("firefox")!=-1);isCamino=(this.isGecko&&ua.indexOf("camino")!=-1);isSafari=(this.isGecko&&ua.indexOf("safari")!=-1);isNS=((this.isGecko)?(ua.indexOf('netscape')!=-1):((ua.indexOf('mozilla')!=-1)&&(ua.indexOf('spoofer')==-1)&&(ua.indexOf('compatible')==-1)&&(ua.indexOf('opera')==-1)&&(ua.indexOf('webtv')==-1)&&(ua.indexOf('hotjava')==-1)));isOpera=!!window.opera;var matchResult=ua.match(/applewebkit\/(\d+)/);if(matchResult)
{isiPhone=(ua.indexOf("mobile/")!=-1);isWebKit=true;webKitVersion=parseInt(matchResult[1]);isEarlyWebKitVersion=(webKitVersion<522);}}
browserDetected=true;}}
detectBrowser();function shouldApplyCSSBackgroundPNGFix()
{return(windowsInternetExplorer&&(browserVersion<7));}
function photocastHelper(url)
{var feed=new IWURL(url);var iPhotoVersionMin=600;var iPhotoMimeTypePlugin="application/photo";if(navigator.mimeTypes&&navigator.mimeTypes.length>0)
{var iPhoto=navigator.mimeTypes[iPhotoMimeTypePlugin];if(iPhoto)
{var description=iPhoto.description;try
{var components=description.split(" ");if(components&&components.length>1)
{var pluginVersion=components[1];if(pluginVersion>=iPhotoVersionMin)
{feed.mProtocol="photo";}}}
catch(exception)
{}}}
window.location=feed.toURLString();}
function loadCSS(file)
{var cssNode=document.createElement('link');cssNode.setAttribute('rel','stylesheet');cssNode.setAttribute('type','text/css');cssNode.setAttribute('href',file);document.getElementsByTagName('head')[0].appendChild(cssNode);}
function loadMozillaCSS(file)
{if(isMozilla||isFirefox||isCamino)
{loadCSS(file);}}
function utf8sequence(c)
{if(c<=0x0000007f)return[c];if(c<=0x000007ff)return[(0xc0|(c>>>6)),(0x80|(c&0x3f))];if(c<=0x0000ffff)return[(0xe0|(c>>>12)),(0x80|((c>>>6)&0x3f)),(0x80|(c&0x3f))];if(c<=0x001fffff)return[(0xf0|(c>>>18)),(0x80|((c>>>12)&0x3f)),(0x80|((c>>>6)&0x3f)),(0x80|(c&0x3f))];if(c<=0x03ffffff)return[(0xf8|(c>>>24)),(0x80|((c>>>18)&0x3f)),(0x80|((c>>>12)&0x3f)),(0x80|((c>>>6)&0x3f)),(0x80|(c&0x3f))];if(c<=0x7fffffff)return[(0xfc|(c>>>30)),(0x80|((c>>>24)&0x3f)),(0x80|((c>>>18)&0x3f)),(0x80|((c>>>12)&0x3f)),(0x80|((c>>>6)&0x3f)),(0x80|(c&0x3f))];return[];}
function utf8encode(s)
{var result=[];var firstSurrogate=0;for(var i=0;i<s.length;++i)
{var code=s.charCodeAt(i);if(firstSurrogate!=0)
{if((code>=0xDC00)&&(code<=0xDFFF))
{code=(firstSurrogate-0xD800)*0x400+(code-0xDC00)+0x10000;firstSurrogate=0;}}
else
{if((code<0xD800)||(code>0xDFFF))
{}
else if((code>=0xD800)&&(code<0xDC00))
{firstSurrogate=code;continue;}
else
{continue;}}
result=result.concat(utf8sequence(code));}
var resultString="";for(i=0;i<result.length;++i)
{resultString+=String.fromCharCode(result[i]);}
return resultString;}
function IELatin1Munge(UTF8String)
{var munged="";for(var i=0;i<UTF8String.length;i++)
{var c=UTF8String.charCodeAt(i);switch(c){case 0x0080:c=0x20AC;break;case 0x0081:break;case 0x0082:c=0x201A;break;case 0x0083:c=0x0192;break;case 0x0084:c=0x201E;break;case 0x0085:c=0x2026;break;case 0x0086:c=0x2020;break;case 0x0087:c=0x2021;break;case 0x0088:c=0x02C6;break;case 0x0089:c=0x2030;break;case 0x008A:c=0x0160;break;case 0x008B:c=0x2039;break;case 0x008C:c=0x0152;break;case 0x008D:break;case 0x008E:c=0x017D;break;case 0x008F:break;case 0x0090:break;case 0x0091:c=0x2018;break;case 0x0092:c=0x2019;break;case 0x0093:c=0x201C;break;case 0x0094:c=0x201D;break;case 0x0095:c=0x2022;break;case 0x0096:c=0x2013;break;case 0x0097:c=0x2014;break;case 0x0098:c=0x02DC;break;case 0x0099:c=0x2122;break;case 0x009A:c=0x0161;break;case 0x009B:c=0x203A;break;case 0x009C:c=0x0153;break;case 0x009D:break;case 0x009E:c=0x017E;break;case 0x009F:c=0x0178;break;}
munged+=String.fromCharCode(c);}
return munged;}
function IEConvertURLForPNGFix(urlString)
{var result=urlString;if(windowsInternetExplorer)
{var decoded=decodeURI(urlString);if(decoded.match(/[^\x00-\x7f]/))
{result=IELatin1Munge(utf8encode(decodeURI(urlString)));}}
return result;}











function fixAllIEPNGs(transparentGif)
{if(windowsInternetExplorer&&browserVersion<8)
{for(var i=0;i<document.images.length;++i)
{if(document.images[i].src.slice(-4).toLowerCase()==".png")
{var img=$(document.images[i]);var fixPng=function(img)
{if(!img.originalSrc&&!img.hasClassName("noAutoPNGFix")&&!img.hasClassName("noAutoPNGFixInTree")&&img.up(".noAutoPNGFixInTree")==undefined)
{if((img.style.width=="")&&(img.style.height==""))
{var width=img.width;var height=img.height;img.style.width=px(width);img.style.height=px(height);}
var filterName='progid:DXImageTransform.Microsoft.AlphaImageLoader';var filterParams='src="'+IEConvertURLForPNGFix(img.src)+'", sizingMethod="scale"';img.setFilter(filterName,filterParams);img.originalSrc=img.src;img.src=transparentGif;}};img.complete?fixPng(img):img.onload=fixPng.bind(null,img);}}}}




function transparentGifURL()
{(function(){return gIWUtilsTransparentGifURL!=""}).assert("Transparent image URL not set");return gIWUtilsTransparentGifURL;}
function imgMarkup(src,style,attributes,alt,forceFixupIE7)
{var markup="";if(src)
{style=style||"";attributes=attributes||"";alt=alt||"";if(windowsInternetExplorer&&((browserVersion<7)||(browserVersion<8&&forceFixupIE7!==false)))
{style+=" filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+IEConvertURLForPNGFix(src)+"', sizingMethod='scale');";src=gIWUtilsTransparentGifURL;}
if(style.length>0)
{style=' style="'+style+'"';}
if(attributes.length>0)
{attributes=' '+attributes;}
if(alt.length>0)
{alt=' alt="'+alt.stringByEscapingXML(true)+'"';}
markup='<img src="'+src+'"'+style+attributes+alt+' />';}
return markup;}
function setImgSrc(imgElement,src,forceFixupIE7)
{if(windowsInternetExplorer&&((browserVersion<7)||(browserVersion<8&&forceFixupIE7!==false))&&src.slice(-4).toLowerCase()==".png")
{$(imgElement).setFilter('progid:DXImageTransform.Microsoft.AlphaImageLoader','src="'+IEConvertURLForPNGFix(src)+'", sizingMethod="scale"');imgElement.src=gIWUtilsTransparentGifURL;}
else
{imgElement.src=src;}}
function iWOpacity(opacity)
{var style="";if(windowsInternetExplorer)
{style=" progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity*100+"); ";}
else
{style=" opacity: "+opacity+"; ";}
return style;}
var IWRange=Class.create({initialize:function(location,length)
{this.setLocation(location);this.setLength(length);},length:function()
{return this.p_length;},setLength:function(length)
{this.p_length=parseFloat(length);},location:function()
{return this.p_location;},setLocation:function(location)
{this.p_location=parseFloat(location);},max:function()
{return this.location()+this.length();},min:function()
{return this.location();},shift:function(amount)
{this.setLocation(this.location()+amount);},containsLocation:function(location)
{return((location>=this.min())&&(location<this.max()));}});var IWPageRange=Class.create(IWRange,{initialize:function($super,location,length)
{$super(location,length);},setMax:function(newMax)
{var maxLength=this.p_lengthForMax(newMax);this.setLocation(Math.max(newMax-maxLength,0))
this.setLength(newMax-this.location());},shift:function($super,amount)
{$super(amount);this.setMax(this.max());},p_lengthForMax:function(max)
{return(max<=9)?5:3;}});function px(s)
{return s.toString()+"px";}
function depx(s)
{return parseInt(s||0);}
function locationHRef()
{var result=window.location.href;if(result.match(/file:\/[^\/]/))
{result="file://"+result.substr(5);}
return result;}
function IWZeroSize()
{return new IWSize(0,0);}
var IWSize=Class.create({initialize:function(width,height)
{this.width=width;this.height=height;},scale:function(hscale,vscale,round)
{if(round===undefined)round=false;if(vscale===undefined)vscale=hscale;var scaled=new IWSize(this.width*hscale,this.height*vscale);if(round)
{scaled.width=Math.round(scaled.width);scaled.height=Math.round(scaled.height);}
return scaled;},scaleToTargetSize:function(targetSize,fitTarget)
{var scaledSize=new IWSize(this.width,this.height);if(scaledSize.width>0&&scaledSize.height>0)
{var wScale=targetSize.width/scaledSize.width;var hScale=targetSize.height/scaledSize.height;var scale=fitTarget?Math.min(wScale,hScale):Math.max(wScale,hScale);scaledSize.width*=scale;scaledSize.height*=scale;}
return scaledSize;},scaleToFit:function(sizeToFit)
{return this.scaleToTargetSize(sizeToFit,true);},round:function()
{return this.scale(1,1,true);},toString:function()
{return"Size("+this.width+", "+this.height+")";},aspectRatio:function()
{return this.width/this.height;},subtractSize:function(s)
{return new IWSize(this.width-s.width,this.height-s.height);}});function IWZeroPoint()
{return new IWPoint(0,0);}
var IWPoint=Class.create({initialize:function(x,y)
{this.x=x;this.y=y;},scale:function(hscale,vscale,round)
{if(round===undefined)round=false;if(vscale===undefined)vscale=hscale;var scaled=new IWPoint(this.x*hscale,this.y*vscale);if(round)
{scaled.x=Math.round(scaled.x);scaled.y=Math.round(scaled.y);}
return scaled;},round:function()
{return this.scale(1,1,true);},offset:function(deltaX,deltaY)
{return new IWPoint(this.x+deltaX,this.y+deltaY);},toString:function()
{return"Point("+this.x+", "+this.y+")";}});function IWZeroRect()
{return new IWRect(0,0,0,0);}
var IWRect=Class.create({initialize:function()
{if(arguments.length==1)
{this.origin=arguments[0].origin;this.size=arguments[0].size;}
else if(arguments.length==2)
{this.origin=arguments[0];this.size=arguments[1];}
else if(arguments.length==4)
{this.origin=new IWPoint(arguments[0],arguments[1]);this.size=new IWSize(arguments[2],arguments[3]);}},clone:function()
{return new IWRect(this.origin.x,this.origin.y,this.size.width,this.size.height);},toString:function()
{return"Rect("+this.origin.toString()+", "+this.size.toString()+")";},maxX:function()
{return this.origin.x+this.size.width;},maxY:function()
{return this.origin.y+this.size.height;},union:function(that)
{var minX=Math.min(this.origin.x,that.origin.x);var minY=Math.min(this.origin.y,that.origin.y);var maxX=Math.max(this.maxX(),that.maxX());var maxY=Math.max(this.maxY(),that.maxY());return new IWRect(minX,minY,maxX-minX,maxY-minY);},intersection:function(that)
{var intersectionRect;var minX=Math.max(this.origin.x,that.origin.x);var minY=Math.max(this.origin.y,that.origin.y);var maxX=Math.min(this.maxX(),that.maxX());var maxY=Math.min(this.maxY(),that.maxY());if((minX<maxX)&&(minY<maxY))
{intersectionRect=new IWRect(minX,minY,maxX-minX,maxY-minY);}
else
{intersectionRect=new IWRect(0,0,0,0);}
return intersectionRect;},scale:function(hscale,vscale,round)
{if(round===undefined)round=false;if(vscale===undefined)vscale=hscale;var scaledOrigin=this.origin.scale(hscale,vscale,round);var scaledSize=this.size.scale(hscale,vscale,round);return new IWRect(scaledOrigin.x,scaledOrigin.y,scaledSize.width,scaledSize.height);},scaleSize:function(hscale,vscale,round)
{var scaledSize=this.size.scale(hscale,vscale,round);return new IWRect(this.origin.x,this.origin.y,scaledSize.width,scaledSize.height);},round:function()
{return this.scale(1,1,true);},offset:function(deltaX,deltaY)
{var offsetOrigin=this.origin.offset(deltaX,deltaY);return new IWRect(offsetOrigin.x,offsetOrigin.y,this.size.width,this.size.height);},offsetToOrigin:function()
{return this.offset(-this.origin.x,-this.origin.y)},centerPoint:function()
{return this.offset(this.size.width/2,this.size.height/2);},position:function()
{return iWPosition(true,this.origin.x,this.origin.y,this.size.width,this.size.height);},clip:function()
{return"clip: rect("+this.origin.y+"px, "+this.maxX()+"px, "+this.maxY()+"px, "+this.origin.x+"px);";},toExtents:function()
{return new IWExtents(this.origin.x,this.origin.y,this.origin.x+this.size.width,this.origin.y+this.size.height);},paddingToRect:function(padded)
{return new IWPadding(this.origin.x-padded.origin.x,this.origin.y-padded.origin.y,padded.maxX()-this.maxX(),padded.maxY()-this.maxY());},fill:function(context)
{context.fillRect(this.origin.x,this.origin.y,this.size.width,this.size.height);},clear:function(context)
{context.clearRect(this.origin.x,this.origin.y,this.size.width,this.size.height);}});var IWExtents=Class.create({initialize:function(left,top,right,bottom)
{this.left=left;this.top=top;this.right=right;this.bottom=bottom;},clone:function()
{return new IWExtents(this.left,this.top,this.right,this.bottom);},toRect:function()
{return new IWRect(this.left,this.top,this.right-this.left,this.bottom-this.top);}});var IWPadding=Class.create({initialize:function(left,top,right,bottom)
{this.left=left;this.top=top;this.right=right;this.bottom=bottom;}});var IWNotificationCenter=Class.create({initialize:function()
{this.mDispatchTable=new Array();},addObserver:function(observer,method,name,object)
{this.p_observersForName(name).push(new Array(observer,method,object));},removeObserver:function(observer)
{},postNotification:function(notification)
{if(notification.name()!=null)
{var observersForName=this.mDispatchTable[notification.name()];this.p_postNotificationToObservers(notification,observersForName);}
var observersForNullName=this.mDispatchTable[null];this.p_postNotificationToObservers(notification,observersForNullName);},postNotificationWithInfo:function(name,object,userInfo)
{this.postNotification(new IWNotification(name,object,userInfo));},p_postNotificationToObservers:function(notification,observers)
{if(notification!=null&&observers!=null)
{for(var i=0;i<observers.length;i++)
{var observer=observers[i][0];var method=observers[i][1];var obj=observers[i][2];if(obj==null||obj===notification.object())
{method.call(observer,notification);}}}},p_observersForName:function(name)
{if(this.mDispatchTable[name]===undefined)
{this.mDispatchTable[name]=new Array();}
return this.mDispatchTable[name];}});var NotificationCenter=new IWNotificationCenter();var IWNotification=Class.create({initialize:function(name,object,userInfo)
{this.mName=name;this.mObject=object;this.mUserInfo=userInfo;},name:function()
{return this.mName;},object:function()
{return this.mObject;},userInfo:function()
{return this.mUserInfo;}});var IWAssertionsEnabled=true;function IWAssert(func,description)
{if(IWAssertionsEnabled)
{function IWAssertionFailed(func,description)
{var formatter=new RegExp("return[\t\r ]*([^};\r]*)");var assertionText=func.toString().match(formatter)[1];var message='Assertion failed: "'+assertionText+'"';if(description!=null)
message+='.  '+description;iWLog(message);}
function IWCoreAssert(func,description)
{if(func()==false)
{IWAssertionFailed(func,description);}}
IWCoreAssert(function(){return typeof(func)=='function'},"IWAssert requires its first argument to be a function.  "+"Try wrapping your assertion in function(){return ... }");var result=func();IWCoreAssert(function(){return result!=null},"The result of your assertion function is null; "+"did you remember your return statement?");IWCoreAssert(function(){return result==true||result==false},"The result of your assertion function is neither true nor false");if(result==false)
{IWAssertionFailed(func,description);}}}
Function.prototype.assert=function(description)
{IWAssert(this,description);}
function getTextFromNode(node)
{if(node.textContent)
return node.textContent;if(node.innerText)
return node.innerText;var result="";if(node.nodeType==Node.ELEMENT_NODE)
{var children=node.childNodes;for(var i=0;i<children.length;++i)
{result=result+getTextFromNode(children[i]);}}
else if(node.nodeType==Node.TEXT_NODE)
{return node.nodeValue;}
return result;}
function getChildElementsByTagNameNS(node,ns,nsPrefix,localName)
{var result=[];for(var i=0;i<node.childNodes.length;++i)
{var childNode=node.childNodes[i];if(childNode.namespaceURI)
{if(childNode.namespaceURI==ns)
{if(childNode.localName&&(childNode.localName==localName))
{result.push(childNode);}
else if(childNode.tagName==(nsPrefix+":"+localName))
{result.push(childNode);}}}
else
{if((ns=="")&&(childNode.tagName==localName))
{result.push(childNode);}}}
return result;}
function getFirstChildElementByTagNameNS(node,ns,nsPrefix,localName)
{var children=getChildElementsByTagNameNS(node,ns,nsPrefix,localName);return(children.length>0)?children[0]:null;}
function getChildElementTextByTagName(node,tagName)
{var result="";if(node!==null)
{var children=node.getElementsByTagName(tagName);if(children.length>1)
{throw"MultipleResults";}
if(children.length==1)
{result=getTextFromNode(children[0]);}}
return result;}
function getChildElementTextByTagNameNS(node,ns,nsPrefix,localName)
{var result="";if(node)
{var children=getChildElementsByTagNameNS(node,ns,nsPrefix,localName);if(children.length>1)
throw"MultipleResults";if(children.length==1)
{result=getTextFromNode(children[0]);}}
return result;}
function adjustNodeIds(node,suffix)
{var undefined;if(node.id!="")
{node.id+=("$"+suffix);}
$(node).childElements().each(function(e){adjustNodeIds(e,suffix);});}
function substituteSpans(parentNode,replacements)
{$H(replacements).each(function(pair)
{var selector="span."+pair.key;$(parentNode).select(selector).each(function(node)
{var contentType=pair.value[0];var newContent=pair.value[1];if(contentType=="text")
{node.update(newContent);}
else if(contentType=="html")
{node.innerHTML=newContent;}});});}
Element.addMethods({selectFirst:function(element,tag_name){var elements=$(element).select(tag_name);return(elements.length>0)?$(elements[0]):null;},setVisibility:function(element,visible){element=$(element);if(visible)
{element.style.display='inline';}
else
{element.style.display='none';}
return element;},ensureHasLayoutForIE:function(element)
{element=$(element);if(windowsInternetExplorer&&browserVersion<8)
{if(!element.currentStyle.hasLayout)
{element.style.zoom=1;}}},setFilter:function(element,filterName,filterParams)
{element=$(element);var regex=new RegExp(filterName+'\\([^\\)]*\\);','gi');element.style.filter=element.style.filter.replace(regex,'')+
filterName+'('+filterParams+'); ';return element;},killFilter:function(element,filterName)
{element=$(element);var regex=new RegExp(filterName+'\\([^\\)]*\\);','gi');element.style.filter=element.style.filter.replace(regex,'');return element;},cloneNodeExcludingIDs:function(element,deep)
{var clone=element.cloneNode(deep);if(deep)
{var descendantsWithID=clone.select("[id]");for(var i=0,length=descendantsWithID.length;i<length;++i){descendantsWithID[i].id="";}}
clone.id="";return clone;}});Object.extend(Array.prototype,{contains:function(value)
{return $A(this).indexOf(value)!=-1;},isEqual:function(that)
{if(this.length==that.length)
{for(var i=0;i<this.length;++i)
{if(this[i]!=that[i])
return false;}
return true;}
return false;},minusArray:function(that)
{var result=$A(this);$A(that).each(function(e){result=result.without(e);});return result;}});String.stringWithFormat=function(format)
{var formatted="";var nextArgument=1;var formatPattern=/%((\d+)\$)?([%s])?/;while(true)
{foundIndex=format.search(formatPattern);if(foundIndex==-1)
{formatted+=format;break;}
if(foundIndex>0)
{formatted+=format.substring(0,foundIndex)}
var matchInfo=format.match(formatPattern);var formatCharacter=matchInfo[3];if(formatCharacter=="%")
{formatted+="%";}
else
{if(matchInfo[2])
{argumentNumber=parseInt(matchInfo[2]);}
else
{argumentNumber=nextArgument++;}
argument=(argumentNumber<arguments.length)?arguments[argumentNumber]:"";if(formatCharacter=="s")
{formatted+=argument;}}
format=format.substring(foundIndex+matchInfo[0].length);}
return formatted;}
Object.extend(String.prototype,{lastPathComponent:function()
{return this.substr(this.lastIndexOf("/")+1);},pathExtension:function()
{var lastSeparatorIndex=this.lastIndexOf("/");var lastDotIndex=this.lastIndexOf(".");return((lastDotIndex>lastSeparatorIndex+1)&&lastDotIndex>0)?this.slice(lastDotIndex+1):this;},stringByDeletingLastPathComponent:function()
{return this.substr(0,this.lastIndexOf("/"));},stringByDeletingPathExtension:function()
{var lastSeparatorIndex=this.lastIndexOf("/");var lastDotIndex=this.lastIndexOf(".");if((lastDotIndex>lastSeparatorIndex+1)&&lastDotIndex>0)
return this.slice(0,lastDotIndex);return this;},stringByAppendingPathComponent:function(component)
{return this.endsWith("/")?(this+component):(this+"/"+component);},stringByAppendingAsQueryString:function(parameters)
{return this+'?'+$H(parameters).toQueryString();},stringByUnescapingXML:function()
{var str=this.replace(/&lt;/g,'<');str=str.replace(/&gt;/g,'>');str=str.replace(/&quot;/g,'"');str=str.replace(/&apos;/g,"'");str=str.replace(/&amp;/g,'&');return str;},stringByEscapingXML:function(escapeAdditionalCharacters)
{var str=this.replace(/&/g,'&amp;');str=str.replace(/</g,'&lt;');if(escapeAdditionalCharacters)
{str=str.replace(/>/g,'&gt;');str=str.replace(/"/g,'&quot;');str=str.replace(/'/g,'&apos;');}
return str;},stringByConvertingNewlinesToBreakTags:function()
{return this.replace(/\n\r|\n|\r/g,'<br />');},urlStringByDeletingQueryAndFragment:function()
{var result=this;var lastIndex=result.lastIndexOf("?");if(lastIndex>0)
return result.substr(0,lastIndex);lastIndex=result.lastIndexOf("#");if(lastIndex>0)
result=result.substr(0,lastIndex);return result;},toRelativeURL:function(baseURL)
{var result=this;if(baseURL&&this.indexOf(baseURL)==0)
{var chop=baseURL.length;if(this.charAt(chop)=='/')
++chop;result=this.substring(chop);}
return result;},toAbsoluteURL:function()
{var result=this;if(this.indexOf(":/")==-1)
{var pageURL=document.URL.urlStringByDeletingQueryAndFragment();var pathURL=pageURL.stringByDeletingLastPathComponent();result=pathURL.stringByAppendingPathComponent(this);}
return result;},toRebasedURL:function(baseURL)
{return this.toRelativeURL(baseURL).toAbsoluteURL();},httpURLRegExp:function()
{if(String.m_httpurlRegExp==undefined)
{var alpha="[A-Za-z]";var digit="[0-9]";var safe="[$_.+-]";var extra="[!*'(),]";var unreserved="("+alpha+"|"+digit+"|"+safe+"|"+extra+")";var hex="("+digit+"|"+"[A-Fa-f])";var escapeSeq="(%"+hex+hex+")";var uchar="("+unreserved+"|"+escapeSeq+")";var alphadigit="("+alpha+"|"+digit+")";var digits=digit+"+";var hostnumber="("+digits+"\\."+digits+"\\."+digits+"\\."+digits+")";var toplabel="(("+alpha+"("+alpha+"|"+"-)*"+alphadigit+")|"+alpha+")";var domainlabel="(("+alphadigit+"("+alphadigit+"|"+"-)*"+alphadigit+")|"+alphadigit+")";var hostname="(("+domainlabel+"\\.)*"+toplabel+")";var host="("+hostname+"|"+hostnumber+")";var port=digits;var hostport="(("+host+")(:"+port+")?)";var hsegment="((("+uchar+")|[;:@&=])*)";var search="((("+uchar+")|[;:@&=])*)";var hpath="("+hsegment+"(/"+hsegment+")*)";var httpurl="((http)|(feed)|(https))://"+hostport+"(/"+hpath+"(\\?"+search+")?)?"
String.m_httpurlRegExp=new RegExp(httpurl);}
return String.m_httpurlRegExp;},isHTTPURL:function()
{var matchResult=this.match(this.httpURLRegExp());return matchResult?(matchResult[0]==this):false;},firstHTTPURL:function()
{var matchResult=this.match(this.httpURLRegExp());return matchResult?matchResult[0]:undefined;},httpURLQueryString:function()
{var charIndex=this.indexOf("?");charIndex=((charIndex==-1)?this.indexOf("&"):charIndex);return(charIndex==-1)?"":this.slice(charIndex+1);},plaintextgsub:function(pattern,replacement)
{var value=this;while(true)
{var index=value.indexOf(pattern);if(index==-1)
break;value=value.substr(0,index)+replacement+value.substr(index+pattern.length);}
return value;}});function IWURL(urlString)
{try
{if((arguments.length==0)||(arguments.length==1&&(urlString==""||urlString==null)))
{this.p_initWithParts(null,null,null,null,null);}
else if(arguments.length==1)
{urlString.replace("file://localhost/","file:///");var urlParts=urlString.match(/^([A-Z]+):\/\/([^/]*)((\/[^?#]*)(\?([^#]*))?(#(.*))?)?/i);if(urlParts)
{this.p_initWithParts(urlParts[1],urlParts[2],urlParts[4]||"/",urlParts[6]||null,urlParts[8]||null);}
else
{urlParts=urlString.match(/^([^?#]*)(\?([^#]*))?(#(.*))?/);if(urlParts)
{this.p_initWithParts(null,null,urlParts[1],urlParts[3]||null,urlParts[5]||null);}
else
{}}}}
catch(e)
{print("Exception Parsing URL:"+e);}}
Object.extend(IWURL,{p_normalizePathComponents:function(components)
{var index=0;while(index<components.length)
{var component=components[index];if(component==""||component==".")
{components.splice(index,1);}
else if(component=="..")
{if(index>0)
{var previousComponent=components[index-1];if(previousComponent=="/")
{components.splice(index,1);}
else if(previousComponent!="..")
{components.splice(index-1,2);index-=1;}
else
{index+=1;}}
else
{index+=1;}}
else
{index+=1;}}
return components;}});Object.extend(IWURL.prototype,{p_initWithParts:function(inProtocol,inAuthority,inPath,inQuery,inFragment)
{this.mProtocol=inProtocol;this.mAuthority=inAuthority;this.mQuery=inQuery;this.mFragment=inFragment;this.mPathComponents=null;if(inPath)
{this.mPathComponents=inPath.split('/');if(this.mPathComponents[0]=="")
this.mPathComponents[0]='/';for(var i=0;i<this.mPathComponents.length;++i)
{this.mPathComponents[i]=decodeURIComponent(this.mPathComponents[i]);}
this.mPathComponents=IWURL.p_normalizePathComponents(this.mPathComponents);}},copy:function()
{var copy=new IWURL();copy.mProtocol=this.mProtocol;copy.mAuthority=this.mAuthority;copy.mQuery=this.mQuery;copy.mFragment=this.mFragment;copy.mPathComponents=null;if(this.mPathComponents)
{copy.mPathComponents=[];for(var i=0;i<this.mPathComponents.length;++i)
{copy.mPathComponents[i]=String(this.mPathComponents[i]);}}
return copy;},toString:function()
{var path="null";if(this.mPathComponents)
{path="";this.mPathComponents.each(function(component)
{if(path=="")
path="[ "+component;else
path+=", "+component;});if(path=="")
path="[]";else
path+=" ]";}
var result="{"+this.mProtocol+", "+this.mAuthority+", "+path+", "+this.mQuery+", "+this.mFragment+"}";return result;},isAbsolute:function()
{return(this.mPathComponents&&this.mPathComponents.length&&this.mPathComponents[0]=="/");},isRelative:function()
{return(this.mProtocol==null);},encodedPathComponents:function()
{var result=[];var index=0;while(index<this.mPathComponents.length)
{if((index==0)&&(this.mPathComponents[0]=="/"))
{result.push("/");}
else
{result.push(encodeURIComponent(this.mPathComponents[index]));}
index+=1;}
return result;},encodedPath:function()
{if(this.isAbsolute())
{return"/"+this.encodedPathComponents().slice(1).join("/");}
else
{return this.encodedPathComponents().join("/");}},toURLString:function()
{if(this.isRelative())
{return this.encodedPath()+
(this.mQuery?"?"+this.mQuery:"")+
(this.mFragment?"#"+this.mFragment:"");}
else
{return this.mProtocol+":"+"//"+this.mAuthority+this.encodedPath()+
(this.mQuery?"?"+this.mQuery:"")+
(this.mFragment?"#"+this.mFragment:"");}},isEqual:function(that)
{var pathMatches=true;if((this.mPathComponents)&&(that.mPathComponents)&&(this.mPathComponents.length==that.mPathComponents.length))
{for(var index=0;index<this.mPathComponents.length;++index)
{if(this.mPathComponents[index]!=that.mPathComponents[index])
{pathMatches=false;break;}}}
else
{pathMatches=false;}
return(this.mProtocol==that.mProtocol)&&(this.mAuthority==that.mAuthority)&&pathMatches&&(this.mQuery==that.mQuery)&&(this.mFragment==that.mFragment);},resolve:function(base)
{if(!this.isRelative())
return new IWURL(this.toURLString());var resolved=base.copy();resolved.mQuery=null;resolved.mFragment=null;if(resolved.mPathComponents==null)
{resolved.mPathComponents=[];}
this.mPathComponents.each(function(component)
{resolved.mPathComponents.push(component);});resolved.mPathComponents=IWURL.p_normalizePathComponents(resolved.mPathComponents);return resolved;},relativize:function(base)
{if(base&&(base.mPathComponents&&base.mPathComponents.length>0)&&(this.mProtocol==base.mProtocol)&&(this.mAuthority==base.mAuthority))
{var commonAncestorIndex=0;for(var index=0;index<Math.min(this.mPathComponents.length,base.mPathComponents.length);++index)
{if(this.mPathComponents[index]==base.mPathComponents[index])
commonAncestorIndex=index;else
break;}
var relativePath=[];for(var up=base.mPathComponents.length-1;up>commonAncestorIndex;--up)
{relativePath.push("..");}
for(var down=commonAncestorIndex+1;down<this.mPathComponents.length;++down)
{relativePath.push(this.mPathComponents[down]);}
var relativized=new IWURL();relativized.mPathComponents=IWURL.p_normalizePathComponents(relativePath);relativized.mQuery=this.mQuery;relativized.mFragment=this.mFragment;return relativized;}
else
{return this.copy();}}});