try{
String.prototype.Contains=function(str){return this.indexOf(str)!=-1;}
String.prototype.ToCSSSafeName=function(){return this.replace(/[^_a-zA-Z0-9-]/g,'-');}
String.prototype.StartsWith=function(str){return this.match('^'+str)==str;}
String.prototype.EndsWith=function(str){return this.match(str+'$')==str;}
String.prototype.LTrim=function(chrs){chrs=chrs||' ';return this.replace(new RegExp('^['+chrs+']+','g'),'');}
String.prototype.RTrim=function(chrs){chrs=chrs||' ';return this.replace(new RegExp('['+chrs+']+$','g'),'');}
String.prototype.Trim=function(chrs){chrs=chrs||' ';return this.LTrim(chrs).RTrim(chrs);}
String.prototype.IsNumeric=function(){return this==parseInt(this);}
String.prototype.Repeat=function(num){return new Array(num+1).join(this);}
String.prototype.Pad=function(chr,length){var newStr=this;if(newStr.length<length){newStr=chr.Repeat(length-newStr.length)+newStr;}
return newStr;}
String.prototype.StripComments=function(Open,Close){var str=this;if(Open===undefined)Open='/*';if(Close===undefined)Close='/*';var commentStartPos=str.indexOf(Open);while(commentStartPos>=0){var commentEndPos=str.indexOf(Close,commentStartPos+2)+2;str=str.substr(0,commentStartPos)+str.substr(commentEndPos);if(commentStartPos+2<str.length)commentStartPos=str.indexOf(Open,commentStartPos+2);else commentStartPos=-1;}
return str;}
String.prototype.SubStrCount=function(needle,offset,length){var haystack=this;var pos=0;var count=0;haystack+='';needle+='';if(isNaN(offset)){offset=0;}
if(isNaN(length)){length=0;}
offset--;while((offset=haystack.indexOf(needle,offset+1))!=-1){if(length>0&&(offset+needle.length)>length)return false;else count++;}
return count;}
String.prototype.URLEncodeCharacter=function(){return'%'+this.charCodeAt(0).toString(16);}
String.prototype.URLDecodeCharacter=function(){return String.fromCharCode(parseInt(this,16));}
String.prototype.URLEncode=function(){return encodeURIComponent(this).replace(/\%20/g,'+').replace(/[!'()*~]/g,URLEncodeCharacter);}
String.prototype.URLDecode=function(){return decodeURIComponent(this.replace(/\+/g,'%20')).replace(/\%([0-9a-f]{2})/g,URLDecodeCharacter);}}catch(ex){if (typeof arguments != 'undefined') alert(arguments.callee.toString() + ': ' + ex.description);}try{
var hideShadeTimeout;function makeShade(shadeID){var shade=document.createElement('div');shade.setAttribute('id',shadeID+'Shd');shade.setAttribute('class','Shade');document.body.appendChild(shade);}
function showShade(shadeID,zIndex){if(typeof zIndex=='undefined')zIndex=false;if(!document.getElementById(shadeID+'Shd'))makeShade(shadeID);if(document.getElementById(shadeID+'Shd')){clearTimeout(hideShadeTimeout);if(zIndex)document.getElementById(shadeID+'Shd').style.zIndex=zIndex;document.getElementById(shadeID+'Shd').style.visibility='visible';document.getElementById(shadeID+'Shd').style.opacity='.35';}}
function hideShade(shadeID){if(!document.getElementById(shadeID+'Shd'))makeShade(shadeID);if(document.getElementById(shadeID+'Shd')){document.getElementById(shadeID+'Shd').style.opacity='0';clearTimeout(hideShadeTimeout);hideShadeTimeout=setTimeout(function(){document.getElementById(shadeID+'Shd').style.visibility='hidden';},400);}}
function sendDialogResponse(dialogWinName,responseMethodName,cancel){var responseArrayString='';var dialogWin=document.getElementById(dialogWinName);dialogWin.style.visibility='hidden';if(!cancel){for(var i=0;i<dialogWin.children.length;i++){var kid=dialogWin.children[i];if(kid.nodeName.toUpperCase()=='INPUT'||kid.nodeName.toUpperCase()=='TEXTAREA'){var id=kid.id;var value=kid.value;responseArrayString+=id+':"'+value+'",';}}}
dialogWin.style.opacity='0';var transformProperty=GetTransformProperty(dialogWin);if(cancel){if(transformProperty)dialogWin.style[transformProperty]='rotate(-15deg) scale(.2)';dialogWin.style.marginLeft='-450px';}
else{if(transformProperty)dialogWin.style[transformProperty]='rotate(16deg) scale(.2)';dialogWin.style.marginLeft='65px';}
setTimeout(function(){dialogWin.parentNode.removeChild(dialogWin);},700);if(typeof CurrentAppID!='undefined'){try{hideShade(CurrentAppID);}
catch(x){}}
if(!cancel){if(responseArrayString)responseArrayString='{'+responseArrayString.substring(0,responseArrayString.length-1)+'}';else responseArrayString=true;try{eval('try{'+responseMethodName+'('+responseArrayString+');}catch(x){}');}
catch(x){}}
else{try{eval('try{'+responseMethodName+'(false);}catch(x){}');}
catch(x){}}}
function ForceCloseDialog(ID,Animate,HideShade){if(typeof Animate=='undefined')Animate=true;if(typeof HideShade=='undefined')HideShade=true;var dialogWin=document.getElementById(ID);if(Animate){dialogWin.style.opacity='0';var transformProperty=GetTransformProperty(dialogWin);if(transformProperty)dialogWin.style[transformProperty]='rotate(-15deg) scale(.2)';dialogWin.style.marginLeft='-450px';dialogWin.style.mozBoxShadow='2px 0 5px Black';dialogWin.style.webkitBoxShadow='2px 0 5px Black';dialogWin.style.boxShadow='2px 0 5px Black';setTimeout(function(){dialogWin.parentNode.removeChild(dialogWin);},700);}
else dialogWin.parentNode.removeChild(dialogWin);if(HideShade)hideShade(CurrentAppID);}
function ShowDialog(HTML,ResponseMethodName,Width,Height,OK,ParentIDName,FocusID,Modal,OKDisabled,Top,Animate){var focusID=typeof FocusID!='undefined'?FocusID:'';if(typeof CurrentAppID=='undefined')CurrentAppID='';if(typeof UniqueResID=='undefined'){ShowDialog.UniqueResID=0;var dialogID='u'+ShowDialog.UniqueResID;}
else{UniqueResID++;var dialogID='u'+UniqueResID;}
if(typeof Top=='undefined')Top=110;if(typeof Animate=='undefined')Animate=true;try{if(Modal!=false)showShade(CurrentAppID);}
catch(x){CurrentAppID=null;ParentIDName=null;Modal=false;}
if(OKDisabled===true)OKDisabled='disabled=disabled';else OKDisabled='';if(OK===true)OK='OK';var buttonsHTML='<div id="btns">';var cancelText='Cancel';if(OK!=false)buttonsHTML+='<input id=\''+dialogID+'-k\' class="Button" type="button" value="'+OK+'" '+OKDisabled+' onclick="sendDialogResponse(\''+dialogID+'\', \''+ResponseMethodName+'\');">';else cancelText='Close';buttonsHTML+='<input id=\''+dialogID+'-c\' class="Button" type="button" value="'+cancelText+'" onclick="sendDialogResponse(\''+dialogID+'\', \''+ResponseMethodName+'\', true);"></div>';var idealLeft=Math.ceil(Width/2)-4;var dlg=document.createElement('div');dlg.setAttribute('id',dialogID);dlg.setAttribute('class','Dialog');dlg.setAttribute('style','width:'+(Width-20)+'px;height:'+(Height-20)+'px;left:50%;top:'+Top+'px;margin-left:-'+(idealLeft+140)+'px;');dlg.innerHTML=HTML+buttonsHTML;if(ParentIDName)document.getElementById(ParentIDName).appendChild(dlg);else{if(document.getElementById('p-'+CurrentAppID))document.getElementById('p-'+CurrentAppID).appendChild(dlg);else document.body.appendChild(dlg);}
if(Animate){setTimeout(function(){dlg.style.opacity='1';var transformProperty=GetTransformProperty(dlg);if(transformProperty)dlg.style[transformProperty]='rotate(0) scale(1)';dlg.style.marginLeft='-'+idealLeft+'px';},10);setTimeout(function(){dlg.style.mozBoxShadow='2px 6px 40px Black';dlg.style.webkitBoxShadow='2px 6px 40px Black';dlg.style.boxShadow='2px 6px 40px Black';},80);}
else{var transitionProperty=GetTransitionProperty(dlg);if(transitionProperty)dlg.style[transitionProperty]='none';dlg.style.opacity='1';var transformProperty=GetTransformProperty(dlg);if(transformProperty)dlg.style[transformProperty]='rotate(0) scale(1)';dlg.style.marginLeft='-'+idealLeft+'px';dlg.style.mozBoxShadow='2px 6px 40px Black';dlg.style.webkitBoxShadow='2px 6px 40px Black';dlg.style.boxShadow='2px 6px 40px Black';if(transitionProperty)dlg.style[transitionProperty]='all .2s ease-out';}
if(ParentIDName){var keyListener=function(e){var keyPressed=(e&&e.which)?e.which:event.keyCode;var ESC_KEY=27;var ENTER_KEY=13;if(keyPressed==ESC_KEY){document.getElementById(ParentIDName).RemoveEvent('onkeydown',keyListener,false);if(ResponseMethodName)sendDialogResponse(dialogID,ResponseMethodName,true);else ForceCloseDialog(dialogID);return false;}
else if(keyPressed==ENTER_KEY){document.getElementById(ParentIDName).RemoveEvent('onkeydown',keyListener,false);if(ResponseMethodName)sendDialogResponse(dialogID,ResponseMethodName);return false;}}
document.getElementById(ParentIDName).AddEvent('onkeydown',keyListener);}
if(focusID)setTimeout("document.getElementById('"+focusID+"').focus();",1);else{if(OK!=false)setTimeout("document.getElementById('"+dialogID+"-k').focus();",1);else setTimeout("document.getElementById('"+dialogID+"-c').focus();",1);}
return dialogID;}
var loaderDialogID=null;function SendWinHashChange(){if(window.location.hash=='#c'){setTimeout(function(){if(document.getElementById('GavaIFrame'))document.getElementById('GavaIFrame').parentNode.removeChild(document.getElementById('GavaIFrame'));},440);window.location.hash='';hideShade('');}}
function showContactIFrame(){document.getElementById('GavaIFrame').style.display='block';ForceCloseDialog(loaderDialogID,false,false);document.getElementById('GavaIFrame').focus();}
function Contact(){var width=680;var height=500;var idealLeft=Math.ceil(width/2);loaderDialogID=ShowDialog('<b style="color:#3E3E3E;font-family:\'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:15px">Send Message</b><br><center style="cursor:wait;"><img src="https://gavamedia.com/w.gif" style="position:absolute;left:184px;top:130px;"><img src="https://gavamedia.com/gavalogin.jpg" style="opacity:.4;margin:15px 0 0;"></center>','',400,310,'Send',null,'',false,true,143);showShade('',1001);var loginSrc='https://gavamedia.com';if(window.location.hostname=='192.168.0.169')loginSrc='http://192.168.0.169';var dlg=document.createElement('iframe');dlg.setAttribute('id','GavaIFrame');dlg.setAttribute('style','text-align:left;display:none;border:none;width:'+width+'px;height:'+height+'px;left:50%;margin-left:-'+idealLeft+'px;position:fixed;top:110px;z-index:9000; ');dlg.onload=showContactIFrame;dlg.src=loginSrc+'/_a?r=sm&u='+encodeURI(document.URL);document.body.appendChild(dlg);if('onhashchange'in window)window.onhashchange=SendWinHashChange;else{window.onload=function(){setInterval(function(){if(CurentPageHash!=window.location.hash.substring(1))SendWinHashChange();},400);}}}}catch(ex){if (typeof arguments != 'undefined') alert(arguments.callee.toString() + ': ' + ex.description);}try{
if(XMLHttpRequest===undefined){XMLHttpRequest=function(){try{return new ActiveXObject('Msxml2.XMLHTTP.6.0');}catch(e){}
try{return new ActiveXObject('Msxml2.XMLHTTP.3.0');}catch(e){}
try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(e){}
try{return new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
window.location='http://www.getfirefox.com/';};}
function loginRequiredResponseBackup(){location.reload(true);}
function Call(FunctionID,Parameters,ReturnFunction){var ajx=new XMLHttpRequest();var params='r='+FunctionID;if(Parameters)params+='&'+Parameters;params+='&u='+Math.random();ajx.open('POST','/_a',true);ajx.setRequestHeader('Content-type','application/x-www-form-urlencoded');ajx.setRequestHeader('Content-length',params.length);ajx.setRequestHeader('Connection','close');ajx.onreadystatechange=function(){if(ajx.readyState==4){if(ajx.status==401){if(typeof window.LoginRequired=='function')LoginRequired();else{ShowDialog('<h2>Login Required</h2><br>Please login to continue.','loginRequiredResponseBackup',330,145,false);}}
else if(ajx.status==403){ShowDialog('<h2>Access Denied</h2><br>You do not have permission to perform this action.',null,330,145,false);setTimeout(function(){ReturnFunction(ajx);},400);}
else ReturnFunction(ajx);}}
ajx.send(params);}}catch(ex){if (typeof arguments != 'undefined') alert(arguments.callee.toString() + ': ' + ex.description);}try{
var DocumentWidth=Math.max(document.body.offsetWidth,document.documentElement.clientWidth,document.documentElement.offsetWidth);var DocumentHeight=Math.max(document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.offsetHeight);window.onresize=function(e){setTimeout(function(){DocumentWidth=Math.max(document.body.offsetWidth,document.documentElement.clientWidth,document.documentElement.offsetWidth);DocumentHeight=Math.max(document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.offsetHeight);},10);}
function GetTransformProperty(element){var properties=['transform','WebkitTransform','MozTransform','msTransform','OTransform'];var p;while(p=properties.shift()){if(typeof element.style[p]!='undefined')return p;}
return false;}
function GetTransitionProperty(element){var properties=['transition','MozTransition','WebkitTransition','OTransition'];var p;while(p=properties.shift()){if(typeof element.style[p]!='undefined')return p;}
return false;}}catch(ex){if (typeof arguments != 'undefined') alert(arguments.callee.toString() + ': ' + ex.description);}try{
if(oldIE===undefined)var oldIE=false;var rose=new Array(8);rose[0]=new Image();rose[1]=new Image();rose[2]=new Image();rose[3]=new Image();rose[4]=new Image();rose[5]=new Image();rose[6]=new Image();rose[7]=new Image();var currentRoseNum=0;var numOfRosePics=0;var canvas;var topPolaroid=new Image();var polaroid=new Image();var picX=83;var picY=20;var picWidth=223;var textWidth=1;var textY=0;var defaultSpeed=2.8;if(oldIE)defaultSpeed=4;var speed=defaultSpeed;var moveHandler;var topRoseName='';var bottomRoseName='';function moveDown(){var nextRoseNum=currentRoseNum+1;if(nextRoseNum>numOfRosePics-1)nextRoseNum=0;canvas.clearRect(0,0,336,310);canvas.drawImage(polaroid,picX,picY,picWidth,272);canvas.drawImage(rose[currentRoseNum],picX+14,picY+19,picWidth-25,191);if(!oldIE)drawText(roseName[currentRoseNum],picX+27+textY,picY+240,textWidth,1);canvas.drawImage(topPolaroid,86,21);canvas.drawImage(rose[nextRoseNum],86+20,40);if(!oldIE)drawText(roseName[nextRoseNum],110,260,1,1);picX=picX+speed;picY=picY+.59;picWidth+=3.4;textWidth+=0.015;textY-=0.4;speed=speed+0.04;if(picX>=95){clearInterval(moveHandler);canvas.clearRect(0,0,336,310);currentRoseNum++;if(currentRoseNum>numOfRosePics-1){requestListOfImagesToLoad();currentRoseNum=0;}
else setTimeout('moveHandler = setInterval(moveUp, 1);document.getElementById("ieName").innerHTML="";',4500);canvas.drawImage(rose[currentRoseNum],86+20,40);drawText(roseName[currentRoseNum],110,260,1,1);picX=83;picY=20;picWidth=223;speed=defaultSpeed;textWidth=1;textY=0;}}
function moveUp(){var nextRoseNum=currentRoseNum+1;if(nextRoseNum>numOfRosePics-1)nextRoseNum=0;canvas.clearRect(0,0,336,310);canvas.drawImage(rose[nextRoseNum],86+20,40);if(!oldIE)drawText(roseName[nextRoseNum],110,260,1,1);canvas.drawImage(polaroid,picX,picY,picWidth,272);canvas.drawImage(rose[currentRoseNum],picX+15,picY+19,picWidth-24,191);if(!oldIE)drawText(roseName[currentRoseNum],picX+27+textY,picY+240,textWidth,1);picX=picX-speed;picY=picY-.6;picWidth-=3.8;textWidth-=0.015;textY+=0.4;if(speed>0.5)speed=speed-0.02;else speed=0.2;if(picX<=0){clearInterval(moveHandler);moveHandler=setInterval(moveDown,5);document.getElementById('lnk').href='http://palatineroses.com/rose/'+roseURLSafeName[nextRoseNum];bottomRoseName=topRoseName;topRoseName=roseName[nextRoseNum];}}
var roseURLSafeName={};var roseName={};function getRoseURL(name){if(name)return name.replace(/-/g,'_').replace(/ /g,'-').toLowerCase();}
function getRosePolaroidURL(name){if(name)return'/roses/'+encodeURIComponent(name.replace(/ /g,'-').replace(/['"]/g,'').replace(/™/,'').replace(/®/,'')).toLowerCase()+'-rose'+'.jpg';else return false;}
var initialLinkSet=false;function gotListOfImagesToLoad(response){if(response.responseText){var list={};list=JSON.parse(response.responseText);var i=0;numOfRosePics=0;while(i<8){if(list[i]){roseName[i]=list[i].replace(/[^a-zA-Z 0-9]+/g,'');roseURLSafeName[i]=getRoseURL(list[i]);if(i!=currentRoseNum||!rose[0].src){if(i>0)setTimeout('rose['+i+'].src = getRosePolaroidURL(\''+list[i].replace(/['"]/g,'')+'\');',i*600);else rose[0].src=getRosePolaroidURL(list[0]);}
numOfRosePics++;i++;}
else break;}
topRoseName=roseName[currentRoseNum];if(!initialLinkSet){initialLinkSet=true;document.getElementById('lnk').href='http://palatineroses.com/rose/'+roseURLSafeName[currentRoseNum];}
if(numOfRosePics>1)setTimeout('clearInterval(refreshHandler); moveHandler = setInterval(moveUp, 1);document.getElementById("ieName").innerHTML="";',4500);}}
function requestListOfImagesToLoad(){try{Call('rl',null,gotListOfImagesToLoad);}
catch(x){setTimeout('requestListOfImagesToLoad();',50);}}
function initCanvas(canvs){if(window.G_vmlCanvasManager&&window.attachEvent&&!window.opera)return window.G_vmlCanvasManager.initElement(canvs);else return canvs;}
var timesTried=0;var alreadyLoaded=false;function init(){if(!alreadyLoaded){timesTried++;try{canvas=initCanvas(document.getElementById('cvs'));canvas=canvas.getContext('2d');if(oldIE){document.getElementById('ieName').className='ieNameStyle';document.getElementById('ieName').style.visibility='visible';}
alreadyLoaded=true;}
catch(ex){if(timesTried<30)setTimeout('init();',100);return;}
requestListOfImagesToLoad();refreshHandler=setInterval(refresh,3);polaroid.src='/rose_bush.png';topPolaroid.src='/blue_rose.png';}}
var refreshHandler=null;var refreshCount=0;function refresh(){try{if(!oldIE)canvas.clearRect(0,225,336,50);if(roseName[0]!==undefined)drawText(roseName[0],110,260,1,1);canvas.drawImage(rose[0],picX+23,picY+20);if(rose[0].src&&rose[0].complete)refreshCount++;if(refreshCount>40)clearInterval(refreshHandler);}
catch(x){}}
function drawText(txt,x,y,scaleX,scaleY){var roseFont='bold 39px palatine';if(txt.length>19)roseFont='bold 35px palatine';if(txt.length>21)roseFont='bold 30px palatine';if(txt.length>22)txt=txt.substring(0,22)+'...';if(!oldIE){canvas.save();canvas.fillStyle='rgba(10, 0, 0, 0.8)';canvas.font=roseFont;canvas.scale(scaleX,scaleY);canvas.fillText(txt,x-4,y+3);canvas.restore();}
else{if(roseFont=='bold 30px palatine')roseFont='bold 27px palatine';document.getElementById('ieName').innerHTML='';document.getElementById('ieName').style.font=roseFont;document.getElementById('ieName').innerHTML=txt;}}
init();}catch(ex){if (typeof arguments != 'undefined') alert(arguments.callee.toString() + ': ' + ex.description);}
