
if(jQuery){$(document).ready(function(){checkRegionAndLanguage();$("#mainmenulogin").click(function(){openLoginModal();return false;});$('HTML').addClass('JS');$("#keywordForm").submit(keywordFormSubmitted);$("#keywordSubmit").click(keywordFormSubmitted);$("#homepagek").click(function(){var keyInput=$("#homepagek");var keyText=$.trim(keyInput.val());if(keyText==keyDefaultText)
keyInput.val("");});$("form.ajaxify").live('submit',function(){return ajaxifyForm($(this),$(this).attr('onsuccess'));});$("#homekeywordForm").submit(homeKeywordSubmitted);$("#homekeywordsubmit").click(homeKeywordSubmitted);$(".sideboxtextsearch .submit").click(function(){var ctrl=$(this).prev();while(ctrl!=null&&!ctrl.is(".textbox"))
ctrl=ctrl.prev();if(ctrl==null)
return false;var param=ctrl.get(0).id;var term=ctrl.val();performKeywordSearch(param,term);return false;});$(".membersonly").live('click',membersOnlyClicked);roundCorners("");$("a.singleclick").one("click",function(){$(this).click(function(){return false;});});$(".sidebox .label a.arrow").click(function(){var refinementId=$(this).parent().parent().parent().get(0).id;var labelId=$(this).parent().parent().get(0).id;var id=labelId.replace("lbl","data");var bodyId="#"+id;var $body=$(bodyId);var collapsed=!($body.css('display')=='none');$body.toggle("slow");if($body.css('display')=='none')
$body.removeClass('refinement-collapsed');else
$body.addClass('refinement-collapsed');$(this).html(escape($(this).html())=="%u25B6"?"&#x25BE;":"&#x25B6;");updateRefinementState(refinementId,collapsed);return false;});$(".sidebox .label a.flipper").click(function(){var refinementId=$(this).parent().parent().parent().get(0).id;var labelId=$(this).parent().parent().get(0).id;var id=labelId.replace("lbl","data");var bodyId="#"+id;var $body=$(bodyId);var collapsed=!($body.css('display')=='none');$body.toggle("slow");if($body.css('display')=='none')
$body.removeClass('refinement-collapsed');else
$body.addClass('refinement-collapsed');var parent=$(this).parent();var arrow=$(":first",parent);$(arrow).html(escape($(arrow).html())=="%u25B6"?"&#x25BE;":"&#x25B6;");updateRefinementState(refinementId,collapsed);return false;});$("#sortForm").submit(function(){var selectedVal=$("#sort").val();if(selectedVal.substr(0,1)=="/"){redirectToUrl(selectedVal);return false;}
else
return true;});$("#refinementLists").sortable({opacity:0.6,update:function(event,ui){var sortOrder='';$('#refinementLists').children().each(function(index){if(sortOrder.length>0)
sortOrder+=",";sortOrder+=$(this).attr('id').replace('Refinements','');});var cookieName=refinementSortCookieName?refinementSortCookieName:"refinementsortorder";var expiryDate=new Date(2040,1,1);document.cookie=cookieName+"="+sortOrder+"; expires="+expiryDate.toGMTString()+"; path=/";}});$(".refinementlink").click(refinementLink_clicked);$(".refinementMore").click(function(){try{$(".refinementPopup").hide();var parent=$(this).parent();while(parent!=null&&!parent.is(".sidebox")){parent=parent.parent();}
if(parent==null){showErrorMsg("");return;}
var id=parent.get(0).id;var popup=getRefinementPopup(id);var container=getRefinementPopupContentContainer(id);container.css({position:"relative",top:10,left:0,width:"100%",height:"90%",overflow:"auto"});var isPopulated=container.children("ul")!=null&&container.children("ul").length!=0;repositionRefinementPopupToSidebox(parent,popup);popup.show();var endPosition=getRefinementPopupEndPosition(popup);if(!isPopulated){loadRefinementList($(this),container,popup,parent);}
animateRefinementPopup(popup,endPosition.top,endPosition.width,endPosition.height,'slow');}catch(err){showErrorMsg("");}
return false;});$("#frmForward").submit(submitForwardItems);String.prototype.startsWith=function(str){return(this.match("^"+str)==str);}
expandCollapseRefinements();});}
function supports_html5_storage(){return('localStorage'in window)&&window['localStorage']!==null;}
function store(key,val){if(supports_html5_storage())
localStorage[key]=val.toString();}
function retrieve(key){if(!supports_html5_storage())
return null;return localStorage[key];}
function updateRefinementState(id,collapsed){if(industryId==null||id==null||id.length==0)
return;var key=id+"-"+industryId.toString();store(key,collapsed);}
function expandCollapseRefinements(){if(!supports_html5_storage()){return;}
if(typeof industryId!='undefined'&&industryId==null)
return;$('#refinementLists').children().each(function(index,value){var id=$(this).attr('id');var val=retrieve(id+"-"+industryId.toString());if(val!=null){if(val=="true"||val==true){var obj=$('#'+id+' a.flipper');if(obj!=null)
obj.click();}}});}
function roundCorners(selector){var cornerStyle="";if(!$.browser.msie)
cornerStyle="keep";if(selector.length!=0&&selector.substr(selector.length-1,1)!=" ")
selector+=" ";$(selector+".round").corner(cornerStyle);$(selector+".roundtop").corner("top "+cornerStyle);$(selector+".roundbottom").corner("bottom "+cornerStyle);$(selector+".roundleft").corner("left "+cornerStyle);$(selector+".roundright").corner("right "+cornerStyle);$(selector+".roundbottomleft").corner("bl "+cornerStyle);if(!$.browser.msie){$(selector+".button").corner("keep");}}
function ajaxifyForm(form,onsuccessMethod)
{$.ajax({type:"POST",url:$(form).attr("action"),dataType:"json",data:$(form).serialize(),success:function(data,status,xhr)
{if(typeof onsuccessMethod!='undefined'&&onsuccessMethod!=null)
eval(onsuccessMethod);$(form).trigger('ajax:success',[data,status,xhr]);},error:function(xhr,status,error)
{$(form).trigger("ajax:failure",[xhr,status,error]);var customMessage="";try{if(showErrorDetail)
customMessage=error;}
catch(err){customMessage="";}
showErrorMsg(customMessage);},complete:function(xhr){$(form).trigger("ajax:complete",xhr);}});return false;}
function keywordFormSubmitted()
{var keyword=$("#keyword").val();if(keyDefaultText!=null&&keyDefaultText==keyword)
return;performKeywordSearch("k",keyword);return false;}
function homeKeywordSubmitted()
{performHomeKeywordSearch($("#homepagek").val());return false;}
jQuery.fn.preventDoubleSubmit=function()
{jQuery(this).submit(function(){if(this.beenSubmitted)
return false;else
this.beenSubmitted=true;});};function getRefinementPopup(sideboxId)
{return($("#"+sideboxId+"Popup"));}
function getSideboxFromPopupId(popupId)
{return($("#"+popupId.replace("Popup","")));}
function getRefinementPopupContentContainer(sideboxId)
{return($("#"+sideboxId+"PopupContent"));}
function repositionRefinementPopupToSidebox(sidebox,popup)
{var sideboxPos=sidebox.position();popup.css({position:"absolute",top:sideboxPos.top,left:sideboxPos.left});resizeRefinementPopup(popup,sidebox.width(),sidebox.height());}
function resizeRefinementPopup(popup,width,height)
{popup.css({width:width,height:height});}
function closeRefinementPopup(popupId)
{var popup=$('#'+popupId);var sidebox=getSideboxFromPopupId(popupId);animateRefinementPopup(popup,sidebox.position().top,sidebox.width(),sidebox.height(),"slow",function(){popup.hide()});}
function getRefinementPopupEndPosition(popup)
{var endTop;var endWidth;var endHeight;var relativeTop=$(window).scrollTop();var middle=$(window).height()/2+relativeTop;var currentTop=(popup.position().top);endTop=currentTop;endWidth=400;endHeight=400;if(currentTop>middle){endTop=(currentTop+popup.height())-endHeight;}else{}
return({top:endTop,width:endWidth,height:endHeight});}
function animateRefinementPopup(popup,endTop,endWidth,endHeight,speed,callback)
{var step=20;var top=popup.position().top;var width=popup.width();var height=popup.height();var topAnimationEnabled=(top!=endTop);var widthAnimationEnabled=(width!=endWidth);var heightAnimationEnabled=(height!=endHeight);var maxframes=(Math.abs(endTop-top)/step);if((Math.abs(endHeight-height)/step)>maxframes)
maxframes=(Math.abs(endHeight-height)/step);if((Math.abs(endWidth-width)/step)>maxframes)
maxframes=(Math.abs(endWidth-width)/step);if(isNaN(speed)){if(speed=="fast")
speed=200;else
speed=600;}
var animTime=speed/maxframes;var timers=[];for(var i=0;i<maxframes;i++){timers[i]=window.setTimeout(function(){if(topAnimationEnabled){if(top<endTop){if((top+step)>endTop)
top=endTop;else
top+=step;}else{if((top-step)<endTop)
top=endTop;else
top-=step;}}
if(widthAnimationEnabled){if(width<endWidth){if((width+step)>endWidth)
width=endWidth;else
width+=step;}else{if((width-step)<endWidth)
width=endWidth;else
width-=step;}}
if(heightAnimationEnabled){if(height<endHeight){if((height+step)>endHeight)
height=endHeight;else
height+=step;}else{if((height-step)<endHeight)
height=endHeight;else
height-=step;}}
if(top==endTop)
topAnimationEnabled=false;if(width==endWidth)
widthAnimationEnabled=false;if(height==endHeight)
heightAnimationEnabled=false;popup.css({top:top,width:width,height:height});if(!topAnimationEnabled&&!widthAnimationEnabled&&!heightAnimationEnabled){if(callback!=null)
callback();}},animTime*(i+1));}}
function registerRefinementPopupExpandEvent(listId)
{$("#"+listId+" li .showChildren").click(function()
{try{var parent=$(this).parent();if(!parent.is("li")){showErrorMsg("");return;}
var popup=parent.parent();while(popup!=null&&!popup.is(".refinementPopup")){popup=popup.parent();}
if(popup==null){showErrorMsg("");return;}
var popupId=popup.get(0).id;var content=$('#'+popupId+'Content');var list=parent.children("ul");var img=$(this).children(0);if($(img).attr("src")==minusImageUrl){list.hide();$(img).attr("src",plusImageUrl);}
else{var isPopulated=list.length!=0;if(!isPopulated)
loadRefinementList($(this),parent,popup);else
list.show();$(img).attr("src",minusImageUrl);}}
catch(err){showErrorMsg("");}
return false;});}
function loadRefinementList(sourceElement,container,baseContainer,parent)
{var loadingMsg=$("#refinementsLoadingMsg");var textOffset=$(sourceElement).offset();loadingMsg.css({top:textOffset.top-5,left:textOffset.left});loadingMsg.show();var href=sourceElement.attr("href");var isGreen=false;if(parent!=null)
isGreen=parent.hasClass('ecotech');$.ajax({type:"GET",url:href,dataType:"json",success:function(data){var newListId=sourceElement.get(0).id+"_list";var listHtml="<ul id='"+newListId+"'>";$.each(data,function(i,item){var itemHtml="<a class='refinementlink' href='"+item.Url+"'>"+item.Text+" ("+item.Count+")"+"</a>";if(isGreen){var whoisthis="Who is this?";if(whoisthisphrase!=null&&whoisthisphrase.length>0)
whoisthis=whoisthisphrase;if(item.CategoryUrl!=null&&item.CategoryUrl.length>0)
itemHtml="<a href='"+item.CategoryUrl+"' title='"+whoisthis+"' target='_blank'><img style='width:17px;' src='"+greenImageUrl+"' /></a>&nbsp;"+itemHtml;else
itemHtml="<span style='width:24px;'>&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;"+itemHtml;}else{if(item.ChildrenUrl!=null&&item.ChildrenUrl!="")
itemHtml="<a id='"+newListId+"_"+i+"' class='showChildren' href='"+item.ChildrenUrl+"'><img alt='+' src='"+plusImageUrl+"' /></a>&nbsp;"+itemHtml;else
itemHtml="<span class='bullet'>&#8226;</span>"+itemHtml;}
listHtml=listHtml+"<li>"+itemHtml+"</li>";});container.append(listHtml+"</ul>");registerRefinementPopupExpandEvent(newListId);$("#"+newListId+" .refinementlink").click(refinementLink_clicked);loadingMsg.hide();},error:function(e,xhr){var customMessage="";try{if(showErrorDetail)
customMessage=xhr;}
catch(err){customMessage="";}
loadingMsg.hide();baseContainer.hide();showErrorMsg(customMessage);}});}
function performHomeKeywordSearch(term)
{term=$.trim(term);if(term==""||term==keyDefaultText){return;}
encode=encodeURIComponent||escape;term=encode(term);term=term.replace("%20","+");var selectPopup=$("#keywordIndustrySelect");var list=selectPopup.children("ul");if(list.children("li").length==0){var textOffset=$("#homepagek").offset();selectPopup.css({top:textOffset.top-75,left:textOffset.left});}
else
list.html("");$.each($("#industrylist a"),function(i,item)
{var href=$(this).attr("href")+"/search?k="+term;list.append("<li><a href='"+href+"'>"+$(this).text()+"</a></li>");});selectPopup.show();}
function performKeywordSearch(param,term){var newUrl;var searchWithin=true;if(searchWithin)
newUrl=textSearchBaseUrl;else
newUrl=newTextSearchBaseUrl;term=$.trim(term);if(term==""){showErrorMsg("Please enter a search term");return;}
encode=encodeURIComponent||escape;term=encode(term);term=term.replace(/ /g,"+").replace("%20","+");var reg=$("#searchRegion");if(reg==null)
return;var newUrl=newUrl.replace("{region}",reg.val());var cyb=$("#searchCybrary");if(cyb==null)
return;newUrl=newUrl.replace("{cybrary}",cyb.val());newUrl=addQuerystringParam(newUrl,param,term,false);if(typeof searchOrder!='undefined'&&searchWithin)
newUrl=newUrl+"&so="+searchOrder;if(typeof parentSearchLogId!='undefined'&&searchWithin)
newUrl=newUrl+"&sl="+parentSearchLogId;redirectToUrl(newUrl);}
function refinementLink_clicked()
{if(typeof searchOrder=='undefined'){return true;}
else{if(this.href.startsWith("javascript:")){return true;}
var url=addQuerystringParam(this.href,"so",searchOrder,true);if(typeof parentSearchLogId!='undefined')
url=addQuerystringParam(url,"sl",parentSearchLogId,true);redirectToUrl(url);return false;}}
function addQuerystringParam(url,param,value,replaceValueIfParamExists)
{if(url.charAt(url.length-1)=="#")
url=url.substr(0,url.length-1);if(url.indexOf("?")==-1)
url=url+"?"+param+"="+value;else{var paramIndex=url.indexOf(param+"=");if(paramIndex==-1)
url=url+"&"+param+"="+value;else{if(replaceValueIfParamExists)
{var valBeginIndex=url.indexOf("=",paramIndex+1)+1;var valEndIndex=url.indexOf("&",paramIndex+1);if(valEndIndex==-1)
url=url.substr(0,valBeginIndex)+value;else
url=url.substr(0,valBeginIndex)+value+url.substr(valEndIndex);}
else
{var sepIndex=url.indexOf("&",paramIndex+1);if(sepIndex==-1)
url=url+"|"+value;else
url=url.substr(0,sepIndex)+"|"+value+url.substr(sepIndex);}}}
return url;}
function showErrorMsg(customMessage){var message;if(customMessage!=null&&customMessage!="")
message=customMessage;else
message="Sorry...An error occurred";openErrorModal(message);}
function ChangeDomain(prefix){var d=$("#selectDomain").get(0);var s=d.options[d.selectedIndex].value;redirectToUrl("http://"+prefix+"."+s);}
function loadPlayer(fil,id,player,width,height){var flashvars={file:fil,id:id,autostart:'true'};var params={align:'middle',play:'true',wmode:'transparent',allowFullScreen:'true'};var attributes={id:id,name:"name"};swfobject.embedSWF(player,"media_region",width,height,"9.0.0",null,flashvars,params,attributes);}
function trackPage(url)
{try{if(typeof(pageTracker)!='undefined'&&pageTracker!=null){if(typeof(setAnalyticsVariables)!='undefined'&&setAnalyticsVariables!=null)
setAnalyticsVariables();pageTracker._trackPageview(url);}}catch(err){}}
function openSpotlightModal(url){var h=$(window).height();h=(h<500)?500:h-100;openModal(url,h,900,"#CCC");}
function openDetailModal(url){var h=$(window).height();h=(h<500)?500:h-100;var callback=null;if(typeof detailContentLoad!=null)
callback=detailContentLoad;openModal(url,h,900,"#CCC",callback);}
function openErrorModal(message)
{var element=$('#modal_error');var content=$('#modal_error_content');element.width(800);element.height(500);content.html(message);closeModal();openElementAsModal(element,450,750,'#ccc');}
function openRestrictedResultModal(element,bookshelfId)
{if(bookshelfId!=null){var cbx=$('#bookshelf_'+bookshelfId);if(cbx!=null)
cbx.attr('checked','checked');}
element.width(800);element.height(500);openElementAsModal(element,500,800,'#ccc');}
function openElementAsModal(element,height,width,backgroundColor)
{element.modal({minHeight:height,minWidth:width,overlay:80,overlayCss:{backgroundColor:backgroundColor}});}
var lastModalProps=null;function openModal(url,height,width,backgroundColor,callbackFunction){if(typeof(callbackFunction)=='undefined'||callbackFunction==null)
callbackFunction=openModalCallback;if(($.browser.msie)&&($.browser.version=="7.0")||($.browser.version=="6.0"))
{document.documentElement.style.overflow="hidden";}
else
{document.body.style.overflow="hidden";}
lastModalProps=new Object();lastModalProps.url=url;lastModalProps.height=height;lastModalProps.width=width;lastModalProps.backgroundColor=backgroundColor;lastModalProps.callbackFunction=callbackFunction;$("#modal_placeholder").load(url,null,callbackFunction).modal({minHeight:height,minWidth:width,overlay:80,overlayCss:{backgroundColor:backgroundColor}});trackPage(url);}
function isModalOpen()
{return $("#"+$.modal.defaults.overlayId).html()!=null}
function closeModal()
{if(($.browser.msie)&&($.browser.version=="7.0")||($.browser.version=="6.0"))
{document.documentElement.style.overflow='';}
else{document.body.style.overflow='';}
lastModalProps=null;$.modal.close();}
function restoreModal(modalProps)
{closeModal();openModal(modalProps.url,modalProps.height,modalProps.width,modalProps.backgroundColor,modalProps.callbackFunction);}
function openModalCallback(responseText,textStatus,XMLHttpRequest)
{if(textStatus=="error"){closeModal();showErrorMsg("Error occurred. Please try again");}
else
{$("#modal_placeholder .membersonly").click(membersOnlyClicked);}}
function openLocaleModal()
{var localeUrl="/locale?time"+new Date().getTime().toString();openModal(localeUrl,610,900,"#CCC",function()
{if(cookieRegionId!=null&&cookieRegionId.length>0&&cookieLanguageId!=null&&cookieLanguageId.length>0&&cookieRegionCode!=null&&cookieRegionCode.length>0){$('#inner-'+cookieRegionCode).css("display","block");$('#selectlang'+cookieRegionId+'-'+cookieLanguageId).css("background-color","#999");}});}
function membersOnlyClicked()
{var targetUrl="";var href=$(this).attr("href");if(typeof(href)!='undefined'&&href.length!=0)
{if(href=="#"||href==window.location.href+"#")
targetUrl=window.location.href;else
targetUrl=href;}
openLoginModal(targetUrl);return false;}
var loginRedirectUrl;var loginModalRestoreProps;function openLoginModal(targetUrl)
{if(isModalOpen())
loginModalRestoreProps=lastModalProps;else
loginModalRestoreProps=null;if(languageCode.length==0)
languageCode='en';var loginUrl=addQuerystringParam("/session/new","version",versionStr);loginUrl=addQuerystringParam(loginUrl,"lang",languageCode);if(typeof(targetUrl)!='undefined'&&targetUrl.length!=0)
loginRedirectUrl=targetUrl;else
loginRedirectUrl="/";closeModal();openModal(loginUrl,330,750,"#CCC",openLoginCallback);}
function openLoginCallback(responseText,textStatus,XMLHttpRequest)
{if(textStatus=="error"){showErrorMsg(responseText);closeModal();}
else{initLogin();}}
var loginInProgress=false;function handleLoginPopupSubmit()
{var form=$("#loginform");$("#loginErrText").html("<img src='"+loadingImgPath+"' />");loginInProgress=true;$.ajax({type:"POST",url:$(form).attr("action"),dataType:"json",data:$(form).serialize(),success:function(data)
{loginInProgress=false;if(data==null||typeof(data.resultCode)=='undefined'||data.resultCode==null)
{$("#loginErrText").html("");showErrorMsg("Unexpected error occurred. Please try again.");closeModal();return;}
if(data.resultCode==0)
{if(data.url==null||data.url.length==0)
{if(loginRedirectUrl==null)
loginRedirectUrl="/";}
else
loginRedirectUrl=data.url;redirectToUrl(loginRedirectUrl);}
else if(data.resultCode==2)
redirectToUrl(data.url);else
$("#loginErrText").html(data.errMsg);},error:function(e,xhr)
{loginInProgress=false;$("#loginErrText").html("");var customMessage="";try{if(showErrorDetail)
customMessage=xhr;}
catch(err){customMessage="Unknown Login Error.";}
showErrorMsg(customMessage);}});return false;}
function closeLoginModal()
{if(loginModalRestoreProps==null)
closeModal();else
{restoreModal(loginModalRestoreProps);loginModalRestoreProps=null;}}
function openNewWindow(anchor)
{openUrlInNewWindow(anchor.href);}
function openUrlInNewWindow(url)
{window.open(url,"Innovadex");}
function postBookmark(bookmarkUrl,bookId,bookShelfId,searchTypeId){if(searchTypeId==='undefined'||searchTypeId==null)
searchTypeId=null;$.ajax({type:"POST",url:bookmarkUrl,data:{bookId:bookId,BookshelfId:bookShelfId,searchTypeId:searchTypeId},beforeSend:function(msg)
{div_swap("bookmarkOff","bookmarkOn");},success:function(msg)
{clearContainer('mybookmarklist');},error:function(msg,textStatus,errorThrown)
{div_swap("bookmarkOn","bookmarkOff");showErrorMsg(textStatus+" "+errorThrown);}});}
function postBookmarkFromResults(linkId,bookmarkUrl,bookId,bookShelfId,phraseText,searchTypeId){if(searchTypeId==='undefined'||searchTypeId==null)
searchTypeId=null;$.ajax({type:"POST",url:bookmarkUrl,data:{bookId:bookId,BookshelfId:bookShelfId,searchTypeId:searchTypeId},beforeSend:function(msg){},success:function(msg){if(linkId&&$('#'+linkId)){$('#'+linkId).html(phraseText);$('#'+linkId).removeAttr('href').attr('onclick','return (false);');}
$('#menubookmarks').html(msg);},error:function(msg,textStatus,errorThrown){showErrorMsg(textStatus+" "+errorThrown);}});}
function ajaxRequest(url,type,data,onSuccess,onError,dataType)
{if(dataType==null)
dataType="json";$.ajax({type:type,url:url,dataType:dataType,data:data,success:onSuccess,error:onError});}
function postSampleCart(linkid,url,bookshelfId,bookId,searchTypeId,sampleAddedPhrase,callback)
{var data={bookshelfId:bookshelfId,bookId:bookId,searchTypeId:searchTypeId};$.post(url,data,function(result)
{if(result.toString().length==0)
showErrorMsg("Unknown error occurred. Please try again.");else
{if(linkid!=null&&linkid.length>0&&$('#'+linkid)!=null){$('#'+linkid).html(sampleAddedPhrase);$('#'+linkid).removeAttr('href').attr('onclick','return (false);');var textLinkId=linkid.replace("sample_link","sample_text_link");if($('#'+textLinkId)!=null)
$('#'+textLinkId).html("");}
if($('#samplecartitemcount'))
$('#samplecartitemcount').html(result.toString());if(callback!=null&&typeof(callback)=='function')
callback(result);}},"text");}
function div_swap(show_div,hide_div){$('#'+show_div).css("display","block");$('#'+hide_div).css("display","none");}
function checkRegionAndLanguage(url){if(typeof localeCookieName!='undefined'){var regionLanguageCookie=getCookie(localeCookieName);if(regionLanguageCookie==""){openLocaleModal();}
else{}}}
function getCookie(c_name){if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;{return unescape(document.cookie.substring(c_start,c_end));}}}
return"";}
function selectLanguage(languageId,regionId){$.ajax({type:"POST",url:"/locale/Update",data:"LanguageId="+languageId+"&RegionId="+regionId+"&url="+window.location,beforeSend:function(msg){},success:function(msg){if((performJavascriptLocaleRedirect==true)&&(msg!="")){redirectToUrl(msg);}
else{closeModal();}},error:function(msg,textStatus,errorThrown){showErrorMsg(textStatus+" "+errorThrown);}});}
function validateEmail(url,email,onSuccess,onError)
{ajaxRequest(url,'get',{email:email,time:new Date().getTime()},onSuccess,onError);}
function load_detail(detail_url){$.ajax({type:"GET",url:detail_url,success:function(response){$('#simplemodal-container').html(response);}});}
function showPopup(sourceId,popupId,offsetX,offsetY)
{if(offsetX==null)
offsetX=0;if(offsetY==null)
offsetY=0;var sourceId='#'+sourceId;var popupId='#'+popupId;var pos=$(sourceId).offset();var width=$(sourceId).width();$(popupId).css({"left":(pos.left+width+offsetX)+"px","top":pos.top+offsetY+"px"});$(popupId).show('slow').bgiframe();}
function showPopupAt(sourceId,popupId,location)
{var offsetX=0;var offsetY=0;var elementSourceId='#'+sourceId;var elementPopupId='#'+popupId;if(location=="bottomleft"){offsetY=$(elementSourceId).height();offsetX=$(elementSourceId).width()*(-1);}
if(location=="bottomright"){offsetX=$(elementPopupId).outerWidth()*(-1)+15;offsetY=$(elementSourceId).height();}
showPopup(sourceId,popupId,offsetX,offsetY);}
function showPopupCentered(popupId)
{popupId="#"+popupId;var x=($(window).width()/2)-($(popupId).width()/2);var y=($(window).height()/2)-($(popupId).height()/2);$(popupId).css({"left":x+"px","top":y+"px"});$(popupId).show();}
function hidePopup(popupId)
{var popupId='#'+popupId;$(popupId).hide('slow');}
function showSaveSearchPopup(isAlert){var checked=isAlert?"checked":"";$("#isAlert").attr("checked",checked);showPopup('savesearch','savesearchpopup',-220,10);}
function showForwardBookPopup(){$("#forwardemailrequired").hide();var checked=$(".recordselector").filter(":checked");if(checked.length==0){if(typeof handleNoSelectedFormwardItems!='undefined'&&handleNoSelectedFormwardItems!=null)
handleNoSelectedFormwardItems();else
showErrorMsg("At least 1 record must be selected");}
else{var selectedStr="";checked.each(function(){if(selectedStr.length!=0)
selectedStr+="|";selectedStr=selectedStr+$(this).attr("id").substring(4);});$("#forwardbooklist").val(selectedStr);showPopup("forwardBook","forwardbookspopup",-400,5);}}
function elementHasEventAttached(element,eventName){var data=element.data('events');if(data!=null)
return data[eventName]!=null;else
return false;}
function loadStateProvinceValues(countryId)
{if(countryId!=null&&countryId!="")
{ajaxRequest('/stateprovince/list','get',{countryId:countryId,time:new Date().getTime()},function(result){$("#StateProvince").autocomplete("destroy");if(result!=null&&result.length>0){$("#StateProvince").autocomplete({data:result,formatItem:function(item){return(item.Name);},mustMatch:true});}},function(){alert("error");});}}
function showNotification(message,time,selector){if(typeof selector=='undefined'||selector==null)
selector="#page-notifications";$(selector).show(0,function(){$(selector+' span').html(message).show(0,function(){window.setTimeout(function(){$(selector+' span').hide(100,function(){$(selector).hide(25);});},time);});});}
function saveSearch(regionId,cybraryId,name,searchString,searchTypeId)
{if(name.length<1||name.length>50)
return(false);var isAlert=$("#isAlert").is(':checked');$.ajax({type:"POST",url:'/savedsearches',data:{regionId:regionId,cybraryId:cybraryId,name:name,searchString:searchString,isAlert:isAlert,searchTypeId:searchTypeId},success:function(response){clearContainer('mysearcheslist');hidePopup('savesearchpopup');$('#savedsearch_saving').hide();if(savedSearchSuccess==null||savedSearchSuccess.length==0)
savedSearchSuccess='Successfully saved your search';showNotification(savedSearchSuccess,4000);},error:function(msg,textStatus,errorThrown){showErrorMsg(msg+" "+textStatus);}});return(true);}
function changeSearchResultStyle(newStyleId)
{var currentUrl=window.location+"";redirectToUrl(addQuerystringParam(currentUrl,"srsid",newStyleId,true));return false;}
function redirectToUrl(url)
{window.location=url;}
function loadBookmarks(url,containerId)
{var container=$('#'+containerId);if(container.children().length>0)
return;ajaxRequest(url,'GET',null,function(response)
{container.append(response);},function(response)
{},'html');}
function loadSearches(url,containerId)
{var container=$('#'+containerId);if(container.children().length>0)
return;ajaxRequest(url,'GET',null,function(response)
{container.append(response);},function(response)
{},'html');}
function clearContainer(containerId)
{var container=$('#'+containerId);container.html('');}
function refreshWindow()
{window.location.reload(true);}
var stopwords=[];function isStopWord(word){for(var i=0;i<stopwords.length;i++)
if(stopwords[i]==word)
return(true);return(false);}
function iwSearch(){if(gcse!=null&&iwKeywords!=null&&iwKeywords.length>0&&!isStopWord(iwKeywords))
gcse.search(iwKeywords);}
function iwNextPage(){if(gcse!=null&&gcse.hasSearched())
gcse.nextPage();}
function ShowWebResults(inmodal){if(iwKeywords==null)
return;if(isStopWord(iwKeywords))
return;if(inmodal){showModalWebResults();}else{if(gcse==null)
return;var searchOptionsBar=$('#search-results-options');if(searchOptionsBar!=null)
searchOptionsBar.hide();var restrictionMessage=$('#restrictedresultmessage');if(restrictionMessage!=null)
restrictionMessage.hide();if(resultsContainer!=null)
resultsContainer.hide();if(contentUrl!=null)
contentUrl=null;var pagingObject=$('div.paging');if(pagingObject!=null)
pagingObject.hide();iwSearch();}}
function showModalWebResults(){var searchVisible=false;var resultsLoading=false;if(gcseid!=null&&gcseid.length>0){var loadingDiv=$('#google-iw-results-loading');google_search=new $.googlecustomsearch({cseid:gcseid,onSearchStarted:function(){if(!searchVisible){searchVisible=true;var $modal=$('#googlesearchresults_modal');var $results_container=$('#googlesearchresults_container');var $results=$('#google-iw-results');$('#iw-branding').html(google_search.branding);$results_container.scroll(function(evt){evt.preventDefault();var position=$results.outerHeight()-($results_container.height()*1.5);if($results_container.scrollTop()>=position){if(!resultsLoading){resultsLoading=true;google_search.nextPage();resultsLoading=false;}}});openElementAsModal($modal,600,800,'#ccc');}
loadingDiv.show();},onSearchCompleted:function(searcher){loadingDiv.hide();var $results=$('#google-iw-results');if(searcher.results&&searcher.results.length>0){for(var i=0;i<searcher.results.length;i++){var result=searcher.results[i];searcher.createResultHtml(result);if(result.html)
$results.append($(result.html.cloneNode(true)));}}else{if($results.html().length>=13)
$results.html('No results were found');}}});google_search.search(iwKeywords);}else{if(gcse==null)
return;if(resultsContainer!=null)
resultsContainer.html('');if(contentUrl!=null)
contentUrl=null;var pagingObject=$("div.paging");if(pagingObject!=null)
pagingObject.hide();iwSearch();}}
function getCookie(name){if(document.cookie.length>0){var start=document.cookie.indexOf(name+"=");if(start!=-1){start=start+name.length+1;var end=document.cookie.indexOf(";",start);if(end==-1)
end=document.cookie.length;return unescape(document.cookie.substring(start,end));}}
return"";}
function submitForwardItems()
{if($("#ForwardEmail").val().length==0){$("#forwardemailrequired").show();return false;}
$('#forwardbooks_loading').show();return ajaxifyForm(this,"forwardBookSuccess()");}