var HtmlUtility={AddResourceGetHtml:function(HtmlAndResource){HtmlAndResource=HtmlAndResource.replace(/<\/?head>/ig,'');var HtmlOnly=HtmlAndResource;var InnerRSOnly='';var TempRSBlock,ScriptOnly;var ResourceUrl,RSBody;var StartRS;var EndRS;var ids,id;while((RSBody=HtmlOnly.match(/<link.*href=("|')([^"']+)("|').*\/?>/i))!=null){HtmlUtility.AddStyleLink(RSBody[2]);HtmlOnly=HtmlOnly.replace(/<link.*href=("|')([^"']+)("|').*\/?>/i,'');};StartRS=HtmlOnly.search(/<style.*>/i);EndRS=HtmlOnly.search(/<\/style>/i);while(StartRS !=-1 && EndRS != -1){TempRSBlock=HtmlOnly.substring(StartRS,EndRS);RSBody=TempRSBlock.match(/<style.*>/i);ids=RSBody[0].match(/id=("|')([^"']+)("|')/i);if(ids != null)id=ids[2];else id="";InnerRSOnly=TempRSBlock.substring(RSBody[0].length,EndRS-StartRS).replace(/^\s+|\s+$/g,"");if(InnerRSOnly!='')HtmlUtility.AddInnerStyle(InnerRSOnly,id);HtmlOnly=HtmlOnly.substring(0,StartRS-1)+HtmlOnly.substring(EndRS+9,HtmlOnly.length);StartRS=HtmlOnly.search(/<style.*>/i);EndRS=HtmlOnly.search(/<\/style>/i);};InnerRSOnly="";StartRS=HtmlOnly.search(/<script/i);EndRS=HtmlOnly.search(/<\/script>/i);while(StartRS !=-1 && EndRS != -1){TempRSBlock=HtmlOnly.substring(StartRS,EndRS);ResourceUrl=TempRSBlock.match(/<script.*src=("|')([^"']+)("|').*>/i);RSBody=TempRSBlock.match(/<script.*>/i);ids=RSBody[0].match(/id=("|')([^"']+)("|')/i);if(ids != null)id=ids[2];else id="";if(ResourceUrl!= null)HtmlUtility.AddScriptBlock(ResourceUrl[2]);else{InnerRSOnly=TempRSBlock.substring(RSBody[0].length,EndRS-StartRS).replace(/^\s+|\s+$/g,"");if(InnerRSOnly!='')HtmlUtility.AddScriptBlock(null,new RegExp("delay=(\"|')(false)(\"|')","i").test(RSBody[0])?InnerRSOnly:"setTimeout(function(){"+InnerRSOnly+"},200)",id,new RegExp("reload=(\"|')(true)(\"|')","i").test(RSBody[0]));};HtmlOnly=HtmlOnly.substring(0,StartRS-1)+HtmlOnly.substring(EndRS+9,HtmlOnly.length);StartRS=HtmlOnly.search(/<script.*>/);EndRS=HtmlOnly.search(/<\/script>/i)};return HtmlOnly;},AddScriptBlock:function(Source,RSBody,id,Reload){var Container;var DocumentHeads=document.getElementsByTagName('Head');if(DocumentHeads.length>0)Container=DocumentHeads[0];else Container=(document.body?document.body:document.documentElement);var ScriptBlock;if(Source != null){var AvScripts=document.getElementsByTagName("script");for(var script=0;script<AvScripts.length;script++)if(AvScripts[script].src.toLowerCase().indexOf(Source.substr(Source.lastIndexOf('/')+1).toLowerCase())>-1) {if(Reload)Container.removeChild(AvScripts[script]);else return;}}else if(id!='' && id!=null){var AvScripts=document.getElementsByTagName("script");for(var i=0;i<AvScripts.length;i++)if(AvScripts[i].id==id)Container.removeChild(AvScripts[i]);};if(ScriptBlock==null)ScriptBlock=document.createElement('script');ScriptBlock.type="text/javascript";ScriptBlock.language="javascript";if(Source != null)ScriptBlock.src=(Source.substr(0,1)=="/"?RootPath:"")+Source+"?"+new Date().getTime();if(RSBody!=null){ScriptBlock.id=id;if(is_ie)ScriptBlock.text=RSBody;else if(is_safari)ScriptBlock.text=RSBody;else ScriptBlock.innerHTML=RSBody;};Container.appendChild(ScriptBlock);},AddStyleLink:function(Url){var AvStyles=document.getElementsByTagName("link");for(var style=0;style<AvStyles.length;style++)if(AvStyles[style].href.toLowerCase().indexOf(Url.substr(Url.lastIndexOf('/')+1).toLowerCase())>-1)return;var StyleLink=document.createElement('link');StyleLink.type="text/css";StyleLink.rel="stylesheet";StyleLink.href=(Url.substr(0,1)=="/"?RootPath:"")+Url;var DocumentHead=document.getElementsByTagName('Head');if(DocumentHead.length>0)DocumentHead[0].appendChild(StyleLink);else{var Body=(document.body?document.body:document.documentElement);Body.appendChild(StyleLink);};},AddInnerStyle:function(Style,id){var Container;var DocumentHeads=document.getElementsByTagName('Head');if(DocumentHeads.length>0)Container=DocumentHeads[0];else Container=(document.body?document.body:document.documentElement);var StyleBlock;if(id!='' && id!=null){var AvStyles=document.getElementsByTagName("style");for(var i=0;i<AvStyles.length;i++)if(AvStyles[i].id==id)Container.removeChild(AvStyles[i]);};var StyleBlock=document.createElement('style');StyleBlock.type="text/css";StyleBlock.id=id;if(is_ie)StyleBlock.styleSheet.cssText=Style;else if(is_safari)StyleBlock.innerText=Style;else StyleBlock.innerHTML=Style;Container.appendChild(StyleBlock);}}
