function DisplayPreviewPopup(a,imgSrc,imgWidth,imgHeight){PW.Preview(a,imgSrc,imgWidth,imgHeight);return false;}var PW={initializedPreviews:{},counter:1,seriesID:1,verticalImgWidth:324,horisontalImgWidth:500,tinyApiScripts:{},Preview:function(a,imgSrc,imgWidth,imgHeight){var id=a.id.replace("link_",""),previewId=null,key;for(key in this.initializedPreviews){if(this.initializedPreviews[key].a==a){previewId=key;break;}}if(!previewId){var imgSize=this.CalculatePreviewImageSize(imgWidth,imgHeight);previewId=id+"-"+this.counter++;this.initializedPreviews[previewId]={isDisplayed:false,width:imgSize.w,height:imgSize.h,isTitleTrimed:false,isTitleSet:false,a:a};this.ShowLoading(previewId);this.CreateNewPreviewInstance(previewId,imgSize.w,imgSize.h,imgWidth,imgHeight);this.GetTwitterLinkUrl(previewId);this.PreloadImage(imgSrc,previewId,imgSize.w,imgSize.h);this.RequestMissingData(previewId);this.BindPreviewEvents(previewId);}else{if(!document.getElementById("loading_"+previewId)){this.DisplayPreview(previewId);}this.SetPublishOptions(previewId);}this.TrackPreviewOpen();},RememberPublishOptions:function(key){var wrap=document.getElementById("pw_wrap_"+key).checked?"true":"false",wrap_dis=document.getElementById("pw_wrap_"+key).disabled?"true":"false",align=document.getElementById("pw_alignnone_"+key).checked?"none":document.getElementById("pw_alignleft_"+key).checked?"left":document.getElementById("pw_aligncenter_"+key).checked?"center":"right",size=document.getElementById("pw_size3_"+key)&&document.getElementById("pw_size3_"+key).checked?"3":document.getElementById("pw_size2_"+key)&&document.getElementById("pw_size2_"+key).checked?"2":"1",days=365;Main.CreateCookie("pub_wrp",wrap,days);Main.CreateCookie("pub_wrp_dis",wrap_dis,days);Main.CreateCookie("pub_alg",align,days);Main.CreateCookie("pub_sz",size,days);},SetPublishOptions:function(key){var align=Main.ReadCookie("pub_alg"),wrap=Main.ReadCookie("pub_wrp"),wrap_dis=Main.ReadCookie("pub_wrp_dis"),size=Main.ReadCookie("pub_sz"),input;if(align){input=document.getElementById("pw_align"+align+"_"+key);input.checked=true;document.getElementById("pw_wrap_"+key).checked=wrap=="true"?true:false;document.getElementById("pw_wrap_"+key).disabled=wrap_dis=="true"?true:false;this.SetImageAlign(input);}if(size){input=document.getElementById("pw_size"+size+"_"+key);if(input){input.checked=true;this.UpdateImageSize(input);}}},EmbedBoxFocus:function(textboxID){this.RememberPublishOptions(textboxID.replace("pw_embedcode_","").replace("pw_wordpress_",""));this.TrackImagePublish();},TrackPreviewOpen:function(){GoogleTrack("/blowout/open.html");},TrackImagePublish:function(){GoogleTrack("/blowout/publish.html");},GetTwitterLinkUrl:function(previewId){var curUrl=picAppConfig.canvasBaseLink,callBackFuncName="func"+previewId.split("-")[0]+previewId.split("-")[1],s,url,arrParam=[];arrParam.push("iid="+previewId.split("-")[0]);arrParam.push("term="+document.getElementById("txtPreviousSearch").value);curUrl+="?"+arrParam.join("&");var url="http://json-tinyurl.appspot.com?callback="+callBackFuncName+"&url="+Main.EncodeURL(curUrl);window[callBackFuncName]=new Function("url","var previewId='"+previewId+"';PW.SetTwitterLinkUrl(url, previewId)");this.tinyApiScripts[previewId]=s=document.createElement("script");s.type="text/javascript";s.src=url;(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(s);},SetTwitterLinkUrl:function(url,previewId){var bookmarkLinks;if(this.tinyApiScripts[previewId]!="undefined"){(document.getElementsByTagName("head")[0]||document.documentElement).removeChild(this.tinyApiScripts[previewId]);delete this.tinyApiScripts[previewId];window["func"+previewId.split("-")[0]+previewId.split("-")[1]]=null;}if(document.getElementById("pw_bookmark_"+previewId)&&url.ok){bookmarkLinks=document.getElementById("pw_bookmark_"+previewId).getElementsByTagName("A");for(var i=0;i<bookmarkLinks.length;i++){if(bookmarkLinks[i].className=="pwTwitterLink"){bookmarkLinks[i].href+=" "+url.tinyurl;bookmarkLinks[i].style.display="inline";break;}}}},PreviewExpandedHandler:function(id){this.initializedPreviews[id].isDisplayed=true;if(!this.initializedPreviews[id].isTitleTrimed&&this.initializedPreviews[id].isTitleSet){this.TrimTitle(id);}},PreviewClosedHandler:function(id){this.initializedPreviews[id].isDisplayed=false;},RequestMissingData:function(previewId){var term=document.getElementById("txtPreviousSearch").value,dataToSend,usemail=RG.GetUserEmail(),seriesID=this.seriesID++;$.ajax({type:"GET",url:"PicAppPreviewImage.ashx",data:"imageId="+previewId.split("-")[0]+"&term="+Main.EncodeURL(term)+"&email="+usemail,contentType:"application/json; charset=utf-8",dataType:"json",cache:true,success:function(res){if(res.success){document.getElementById("pw_desc_"+previewId).innerHTML=res.decription;document.getElementById("pw_tag_"+previewId).innerHTML=res.tags.replace(/-x22/g,"\\x22").replace(/-x27/g,"\\x27");document.getElementById("pw_embedcode_"+previewId).value=res.embedCode;document.getElementById("pw_wordpress_"+previewId).value=res.wordpress;document.getElementById("pw_title_"+previewId).innerHTML=res.title;var thumbLink=document.getElementById("pw_thumbButton_"+previewId);thumbLink.setAttribute("href",res.thumbLink);thumbLink.setAttribute("target","hiddenIframe");PW.initializedPreviews[previewId].isTitleSet=true;if(PW.initializedPreviews[previewId].isDisplayed){PW.TrimTitle(previewId);}PW.SetPublishOptions(previewId);var bookmarkLinks=document.getElementById("pw_bookmark_"+previewId).getElementsByTagName("A"),imgId=previewId.split("-")[0],targetURL,params;for(var i=0;i<bookmarkLinks.length;i++){if(bookmarkLinks[i].className!="pwTwitterLink"){targetURL=bookmarkLinks[i].href.split("?")[0];params=bookmarkLinks[i].href.replace(targetURL+"?","");bookmarkLinks[i].href=targetURL+"?"+params.replace("canvasurl",picAppConfig.canvasBaseLink).replace("imgtitle",res.title).replace("imgid",imgId);}}document.getElementById("pw_bookmark_"+previewId).style.display="block";}},error:function(request,status,errorThrown){}});$.ajax({type:"GET",url:"PicAppSearchMosaicImages.ashx",data:"term="+Main.EncodeURL(term)+"&imageId="+previewId.split("-")[0]+"&cats="+document.getElementById("txtCats").value,contentType:"application/json; charset=utf-8",dataType:"json",cache:true,success:function(res){if(res.success){document.getElementById("pw_releatedimages_"+previewId).innerHTML=res.images.replace(/<seriesID>/g,seriesID);document.getElementById("pw_releatedimages_"+previewId).className="pwRelImgPlace";Main.DisableImageRightClickAndDrag("pw_releatedimages_"+previewId);}},error:function(request,status,errorThrown){}});},ShowLoading:function(previewId){var isMosaicThumb=false,loading,loadingHeight,loadingWidth;if(previewId.split("-").length==3){imageIdComponent=previewId.split("-")[0]+"-"+previewId.split("-")[1];isMosaicThumb=true;}else{imageIdComponent=previewId.split("-")[0];}var obj=document.getElementById("loading_"+previewId);if(!obj){var targetImg=document.getElementById("img_"+imageIdComponent);loading=document.createElement("a");loading.id="loading_"+previewId;loading.href="javascript:void(0)";loading.style.opacity=0.75;loading.style.position="absolute";loading.style.zIndex=hs.zIndexCounter-1;loading.style.display="block";if(!isMosaicThumb){loading.className="highslide-loading";loading.innerHTML="Loading...";loadingWidth=77;loadingHeight=22;}else{loading.className="highslide-loading-small";loadingWidth=18;loadingHeight=18;}(document.getElementById("highslide-container")||document.getElementsByTagName("body")[0]||document.body).appendChild(loading);var thumbPos=$(targetImg).offset();var thumbHeight=$(targetImg).height();var thumbWidth=$(targetImg).width();loading.style.left=(thumbPos.left+Math.round((thumbWidth-loadingWidth)/2))+"px";loading.style.top=(thumbPos.top+Math.round((thumbHeight-loadingHeight)/2))+"px";}},PreloadImage:function(imgUrl,id,imgWidth,imgHeight){function RemoveLoading(obj){var loading=document.getElementById("loading_"+id);try{document.getElementById("highslide-container").removeChild(loading);}catch(e){try{(document.getElementsByTagName("body")[0]||document.body).removeChild(loading);}catch(e){}}}function ImagePreloader(imgUrl){var load={};load.timeOutFlag=false;load.abortedFlag=false;load.errorFlag=false;load.successFlag=false;load.onSuccess=function(){if(load.timeOutFlag||load.abortedFlag||load.errorFlag){return;}var img=document.createElement("img");img.style.width=imgWidth+"px";img.style.height=imgHeight+"px";img.src=imgUrl;img.oncontextmenu=function(){return false;};img.onmousedown=function(){return false;};img.ondrag=function(){return false;};img.onclick=function(){hs.close(document.getElementById("preview_"+id));};img.title="click to close";img.className="pwImg";document.getElementById("pw_imgplace_"+id).appendChild(img);RemoveLoading(id);PW.DisplayPreview(id);};load.onUnSuccess=function(){RemoveLoading(id);};load.onTimeout=function(){load.timeOutFlag=true;if(!load.successFlag){load.onUnSuccess();}};load.oImage=new Image;load.oImage.onload=function(){load.successFlag=true;load.onSuccess();};load.oImage.onerror=function(){load.errorFlag=true;load.onUnSuccess();};load.oImage.onabort=function(){load.abortedFlag=true;load.onUnSuccess();};load.oImage.src=imgUrl;setTimeout(load.onTimeout,10000);}var preloader=new ImagePreloader(imgUrl);},CalculatePreviewImageSize:function(imageWidth,imageHeight){var width,height;if(imageWidth>imageHeight){width=(imageWidth>this.horisontalImgWidth)?this.horisontalImgWidth:imageWidth;height=width*imageHeight/imageWidth;}else{width=(imageWidth>this.verticalImgWidth)?this.verticalImgWidth:imageWidth;height=width*imageHeight/imageWidth;}return{w:Math.round(width),h:Math.round(height)};},TrimTitle:function(id){var headerPlace=document.getElementById("pw_header_"+id),spaceAvailable=$(document.getElementById("pw_header_"+id)).width()-120,titlePlace=document.getElementById("pw_title_"+id);if(titlePlace){var fullText=titlePlace.innerHTML.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"");while($(titlePlace).width()>spaceAvailable&&fullText!=""){fullText=fullText.substr(0,fullText.lastIndexOf(" "));titlePlace.innerHTML=fullText+"...";}}this.initializedPreviews[id].isTitleTrimed=true;},SetImageAlign:function(radioObj){var id=radioObj.id.split("_")[2],embedCodeTextbox=document.getElementById("pw_embedcode_"+id),wordpressTextbox=document.getElementById("pw_wordpress_"+id),wrapCheckBox=document.getElementById("pw_wrap_"+id),marginValue="",align=radioObj.value;embedCodeTextbox.value=embedCodeTextbox.value.replace(/<div[\sa-zA-Z0-9._%+-=\";]*>/g,"").replace(/\<\/div\>/g,"");switch(align){case"left":if(wrapCheckBox.checked){marginValue="margin-right:5px;";}wordpressTextbox.value=wordpressTextbox.value.replace(/align=\"[a-zA-Z]*\"/,'align="left"');embedCodeTextbox.value='<div style="float:left;'+marginValue+'">'+embedCodeTextbox.value.replace(/<script/,"</div><script");wrapCheckBox.disabled=false;if(!wrapCheckBox.checked){embedCodeTextbox.value=embedCodeTextbox.value.replace(/<script/,'<div style="clear:left;height:0px;overflow: hidden;"></div><script');}break;case"center":wordpressTextbox.value=wordpressTextbox.value.replace(/align=\"[a-zA-Z]*\"/,'align="center"');embedCodeTextbox.value='<div style="text-align:center;">'+embedCodeTextbox.value.replace(/<script/,"</div><script");wrapCheckBox.disabled=true;break;case"right":if(wrapCheckBox.checked){marginValue="margin-left:5px;";}wordpressTextbox.value=wordpressTextbox.value.replace(/align=\"[a-zA-Z]*\"/,'align="right"');embedCodeTextbox.value='<div style="float:right;'+marginValue+'">'+embedCodeTextbox.value.replace(/<script/,"</div><script");wrapCheckBox.disabled=false;if(!wrapCheckBox.checked){embedCodeTextbox.value=embedCodeTextbox.value.replace(/<script/,'<div style="clear:right;height:0px;overflow: hidden;"></div><script');}break;default:wrapCheckBox.disabled=true;wordpressTextbox.value=wordpressTextbox.value.replace(/align=\"[a-zA-Z]*\"/,'align="none"');}if(wrapCheckBox.checked&&!wrapCheckBox.disabled){wordpressTextbox.value=wordpressTextbox.value.replace(/wrap=\"[a-zA-Z]*\"/,'wrap="true"');}else{wordpressTextbox.value=wordpressTextbox.value.replace(/wrap=\"[a-zA-Z]*\"/,'wrap="false"');}},UpdateImageSize:function(radioObj){if(!radioObj){return;}var id=radioObj.id.split("_")[2],embedCodeTextbox=document.getElementById("pw_embedcode_"+id),embedCodeWordPress=document.getElementById("pw_wordpress_"+id),sizeArray=radioObj.value.split("x");embedCodeTextbox.value=embedCodeTextbox.value.replace(/width\=\"\d*\"/,'width="'+sizeArray[0]+'"').replace(/height\=\"\d*\"/,'height="'+sizeArray[1]+'"');embedCodeWordPress.value=embedCodeWordPress.value.replace(/width\=\"\d*\"/,'width="'+sizeArray[0]+'"').replace(/height\=\"\d*\"/,'height="'+sizeArray[1]+'"');},SetImageWrapMode:function(checkboxObj){var id=checkboxObj.id.split("_")[2],embedCodeTextbox=document.getElementById("pw_embedcode_"+id),wordpressTextbox=document.getElementById("pw_wordpress_"+id);embedCodeTextbox.value=embedCodeTextbox.value.replace(/<div style=\"clear:[\sa-zA-Z0-9._%+-=\";]*><\/div>/,"");embedCodeTextbox.value=embedCodeTextbox.value.replace(/margin-(right|left):5px;/,"");if(!checkboxObj.checked){if(document.getElementById("pw_alignleft_"+id).checked){embedCodeTextbox.value=embedCodeTextbox.value.replace(/<script/,'<div style="clear:left;height:0px;overflow: hidden;"></div><script');}else{if(document.getElementById("pw_alignright_"+id).checked){embedCodeTextbox.value=embedCodeTextbox.value.replace(/<script/,'<div style="clear:right;height:0px;overflow: hidden;"></div><script');}}wordpressTextbox.value=wordpressTextbox.value.replace(/wrap=\"[a-zA-Z]*\"/,'wrap="false"');}else{if(document.getElementById("pw_alignleft_"+id).checked){embedCodeTextbox.value=embedCodeTextbox.value.replace(/float:left;/,"float:left;margin-right:5px;");}else{if(document.getElementById("pw_alignright_"+id).checked){embedCodeTextbox.value=embedCodeTextbox.value.replace(/float:right;/,"float:right;margin-left:5px;");}}wordpressTextbox.value=wordpressTextbox.value.replace(/wrap=\"[a-zA-Z]*\"/,'wrap="true"');}},BuildOptionsPanel:function(imgOriginWidth,imgOrighinHeight){var imagePublishWidths=picAppConfig.imagePublishWidths.split(","),defaultPublishWidth=imagePublishWidths[parseInt(picAppConfig.defaultPublishWidthIndex,10)],wasCheckedFlag=false,imagePushlishSizes=[],breakFlag=false,isChecked,width,height,caption,alignHtml,sizeHtml;for(var i=0;i<imagePublishWidths.length;i++){if(imgOriginWidth<parseInt(imagePublishWidths[i],10)){width=imgOriginWidth;height=imgOrighinHeight;breakFlag=true;}else{width=parseInt(imagePublishWidths[i],10);height=Math.round(imgOrighinHeight*width/imgOriginWidth);}if(defaultPublishWidth==width){wasCheckedFlag=true;isChecked='checked="checked"';}else{isChecked="";}imagePushlishSizes.push({"size":width+"x"+height,"checked":isChecked});if(breakFlag){break;}}if(!wasCheckedFlag){imagePushlishSizes[imagePushlishSizes.length-1].checked='checked="checked"';}sizeHtml='<ul class="pwSize"><li class="first">Size:</li>';for(var i=0;i<imagePushlishSizes.length;i++){sizeHtml+='<li><input type="radio"'+' id="pw_size'+(i+1)+"_<ID>"+'" value="'+imagePushlishSizes[i].size+'" '+imagePushlishSizes[i].checked+' name="pw_size_<ID>" onclick="PW.UpdateImageSize(this)"></li><li class="sizeText">'+imagePushlishSizes[i].size+"</li>";}sizeHtml+='</ul><br style="clear:left;" />';alignHtml='<ul class="pwAlignment">'+'<li class="first">Alignment:</li>'+'<li><input type="radio" name="pw_align_<ID>" onclick="PW.SetImageAlign(this)" id="pw_alignnone_<ID>" value="none" checked="checked"></li>'+'<li class="alignText">None</li>'+'<li><input type="radio" name="pw_align_<ID>" onclick="PW.SetImageAlign(this)" id="pw_alignleft_<ID>" value="left"></li>'+'<li class="alignText">Left</li>'+'<li><input type="radio" name="pw_align_<ID>" onclick="PW.SetImageAlign(this)" id="pw_aligncenter_<ID>" value="center"></li>'+'<li class="alignText">Center</li>'+'<li><input type="radio" name="pw_align_<ID>" onclick="PW.SetImageAlign(this)" id="pw_alignright_<ID>" value="right"></li>'+'<li class="alignText">Right</li>'+'<li><input onclick="PW.SetImageWrapMode(this)" type="checkbox" id="pw_wrap_<ID>" value="" disabled="disabled"></li>'+'<li class="alignText">Wrap</li>'+"</ul>";return alignHtml+sizeHtml;},CreateNewPreviewInstance:function(id,imgWidth,imgHeight,originImgWidth,originImgHeight){var pisImage;var body=document.getElementsByTagName("body")[0]||document.body,div=document.createElement("div"),popupHtml=('<div id="pw_header_<ID>" class="highslide-header">'+'<span id="pw_title_<ID>" class="title"> </span>'+"<ul>"+'<li class="highslide-move">'+'<a href="#" onclick="return false">Move</a>'+"</li>"+'<li class="highslide-close">'+'<a href="#" onclick="return hs.close(this);">Close</a>'+"</li>"+"</ul>"+"</div>"+'<div class="pwMainContArea">'+"<!-- Left Panel -->"+'<div class="pwLeft" style="width:<imgWidth>px">'+"<!-- Image Area -->"+'<div class="pwImagePlace" id="pw_imgplace_<ID>" style="width:<imgWidth>px;height:<imgHeight>px;">'+"</div>"+"<!-- /Image Area -->"+'<ul class="pwPisPreview"><li><img src="images/general/pisPreview.png" width="16" height="16" border="0" class="cursorHand" onclick="Main.ShowPisExample(\'<ID>\')"></li><li><a href="javascript:void(0)" onclick="Main.ShowPisExample(\'<ID>\')">Click to see how the image will look on your blog</a></li></ul>'+"<!-- Desc Area -->"+'<ul class="pwDescNav">'+'<li id="pw_descnav_<ID>" class="pwDescNavActive"><a href="javascript:void(0)">Description</a></li>'+'<li id="pw_tagnav_<ID>" class="pwDescNavInActive" style="margin-left:5px;"><a href="javascript:void(0)">Tags</a></li>'+"</ul>"+'<div id="pw_bookmark_<ID>" class="pwSocBookmarkArea"><a href="http://twitter.com/home?status=Check out these images" class="pwTwitterLink" style="display:none" target="_blank"><img src="images/general/twitter.png" width="16" height="16" border="0"></a>&nbsp;<a href="http://www.facebook.com/sharer.php?u=canvasurl?iid=imgid&title=imgtitle" target="_blank"><img src="images/general/facebook.png" width="16" height="16" border="0"></a>&nbsp;<a href="http://digg.com/submit?url=canvasurl?iid=imgid&title=imgtitle" target="_blank"><img src="images/general/digg.png" width="16" height="16" border="0"></a>&nbsp;<a href="http://del.icio.us/post?url=canvasurl?iid=imgid&title=imgtitle" target="_blank"><img src="images/general/delicious.png" width="16" height="16" border="0"></a></div>'+'<div id="pw_desc_<ID>" class="pwDescContActive">&nbsp;</div>'+'<div id="pw_tag_<ID>" class="pwDescContInActive">&nbsp;</div>'+"<!-- /Desc Area -->"+"</div>"+"<!-- /Left Panel -->"+'<div class="pwCenter">&nbsp;</div>'+"<!-- Right Panel -->"+'<div class="pwRight">'+'<div class="pwEmbedCodeArea">'+'<p class="pwEmbedCodeTitle">Copy and paste embed code to your blog:</p>'+'<ul class="pwBlogEmbedCodeArea"><li class="pwBlogEmbedText">Image code</li><li><input id="pw_embedcode_<ID>" onclick="javascript:this.focus();this.select();" onfocus="PW.EmbedBoxFocus(this.id);" readonly="readonly" class="pwTextBox" type="text" value=""></li></ul>'+'<br class="clear" />'+'<ul class="pwWPEmbedCodeArea"><li class="pwWPEmbedText"><span title="embed this image code only for blogs hosted on WordPress.com platform">For WordPress.com</span></li><li><input id="pw_wordpress_<ID>" onclick="javascript:this.focus();this.select();" onfocus="PW.EmbedBoxFocus(this.id);" readonly="readonly" class="pwTextBox" type="text" value=""></li></ul>'+'<br class="clear" />'+'<div class="pwThumButtonPlace"><a href="javascript:void(0)" class="pwThumbButton" id="pw_thumbButton_<ID>">download thumbnail</a></div>'+'<div id="pw_options_<ID>"><form><table border="0" cellpadding="0" cellspacing="0"><tr><td><op></td></tr></table></form></div>'+"</div>"+'<div class="pwAgreeText">By using the code or thumbnail you agree to the <a href="TermsAndCondition.aspx" target="_blank">terms</a></div>'+"<!-- Releated images area -->"+'<div class="pwRelImgTitle">more "<span><term></span>" images:</div>'+'<div id="pw_releatedimages_<ID>" class="pwRelImgDefaultPlace">'+"</div>"+"<!-- /Releated images area -->"+"</div>"+"<!-- /Right Panel -->"+'<br class="clear" />'+"</div>").replace(/<imgWidth>/g,imgWidth).replace(/<imgHeight>/,imgHeight).replace(/<op>/,this.BuildOptionsPanel(originImgWidth,originImgHeight)).replace(/<ID>/g,id).replace(/<term>/,document.getElementById("txtPreviousSearch").value||"Most Recent");div.className="highslide-html-content";div.id="preview_"+id;div.innerHTML=popupHtml;body.appendChild(div);},BindPreviewEvents:function(id){$(("#pw_tagnav_<ID>,#pw_descnav_<ID>").replace(/<ID>/g,id)).click(function(){var idkey=this.id.split("_")[2];var instanceKey=this.id.indexOf("desc")!=-1?{active:"desc",inactive:"tag"}:{active:"tag",inactive:"desc"};this.className="pwDescNavActive";document.getElementById("pw_"+instanceKey.inactive+"nav_"+idkey).className="pwDescNavInActive";document.getElementById("pw_"+instanceKey.inactive+"_"+idkey).className="pwDescContInActive";document.getElementById("pw_"+instanceKey.active+"_"+idkey).className="pwDescContActive";});},ShowHideOptionsPanel:function(e){e.stopPropagation();var idkey=this.id.split("_")[2];if(document.getElementById("pw_options_"+idkey).style.display=="none"){PW.ShowOptionsPanel(idkey);}else{PW.HideOptionsPanel(idkey);}},CheckCloseOptionsPanel:function(){for(key in this.initializedPreviews){if(this.initializedPreviews[key].isDisplayed){this.HideOptionsPanel(key);}}},ShowOptionsPanel:function(id){document.getElementById("pw_options_"+id).style.display="block";},HideOptionsPanel:function(id){document.getElementById("pw_options_"+id).style.display="none";},DisplayPreview:function(id){var popupWidth=this.initializedPreviews[id].width+360;hs.htmlExpand(this.initializedPreviews[id].a,{contentId:"preview_"+id,minWidth:popupWidth});}};var SH={CatOptionsClickHandler:function(checkbox){if(checkbox.value=="creative"){document.getElementById("searchFilterLinks").style.display="none";document.getElementById("cmbSubCategories").disabled=true;}else{var selVal=$("#cmbSubCategories").val();if(!selVal){document.getElementById("searchFilterLinks").style.display="block";}document.getElementById("cmbSubCategories").disabled=false;}},CatSelectChangeHandler:function(selVal){if(selVal){document.getElementById("searchFilterLinks").style.display="none";}else{document.getElementById("searchFilterLinks").style.display="block";}},FilterLinkClickHandler:function(filterValue){$("#cmbSubCategories").val(filterValue);document.getElementById("searchFilterLinks").style.display="none";this.PerformSearch();},GetSearchCategories:function(){var cat;if(document.getElementById("rdCreative").checked){cat="creative";}else{cat=$("#cmbSubCategories").val();}return cat;},SearchAfterStart:function(term){var searchProgress;if(term==""){term="Most Recent";}if(searchProgress=document.getElementById("searchProgress")){searchProgress.innerHTML="Now searching the world best content collections for the term  <span>"+term+"</span>";searchProgress.style.display="block";searchProgress.style.left=Math.round(($(window).width()-searchProgress.offsetWidth)/2)+"px";searchProgress.style.top=Math.round(($(window).height()-searchProgress.offsetHeight)/2)+"px";searchProgress.style.visibility="visible";}},SearchAfterEnd:function(){var searchProgress;if(searchProgress=document.getElementById("searchProgress")){searchProgress.style.visibility="hidden";searchProgress.style.display="none";}},SearchError:function(){document.getElementById("thumbPlace").innerHTML="";document.getElementById("pagContainer").innerHTML="";document.getElementById("rssPlace").innerHTML="";document.getElementById("searchResults").innerHTML="";document.getElementById("searchError").style.display="block";},PerformSearch:function(term,pageNum){if(!pageNum){pageNum="0";}if(!term){term=document.getElementById(searchTextBoxId).value;}var cats=this.GetSearchCategories();document.location.href="search.aspx?term="+Main.EncodeURL(term)+"&pageNum="+pageNum+"&cats="+cats;},PerformAjaxSearch:function(){var pageNum=document.getElementById("txtPage").value,term=document.getElementById(searchTextBoxId).value,cats=document.getElementById("txtCats").value=this.GetSearchCategories();$.ajax({type:"GET",url:"PicAppSearch.ashx",data:"term="+Main.EncodeURL(term)+"&pageNum="+pageNum+"&cats="+cats,contentType:"application/json; charset=utf-8",dataType:"json",cache:true,success:function(res){if(res.success=="0"){document.getElementById("thumbPlace").innerHTML=res.thumbs;document.getElementById("pagContainer").innerHTML=res.pagination;document.getElementById("searchResults").innerHTML=res.searchResultText;document.getElementById("rssPlace").innerHTML=res.rssLink;Main.DisableImageRightClickAndDrag("thumbPlace");}else{if(res.success=="1"){document.getElementById("thumbPlace").innerHTML="";document.getElementById("pagContainer").innerHTML="";document.getElementById("rssPlace").innerHTML="";document.getElementById("searchResults").innerHTML="";document.getElementById("noResultsFound").style.display="block";}else{if(res.success=="2"){SH.SearchError();}}}SH.SearchAfterEnd();},error:function(request,status,errorThrown){SH.SearchError();SH.SearchAfterEnd();}});this.SearchAfterStart(term);return false;}};var Main={isDomReady:false,pisWinCounter:1,prevPisWin:null,unloadedImages:[],ShowPisExample:function(key){var spacer=25,picSize=document.getElementById("pw_size3_"+key)&&document.getElementById("pw_size3_"+key).checked?document.getElementById("pw_size3_"+key).value.split("x"):document.getElementById("pw_size2_"+key)&&document.getElementById("pw_size2_"+key).checked?document.getElementById("pw_size2_"+key).value.split("x"):document.getElementById("pw_size1_"+key).value.split("x"),picWidth=parseInt(picSize[0],10),picHeight=parseInt(picSize[1],10),winTarget="piswin"+this.pisWinCounter++,winLeft=screen.availWidth?Math.round((screen.availWidth-picWidth)/2):0,winTop=screen.availHeight?Math.round((screen.availHeight-picHeight)/2):0,winWidth=picWidth+spacer,winHeight=picHeight+spacer;if(this.prevPisWin&&!this.prevPisWin.closed){this.prevPisWin.close();}this.prevPisWin=window.open("",winTarget,"top="+winTop+",left="+winLeft+",width="+winWidth+",height="+winHeight+",scrollbars=yes");document.picAppPisForm.target=winTarget;document.picAppPisForm.embedCode.value=document.getElementById("pw_embedcode_"+key).value;document.picAppPisForm.submit();},CreateCookie:function(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{var expires="";}document.cookie=name+"="+value+expires+"; path=/";},ReadCookie:function(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length);}if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}return null;},BatchThumbnailsRemove:function(){for(var i=0;i<this.unloadedImages.length;i++){this.RemoveUnloadedThumbnail(this.unloadedImages[i]);}},RemoveUnloadedThumbnail:function(imgId){var imgObj=document.getElementById(imgId),thumbContainer;if(imgId){try{thumbContainer=imgObj.parentNode.parentNode;if(thumbContainer.className=="searchThumb"||thumbContainer.className=="pwRelImg"){thumbContainer.parentNode.removeChild(thumbContainer);}}catch(e){}}},ImageLoadErrorHandler:function(imgId){if(this.isDomReady){this.RemoveUnloadedThumbnail(imgId);}else{this.unloadedImages.push(imgId);}},EncodeURL:function(url){url=encodeURI(url);url=url.replace(/\?/g,"%3F");url=url.replace(/\+/g,"%2B");url=url.replace(/&/g,"%26");url=url.replace(/#/g,"%23");url=url.replace(/=/g,"%3D");return url;},DisableImageRightClickAndDrag:function(contentPlaceId){var contentPlace=document.getElementById(contentPlaceId),imgs,im;if(contentPlace){imgs=contentPlace.getElementsByTagName("img");for(var i=0;i<imgs.length;i++){imgs[i].oncontextmenu=function(){return false;};imgs[i].onmousedown=function(){return false;};imgs[i].ondrag=function(){return false;};}}}};hs.graphicsDir="highslide/graphics/";hs.outlineType="rounded-white";hs.showCredits=false;hs.numberOfImagesToPreload=0;hs.marginLeft=10;hs.marginRight=10;hs.marginTop=10;hs.marginBottom=10;hs.allowSizeReduction=false;hs.minWidth=400;hs.minHeight=300;hs.allowWidthReduction=false;hs.allowHeightReduction=false;$(document).ready(function(){Main.isDomReady=true;document.getElementById(formName).reset();if(document.getElementById("rdEditorial").checked){document.getElementById("cmbSubCategories").disabled=false;}SH.PerformAjaxSearch();});