
var Core={};Core.GetHtml=function(url,data,cache,callback){$.ajax({cache:cache,data:data,dataType:"html",success:callback,type:"GET",url:url});};Core.PostHtml=function(url,data,cache,callback){$.ajax({cache:cache,data:data,dataType:"html",success:callback,type:"POST",url:url});};Core.OpenAdp=function(url)
{var popup="/popup";var queryIndex=url.indexOf("?");if(queryIndex>=0)
{popup+=url.substr(queryIndex);url=url.substr(0,queryIndex);}
url=url+popup;window.open(url,"","width=969,height=744,scrollbars=1");};Core.OpenFaq=function(url)
{window.open(url,"FAQs","width=630,height=650,scrollbars=1;status=0,toolbar=0,menubar=0,resizable=0,location=0,directories=0,minimize=0,maximize=0'");};Core.IsAlphaNumeric=function(keyCode)
{return((keyCode>=48&&keyCode<=90)||(keyCode>=96&&keyCode<=105));};Core.IsEnterKey=function(keyCode)
{return keyCode==13;};function sslRedirector()
{var that={};that.ToNonSecureUrl=function(secureUrl)
{return Core.ToNonSecureUrl(secureUrl);};return that;}
Core.ToNonSecureUrl=function(secureUrl)
{var url=secureUrl;if(url.indexOf("https://secure.")==0)
{url="http://www."+url.substr(15);}
return url;};Core.SetAllToLargestHeight=function(elements)
{var height=0;elements.each(function()
{var currentHeight=$(this).height();if(height<currentHeight)
{height=currentHeight;}});elements.height(height);};Core.RemoveItemsFromArray=function(list,items)
{var index;for(var i=0;i<items.length;i++)
{index=0;while(index<list.length)
{if(list[index]==items[i])
{list.splice(index,1);}
else
{index++;}}}};Core.stringInsert=function(source,index,value)
{try
{var first=source.substring(0,index);var last=source.substring(index);return first+value+last;}
catch(ex)
{return source;}};Core.stringInsertAtMatch=function(html,regExDelimiter,insertValue)
{var wrappingHtml=html;try
{var delimIndex=wrappingHtml.search(regExDelimiter);while(delimIndex>-1)
{wrappingHtml=Core.stringInsert(wrappingHtml,delimIndex+1,insertValue);delimIndex=wrappingHtml.search(regExDelimiter);}
return wrappingHtml;}
catch(ex)
{return html;}}

var events={};events.Download={};events.Download.CloseDownloadDialog="CloseDownloadDialog";events.Download.BeginDownload="BeginDownload";events.Download.GetProducts="GetProductsForDownload";events.Modal={};events.Modal.BeforeClose="onBeforeClose";

$.fn.outerHtml=function()
{return $("<div>").append(this.eq(0).clone()).html();};jQuery.isJson=function(str)
{if(jQuery.trim(str)=='')return false;str=str.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"/g,'');return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);};jQuery.evalJson=function(str)
{return eval("("+str+")");};jQuery.fn.maxLength=function(max)
{this.each(function()
{var type=this.tagName.toLowerCase();var inputType=this.type?this.type.toLowerCase():null;if(type=="input"&&inputType=="text"||inputType=="password")
{this.maxLength=max;}
else if(type=="textarea")
{this.onkeypress=function(e)
{var ob=e||event;var keyCode=ob.keyCode;var hasSelection=document.selection?document.selection.createRange().text.length>0:this.selectionStart!=this.selectionEnd;return!(this.value.length>=max&&(keyCode>50||keyCode==32||keyCode==0||keyCode==13)&&!ob.ctrlKey&&!ob.altKey&&!hasSelection);};this.onkeyup=function()
{if(this.value.length>max)
{this.value=this.value.substring(0,max);}};}});};jQuery.fn.extend({check:function()
{return this.each(function(){$(this).attr("checked","checked");});},uncheck:function()
{return this.each(function(){$(this).removeAttr("checked");});},setCheckState:function(isChecked)
{return isChecked?this.check():this.uncheck();},isChecked:function()
{return this.eq(0).attr("checked");}});jQuery.fn.setCursorPosition=function(startPos,endPos)
{var inputElement=this.get(0);if(inputElement!==undefined)
{if(inputElement.setSelectionRange)
{inputElement.setSelectionRange(startPos,endPos);inputElement.focus();}
else if(inputElement.createTextRange)
{var range=inputElement.createTextRange();range.move("sentence",0);range.select();}}};

if(!CookieManager)
{var CookieManager=function(){};}
CookieManager.UserCookieName="tu";CookieManager.SavedSettingsCookieName="tss";CookieManager.SavedSessionSettingsCookieName="tsss";CookieManager.getInstance=function()
{if(!CookieManager._instance)
{CookieManager._instance=new CookieManager();}
CookieManager._instance._refreshCookieCache();return CookieManager._instance;};CookieManager.getCookie=function(name)
{return CookieManager.getInstance().getCookie(name);};CookieManager.cookiesAllowed=function()
{return CookieManager.getInstance().cookiesAllowed();};CookieManager.prototype._refreshCookieCache=function()
{this.cookieDictionary=CookieManager._deserializeCookies();};CookieManager._deserializeCookies=function()
{var serializedCookies=document.cookie;var cookieArray=serializedCookies.split(';');var cookies=new Dictionary();for(var i=0;i<cookieArray.length;i++)
{var cookieString=jQuery.trim(cookieArray[i]);var cookie=Cookie.deserialize(cookieString);cookies.add(cookie.name,cookie);}
return cookies;};CookieManager.prototype.getCookie=function(name)
{if(this.cookieDictionary.containsKey(name))
{return this.cookieDictionary.get(name);}
else
{var cookie=new Cookie(name);this.cookieDictionary.add(name,cookie);return cookie;}};CookieManager.prototype.removeCookie=function(name)
{if(this.cookieDictionary.containsKey(name))
{var cookie=this.cookieDictionary.get(name);cookie.remove();}};CookieManager.prototype.cookiesAllowed=function()
{if(!this._allowed)
{var testName="AllowedTest";var testValue="blah";this._allowed=false;try
{var cookie=this.getCookie(testName);cookie.setValue(testValue);cookie.save(false);this._refreshCookieCache();cookie=this.getCookie(testName);this._allowed=(cookie.getValue()==testValue);}
catch(ex)
{}}
return this._allowed;};function Cookie(name,value)
{this.name=name;this._value=value?value:'';this._values=new Dictionary();};Cookie.deserialize=function(cookieString)
{var firstEqualsIndex=cookieString.indexOf('=');var name=cookieString.substring(0,firstEqualsIndex);var value=cookieString.substring(firstEqualsIndex+1);var cookie=new Cookie(name);cookie._value=value;if(cookie._value.indexOf('=')>=0)
{cookie._values=new Dictionary();var valueArray=value.split('&');for(var i=0;i<valueArray.length;i++)
{if(valueArray[i]!="")
{var nv=valueArray[i].split('=');cookie._values.add(nv[0],nv[1]);}}}
return cookie;};Cookie.prototype.isMultivalued=function()
{return!this._values.isEmpty();};Cookie.prototype.getValue=function(name)
{if(name)
{return this._values.get(name);}
else
{return this._value;}};Cookie.prototype.setValue=function(param1,param2)
{if(typeof(param2)!='undefined')
{this._values.add(param1,param2);}
else
{this._values.clear();this._value=param1;}};Cookie.prototype.serialize=function()
{var cookieString=this.name+'=';if(this.isMultivalued())
{var names=this._values.keys();for(var i=0;i<names.length;i++)
{var name=names[i];var value=this._values.get(name);if(i>0)
cookieString+='&';cookieString+=name+'='+value;}}
else
{cookieString+=this._value;}
return cookieString;};Cookie.prototype._createCookie=function(expiryString)
{var cookieString=this.serialize();if(expiryString)
{cookieString+="; expires="+expiryString;}
cookieString+="; path=/; domain="+CookieManager.domain;document.cookie=cookieString;};Cookie.prototype.save=function(persistent)
{if(persistent)
{var date=new Date();date.setFullYear(date.getFullYear()+5);this._createCookie(date.toGMTString());}
else
{this._createCookie(null);}};Cookie.prototype.remove=function()
{var date=new Date();date.setFullYear(date.getFullYear()-1);this._createCookie(date.toGMTString());};

function Dictionary()
{this.dictionary=new Object();}
Dictionary.prototype.clear=function()
{this.dictionary=new Object();};Dictionary.prototype.containsKey=function(key)
{var exists=false;for(var i in this.dictionary)
{if(i==key&&this.dictionary[i]!=null)
{exists=true;break;}}
return exists;};Dictionary.prototype.containsValue=function(value)
{var contains=false;if(value!=null)
{for(var i in this.dictionary)
{if(this.dictionary[i]==value)
{contains=true;break;}}}
return contains;};Dictionary.prototype.get=function(key)
{return this.dictionary[key];};Dictionary.prototype.isEmpty=function()
{return(parseInt(this.size())==0);};Dictionary.prototype.keys=function()
{var keys=new Array();for(var i in this.dictionary)
{if(this.dictionary[i]!=null)
keys.push(i);}
return keys;};Dictionary.prototype.add=function(key,value)
{if(key==null)
{throw"NullReferenceException {"+key+"},{"+value+"}";}
this.dictionary[key]=value;};Dictionary.prototype.remove=function(key)
{var rtn=this.dictionary[key];this.dictionary[key]=null;return rtn;};Dictionary.prototype.size=function()
{var size=0;for(var i in this.dictionary)
{if(this.dictionary[i]!=null)
size++;}
return size;};Dictionary.prototype.toString=function()
{var result="";for(var i in this.dictionary)
{if(this.dictionary[i]!=null)
result+="{"+i+"},{"+this.dictionary[i]+"}\n";}
return result;};Dictionary.prototype.values=function()
{var values=new Array();for(var i in this.dictionary)
{if(this.dictionary[i]!=null)
values.push(this.dictionary[i]);}
return values;};

(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/MSIE 6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

var LanguageMenu={};LanguageMenu.onClose="LanguageMenuClose";LanguageMenu.Init=function()
{LanguageMenu.Selection=$("#LanguageSelection");var culture=Language.GetCurrent();$("a[culture='"+culture+"']").addClass("LanguageSelected");LanguageMenu.Selection.click(function(e)
{LanguageMenu.Selection.unbind("hover");LanguageMenu.Selection.removeClass("language").removeClass("language-hover").addClass("language-active");var menu=new MenuDialog(LanguageMenu.Selection,-15,22);menu.onCloseEvent=LanguageMenu.onClose;menu.display("Languages");$(document).bind(menu.onCloseEvent,LanguageMenu.HandleClose);$("#Dialog a[culture!='"+culture+"']").click(function(ev)
{ev.preventDefault();Language.SetCurrent($(this).attr("culture"));location.reload();});e.preventDefault();});LanguageMenu.RegisterHoverEvent();};LanguageMenu.RegisterHoverEvent=function()
{LanguageMenu.Selection.hover(function()
{$(this).removeClass("language").addClass("language-hover");},function()
{$(this).removeClass("language-hover").addClass("language");});};LanguageMenu.HandleClose=function()
{LanguageMenu.Selection.removeClass("language-hover").removeClass("language-active").addClass("language");LanguageMenu.RegisterHoverEvent();};$(document).ready(LanguageMenu.Init);

Preview={};Preview.Bubble;Preview.Link;Preview.Image;Preview.OnButton;Preview.OffButton;Preview.Timer;Preview.MinX;Preview.MaxX;Preview.MinY;Preview.MaxY;Preview.CenterX;Preview.CenterY;Preview.ThumbWidth;Preview.ThumbHeight;Preview.CursorX;Preview.CursorY;Preview.Collection;Preview.AssetID;Preview.Large;Preview.AddToLightbox;Preview.RemoveFromLightbox;Preview.ParentAddToLightbox;Preview.ParentRemoveFromLightbox;Preview.Init=function()
{Preview.Bubble=$("#PreviewBubble");Preview.Border=$("#PreviewBorder");Preview.Link=$("#PreviewLink");Preview.OnButton=$(".previewOn");Preview.OffButton=$(".previewOff");Preview.AssetID=$("#PreviewId");Preview.AddToLightbox=$("#PreviewBubble #PreviewAddToLightbox");Preview.RemoveFromLightbox=$("#PreviewBubble #PreviewRemoveFromLightbox");Preview.Bubble.bgiframe();Preview.Border.bgiframe();Preview.OffButton.click(function(event)
{Preview.SetCookie(false);event.preventDefault();});Preview.OnButton.click(function(event)
{Preview.SetCookie(true);event.preventDefault();});Preview.AddToLightbox.click(function()
{var element=$(this);LightboxUtil.ToggleLightboxIconShowHide(element.next(),element);LightboxUtil.ToggleLightboxIconShowHide(Preview.ParentRemoveFromLightbox,Preview.ParentAddToLightbox);LightboxUtil.SetUpLightboxAddEvents(element,Preview.AssetID.text());});Preview.RemoveFromLightbox.click(function()
{var element=$(this);LightboxUtil.ToggleLightboxIconShowHide(element.prev(),element);LightboxUtil.ToggleLightboxIconShowHide(Preview.ParentAddToLightbox,Preview.ParentRemoveFromLightbox);LightboxUtil.SetUpLightboxRemoveEvents(element,Preview.AssetID.text());});$().bind("mousemove",function(e)
{Preview.CursorX=e.pageX;Preview.CursorY=e.pageY;if(!Preview.IsMouseOnTarget())
Preview.HideBubble();});Preview.ToggleButtons(Preview.GetCookie());};Preview.HideBubble=function()
{clearTimeout(Preview.Timer);$(Preview.Image).unbind("load");Preview.Border.hide();Preview.Bubble.hide();$("#PreviewText").hide();};Preview.IsMouseOnTarget=function()
{if(Preview.CursorX<Preview.MinX||Preview.CursorX>Preview.MaxX||Preview.CursorY<Preview.MinY||Preview.CursorY>Preview.MaxY)
return false;return true;};Preview.BeginImageLoad=function()
{$(Preview.Image).unbind("load");Preview.Image=new Image();$(Preview.Image).bind("load",function(){Preview.ImageLoadComplete(this)});Preview.Image.src=Preview.Large;};Preview.ImageLoadComplete=function(image)
{Preview.FormatPreviewBubble(image);if(Preview.IsMouseOnTarget())
{Preview.Bubble.show();Preview.ShowBorder();Preview.MinX=Preview.Border.offset().left;Preview.MinY=Preview.Border.offset().top;Preview.MaxX=Preview.MinX+Preview.Border.width();Preview.MaxY=Preview.MinY+Preview.Border.height();}};Preview.ShowBorder=function()
{var borderLeft=Preview.Bubble.offset().left-10;var borderTop=Preview.Bubble.offset().top-10;Preview.Border.css("left",borderLeft).css("top",borderTop);Preview.Border.width(Preview.Bubble.width()+40);Preview.Border.height(Preview.Bubble.height()+40);Preview.Border.show();}
Preview.HookupHoverEvents=function(){$(".detailLink img").bind("mouseenter",function(e){if(Preview.OffButton.css("display")!="none"){Preview.HideBubble();Preview.MinX=$(this).offset().left;Preview.MinY=$(this).offset().top;Preview.MaxY=Preview.MinY+$(this).height();Preview.MaxX=Preview.MinX+$(this).width();Preview.CenterX=$(this).offset().left+$(this).width()/2;Preview.CenterY=$(this).offset().top+$(this).height()/2;var wrapper=$(this).parent().parent().parent();Preview.AssetID.text(wrapper.find(".detailLink").text());$("#PreviewCollection").text(wrapper.find(".collectionName").text());$("#PreviewText").empty();var assetTitle=wrapper.find("#AssetTitle").text();if(assetTitle){if(assetTitle.length>140){assetTitle=assetTitle.substring(0,137);assetTitle+='...';}
$("#PreviewText").text(assetTitle).show();}
$("#PreviewLink").attr("href",wrapper.find(".detailLink").attr("href"));Preview.AssetID.attr("href",wrapper.find(".detailLink").attr("href"));Preview.Large=$(this).attr("preview");Preview.Timer=setTimeout(function(){Preview.BeginImageLoad();},200);if($(wrapper).find("#AddToLightbox").hasClass(".hidden")){LightboxUtil.ToggleLightboxIconShowHide(Preview.RemoveFromLightbox,Preview.AddToLightbox);}
else{LightboxUtil.ToggleLightboxIconShowHide(Preview.AddToLightbox,Preview.RemoveFromLightbox);}
Preview.AddToLightbox.hover(function(){$(this).addClass("lightbox_add");$(this).removeClass("lightbox_off");},function(){$(this).addClass("lightbox_off");$(this).removeClass("lightbox_add");});$(Preview.AddToLightbox).attr("title",$(wrapper).find("#AddToLightbox").attr("title"));$(Preview.RemoveFromLightbox).attr("title",$(wrapper).find("#RemoveFromLightbox").attr("title"));Preview.ParentAddToLightbox=$(".wrapper").find("[assetId="+Preview.AssetID.text()+"]").filter("#AddToLightbox");Preview.ParentRemoveFromLightbox=$(".wrapper").find("[assetId="+Preview.AssetID.text()+"]").filter("#RemoveFromLightbox");}});};Preview.FormatPreviewBubble=function(image)
{Preview.Bubble.css("width",image.width);Preview.Link.css("width",image.width).css("height",image.height);Preview.Link.find("img").remove();Preview.Link.append(image);Preview.SetPosition();};Preview.SetPosition=function()
{var height=Preview.Bubble.height();var previewTop=Preview.CenterY-(height/2);var width=Preview.Bubble.width();var previewRight=Preview.CenterX+(width/2);var previewLeft=Preview.CenterX-(width/2);var outOfBoundsRight=$(window).width()-30;if(previewRight>outOfBoundsRight)
{var xAdjustment=previewRight-outOfBoundsRight;previewLeft=previewLeft-xAdjustment;}
Preview.Bubble.css("left",previewLeft).css("top",previewTop);};Preview.GetCookie=function()
{var cookie=CookieManager.getCookie(CookieManager.UserCookieName);var show=cookie.getValue("PB");if(show=="false")
{return false;}
return true;};Preview.SetCookie=function(show){var cookie=CookieManager.getCookie(CookieManager.UserCookieName);cookie.setValue("PB",show);cookie.save(true);Preview.ToggleButtons(show);};Preview.ToggleButtons=function(show){if(show){Preview.OnButton.hide();Preview.OffButton.show();}
else{Preview.OffButton.hide();Preview.OnButton.show();}};$(document).ready(Preview.Init);

var LightboxUtil={};LightboxUtil.RemoveLightboxItem=function(assetId,success,failure)
{LightboxUtil.AddRemoveLightboxItem(LightboxUtil.RemoveItemUrl,assetId,success,failure)};LightboxUtil.AddLightboxItem=function(assetId,success,failure)
{LightboxUtil.AddRemoveLightboxItem(LightboxUtil.AddItemUrl,assetId,success,failure)};LightboxUtil.AddRemoveLightboxItem=function(url,assetId,success,failure)
{success();$.ajax({url:url,type:"POST",data:{'assetID':assetId},success:function(status)
{if(status=="false")
{failure();}},error:failure});};LightboxUtil.ToggleLightboxIconShowHide=function(showTarget,hideTarget)
{$(hideTarget).addClass("hidden");$(showTarget).removeClass("hidden");};LightboxUtil.AddItemUrl='/Lightbox/AddItem';LightboxUtil.RemoveItemUrl='/Lightbox/RemoveItem';LightboxUtil.SetUpLightboxAddEvents=function(element,assetId)
{$(document).trigger({type:"AddToLightbox",assetId:assetId,element:element});element.bind("AddToLightboxSuccess",function()
{element.unbind("AddToLightboxSuccess");element.unbind("AddToLightboxFailure");});element.bind("AddToLightboxFailure",function()
{LightboxUtil.ToggleLightboxIconShowHide(element,element.next());element.unbind("AddToLightboxSuccess");element.unbind("AddToLightboxFailure");});};LightboxUtil.SetUpLightboxRemoveEvents=function(element,assetId)
{$(document).trigger({type:"RemoveFromLightbox",assetId:assetId,element:element});element.bind("RemoveFromLightboxSuccess",function()
{element.unbind("RemoveFromLightboxSuccess");element.unbind("RemoveFromLightboxFailure");});element.bind("RemoveFromLightboxFailure",function()
{LightboxUtil.ToggleLightboxIconShowHide(element,element.prev());element.unbind("RemoveFromLightboxSuccess");element.unbind("RemoveFromLightboxFailure");});};

function DialogBase(width,height,x,y)
{this.height=height;this.width=width;this.x=x;this.y=y;this.borderWidth=5;this.dialogPadding=10;this.dialogShift=0;this.backgroundStyle="LightBackground opacity0";this.borderStyle="LightBackground opacity75";this.dialogPaddingStyle="SmallDialogPadding";this.dialogType="";this.isShown=false;}
DialogBase.prototype={close:function()
{$(document).trigger(events.Modal.BeforeClose);if(this.onBeforeClose)
this.onBeforeClose();this.background.remove();this.container.remove();if(this.onClose)
this.onClose();if(this.onAfterClose)
this.onAfterClose();this.isShown=false;},_positionDialog:function(left,top)
{this.dialog.css('margin-left',left+this.borderWidth+'px')
this.border.css('margin-left',left+'px')
this.border.css('margin-top',top+'px');this.dialog.css('margin-top',top+this.borderWidth+'px');},_ieHackReapplyZIndex:function()
{var body=$("body");if(body.hasClass('ie6')||body.hasClass('ie7'))
{this.background.css('z-index',9998);this.container.css('z-index',9999);}},_initializeDialog:function()
{var background="<div dialogtype='"+this.dialogType+"' class='"+this.backgroundStyle+" ModalBackground'></div>";var modalContainer="<div dialogtype='"+this.dialogType+"' class='DialogContainer'></div>";var border="<div id='DialogBorder' dialogtype='"+this.dialogType+"' class='"+this.borderStyle+" BorderBackground'></div>";var dialog="<div id='Dialog' dialogtype='"+this.dialogType+"' class='"+this.dialogPaddingStyle+"'></div>";var dialogContent="<div id='DialogContent' class='dialogContent' dialogtype='"+this.dialogType+"'>"+this.content+'</div>';var body=$("body");body.append(background);body.append(modalContainer);this.container=$('div[dialogtype="'+this.dialogType+'"][class="DialogContainer"]');this.container.append(dialog);this.container.append(border);this.dialog=$('div[dialogtype="'+this.dialogType+'"][class="'+this.dialogPaddingStyle+'"]');this.dialog.append(dialogContent);this.dialogContent=$('div[dialogtype="'+this.dialogType+'"][class="dialogContent"]');this.background=$('div[dialogtype="'+this.dialogType+'"][class*="ModalBackground"]');this.border=$('div[dialogtype="'+this.dialogType+'"][class*="'+this.borderStyle+'"]');this._addAdditionalContent();this.dialog.bgiframe();this.border.bgiframe();this._ieHackReapplyZIndex();},_addAdditionalContent:function()
{},_resizeBackground:function()
{if($("body").hasClass("ie6"))
{this.background.width(document.documentElement.scrollWidth);var height=Math.max(document.documentElement.scrollHeight,$(window).height());this.background.height(height);}},_getLeftMargin:function()
{var window=$(window);var wWidth=window.width();var scrollbarWidth=17
var mouseOffset=15;if(this.x+mouseOffset+this.border.width()<wWidth||this.border.width()>wWidth)
{return this.x+mouseOffset;}
return wWidth-this.border.width();},_getTopMargin:function()
{var window=$(window);var wHeight=window.height();var mouseOffset=15;if(this.y+mouseOffset+this.height+this._getPadding()<wHeight)
{return this.y+mouseOffset;}
return wHeight-(this.height+this._getPadding());},_sizeDialog:function()
{this.dialog.width(this.width)
this.border.width(this.dialog.width()+this._getPadding())
this.border.height(this.dialog.height()+this._getPadding());},_getPadding:function()
{return(this.borderWidth*2)+(this.dialogPadding*2)},_show:function()
{if(!this.isShown)
{this.isShown=true;this._initializeDialog();this._sizeDialog();this._positionDialog(this._getLeftMargin(),this._getTopMargin());this._resizeBackground();this._wireupEvents();this.border.show();this.background.show();this.dialog.show();this.dialog.focus();}},_wireupEvents:function()
{}};function Dialog(width,height,x,y)
{this.base=DialogBase;this.base(width,height,x,y);this.closeButtonStyle="close_small";}
Dialog.prototype=new DialogBase();Dialog.prototype._addAdditionalContent=function()
{var close="<a href=\"javascript:void(0)\" id='DialogClose' class='"+this.closeButtonStyle+"'></a>";this.dialog.append(close);this.closeButton=$('#Dialog #DialogClose');};Dialog.prototype._wireupEvents=function()
{var context=this;this.background.click(function(evt)
{context.close();});this.closeButton.click(function(evt)
{evt.preventDefault();context.close();});};Dialog.prototype.onClose=null;Dialog.prototype.onBeforeClose=null;Dialog.prototype.onAfterClose=null;function ModalDialog(width,height)
{this.base=Dialog;this.base(width,height,0,0);this.borderWidth=10;this.dialogPadding=16;this.backgroundStyle="DarkBackground opacity50";this.borderStyle="LightBackground opacity75";this.closeButtonStyle="close_large";this.dialogPaddingStyle="LargeDialogPadding";}
ModalDialog.prototype=new Dialog();ModalDialog.prototype._getLeftMargin=function()
{var window=$(window);var wHeight=window.height();var wWidth=window.width();return((wWidth-this.width)/2);};ModalDialog.prototype._getTopMargin=function()
{return $(window).scrollTop()+200-this.dialogShift;};ModalDialog.prototype._recalculateBorderHeight=function()
{this.border.height(this.dialog.height()+52);};function alertWindow(width,height)
{this.base=ModalDialog;this.base(width,height);this.backgroundStyle="DarkBackground opacity50";this.borderStyle="alertBackground almost-opaque";}
alertWindow.prototype=new ModalDialog();alertWindow.prototype._wireupEvents=function()
{var context=this;this.background.click(function(evt)
{context.close();});};alertWindow.prototype._addAdditionalContent=function(){};

function MenuDialog(contextElement,offsetLeft,offsetTop)
{this.offsetLeft=offsetLeft;this.offsetTop=offsetTop;this.menuWasEntered=false;this.onCloseEvent=null;var offset=contextElement.offset();this.base=DialogBase;this.base("auto",0,offset.left,offset.top);this.dialogType="menuDialog";}
MenuDialog.prototype=new DialogBase();MenuDialog.prototype._wireupEvents=function()
{var context=this;this.dialog.mouseleave(function()
{context.close();});this.background.click(function(evt)
{context.close();});this.dialog.mouseenter(function()
{context.menuWasEntered=true;});$(document).bind("CloseMenuDialog",function()
{context.close();});};MenuDialog.prototype._getLeftMargin=function()
{return this.x+this.offsetLeft;};MenuDialog.prototype._getTopMargin=function()
{return this.y+this.offsetTop;};MenuDialog.prototype.display=function(menuContent)
{var cloned=$("[name='"+menuContent+"']").clone();cloned.removeClass("hidden");this.content=cloned.outerHtml();this._show();var context=this;setTimeout(function()
{if(!context.menuWasEntered)
context.close();},5000);};MenuDialog.prototype.close=function()
{this.background.remove();this.container.remove();if(this.onCloseEvent!=null)
$(document).trigger(this.onCloseEvent);};

var Language={};Language.SetCurrent=function(culture)
{var cookie=CookieManager.getCookie("tg");cookie.setValue("Language",culture);cookie.save();};Language.GetCurrent=function()
{var cookie=CookieManager.getCookie("tg");return cookie.getValue("Language");};

var HelpMenu={};HelpMenu.Selection=$("#HelpMenuSelection");HelpMenu.onClose="HelpMenuClose";HelpMenu.Init=function()
{HelpMenu.Selection.click(function(e)
{HelpMenu.Selection.unbind("hover");HelpMenu.Selection.removeClass("help-menu").removeClass("help-menu-hover").addClass("help-menu-active");var menu=new MenuDialog(HelpMenu.Selection,0,22);menu.onCloseEvent=HelpMenu.onClose;menu.display("HelpMenuItems");$(document).bind(HelpMenu.onClose,HelpMenu.HandleClose);e.preventDefault();});HelpMenu.RegisterHoverEvent();};HelpMenu.RegisterHoverEvent=function()
{HelpMenu.Selection.hover(function()
{$(this).removeClass("help-menu").addClass("help-menu-hover");},function()
{$(this).removeClass("help-menu-hover").addClass("help-menu");});};HelpMenu.HandleClose=function()
{HelpMenu.Selection.removeClass("help-menu-hover").removeClass("help-menu-active").addClass("help-menu");HelpMenu.RegisterHoverEvent();};HelpMenu.InitFaqLink=function(){$(".faqLink").live("click",function(e){e.preventDefault();Core.OpenFaq($(this).attr("href"));});};HelpMenu.InitContactUsLink=function()
{$("#HelpMenuContactUs").live("click",function(e)
{e.preventDefault();ContactUsModal._openModal();});}
$(document).ready(HelpMenu.Init);$(document).ready(HelpMenu.InitFaqLink);$(document).ready(HelpMenu.InitContactUsLink);

var AccountMenu={};AccountMenu.Selection=$("#AccountMenu");AccountMenu.onClose="AccountMenuClose";AccountMenu.Init=function()
{if(AccountMenu.Selection.length>0)
{AccountMenu.Selection.click(function(e)
{AccountMenu.Selection.unbind("hover");AccountMenu.Selection.removeClass("account-menu").removeClass("account-menu-hover").addClass("account-menu-active");var menu=new MenuDialog(AccountMenu.Selection,0,22);menu.onCloseEvent=AccountMenu.onClose;menu.display("AccountMenuItems");$(document).bind(AccountMenu.onClose,AccountMenu.HandleClose);e.preventDefault();});AccountMenu.RegisterHoverEvent();}};AccountMenu.RegisterHoverEvent=function()
{AccountMenu.Selection.hover(function()
{$(this).removeClass("account-menu").addClass("account-menu-hover");},function()
{$(this).removeClass("account-menu-hover").addClass("account-menu");});};AccountMenu.HandleClose=function()
{AccountMenu.Selection.removeClass("account-menu-hover").removeClass("account-menu-active").addClass("account-menu");AccountMenu.RegisterHoverEvent();};$(document).ready(AccountMenu.Init);

$(document).ready(function()
{var height=$("#SiteFooter").height();$("#SiteFooter").css("height",height).css("margin-top",-height);$("div.mainBody").css("padding-bottom",height);});

var SignIn={};SignIn.AjaxExecuting=false;String.prototype.startsWith=function(str){return(this.indexOf(str)===0);}
SignIn.InitializeReturnUrl=function(url)
{SignIn.ReturnUrl=url;}
SignIn.DisplaySignInDialog=function(e)
{if(!location.pathname.toLowerCase().startsWith("/authentication/login"))
{if(!SignIn.AjaxExecuting)
{SignIn.AjaxExecuting=true;var offset=$(e.target).offset();var modal=new ModalDialog(430,0);var postData={returnUrl:SignIn.ReturnUrl||location.href};modal.content=Core.GetHtml("/Authentication/SignInDialog",postData,false,function(data)
{modal.content=data;modal._show();$("#userName").focus();SignIn.AjaxExecuting=false;});}}
e.preventDefault();};SignIn.InitEvents=function()
{$(".signIn").live("click",SignIn.DisplaySignInDialog);};$(document).ready(SignIn.InitEvents);

SignIn.Register=function(e)
{e.preventDefault();$("#GlobalReturnUrl").val(location.href);$("#RegisterReturnUrlForm").submit();};$(document).ready(function()
{$("#Register").live("click",SignIn.Register);});

function CreateLightboxModal()
{this.width=489;this.height=420;this.dialogType="createLightboxModal";this.success={};this._getContents=function()
{context=this;Core.GetHtml("/createlightbox/index",null,false,function(data)
{context.content=data;context._show();$('#LightboxName').focus();$("#CreateLightbox #Cancel").click(function()
{context.close();});$("#CreateLightbox #Create").click(function()
{context._createLightbox();});});}
this._createLightbox=function()
{var name=$('#LightboxName').val();var client=$('#Client').val();var project=$('#Project').val();var notes=$('#Notes').val();var context=this;$.ajax({url:"/createlightbox/CreateLightbox",type:"POST",data:{'lightboxname':name,'client':client,'project':project,'notes':notes},success:function(status)
{if($.isJson(status))
{context.success(status);}
else
{context.dialogContent.html(status);context.border.height(context.dialog.height()+52);$("#CreateLightbox #Cancel").click(function()
{context.close();});$("#CreateLightbox #Create").click(function()
{context._createLightbox();});}}});}}
CreateLightboxModal.prototype=new ModalDialog();CreateLightboxModal.constructor=CreateLightboxModal;CreateLightboxModal.parent=ModalDialog.prototype;CreateLightboxModal.prototype.display=function()
{this._getContents();}
function CreateLightboxPreviewModal()
{this.dialogType="CreateLightboxPreviewModal";this.success=function(id)
{Lightbox.SetCurrentLightbox(id);LightboxPreview.InitializeResults(id);context.close();}}
CreateLightboxPreviewModal.prototype=new CreateLightboxModal();CreateLightboxPreviewModal.constructor=CreateLightboxPreviewModal;CreateLightboxPreviewModal.parent=CreateLightboxModal.prototype;CreateLightboxPreviewModal.prototype.display=function()
{this._getContents();}
function CreateLightboxDetailModal()
{this.dialogType="CreateLightboxDetailModal";this.success=function(id)
{document.location="/lightboxes/"+id;}}
CreateLightboxDetailModal.prototype=new CreateLightboxModal();CreateLightboxDetailModal.constructor=CreateLightboxDetailModal;CreateLightboxDetailModal.parent=CreateLightboxModal.prototype;CreateLightboxDetailModal.prototype.display=function()
{this._getContents();}
function ShareLightboxModal(contentProvider)
{this.width=489;this.dialogType="shareLightbox";this.contentProvider=contentProvider;var thisContext=this;this._getContents=function(lightboxId)
{$(document).unbind("CloseSharedLightbox");$(document).bind("CloseSharedLightbox",function()
{thisContext.close();});thisContext.content=thisContext.contentProvider.getContents().outerHtml();thisContext._show();Core.GetHtml("/lightboxes/share/"+lightboxId,null,false,function(data)
{var result=$.evalJson(data);thisContext.contentProvider.init(result);thisContext.border.height(thisContext.dialog.height()+52);});}}
ShareLightboxModal.prototype=new ModalDialog();ShareLightboxModal.constructor=ShareLightboxModal;ShareLightboxModal.parent=ModalDialog.prototype;ShareLightboxModal.prototype.display=function(lightboxId)
{this._getContents(lightboxId);}
ShareLightboxModal.prototype.onBeforeClose=function()
{this.contentProvider.reset();};

function DocumentLocation()
{}
DocumentLocation.prototype={ChangeLocation:function(location)
{document.location=location;},CurrentLocation:function()
{return document.location;},PathName:function()
{return document.location.pathname;},Protocol:function()
{return document.location.protocol;},Host:function()
{return document.location.host;},hash:function()
{return document.location.hash.substr(1);},href:function()
{return document.location.href;}};

function UrlParser()
{this.LocationProvider=new DocumentLocation();}
UrlParser.prototype={Fragments:function()
{return this.LocationProvider.PathName().substring(1).split("/");},FirstFragment:function()
{var fragments=this.Fragments();return fragments[0];},LastFragment:function()
{var fragments=this.Fragments();return fragments[fragments.length-1];},parameters:function()
{var map={};var parts=this.LocationProvider.href().replace(/[?&]+([^=&]+)(=[^&]*)?/gi,function(m,key,value)
{map[key]=(value===undefined)?true:value.substring(1);});return map;},parameterNamed:function(name)
{return this.parameters()[name];}};

function AssetParser()
{}
AssetParser.prototype={Parse:function(assets)
{var i=0;var count=assets.length;var data=new Array();for(i=0;i<count;i++)
{if(assets[i].IsAvailable)
data.push(assets[i].AssetId);}
return data.join(",");}};

function ActionHistoryProvider()
{}
ActionHistoryProvider.prototype={Init:function(action)
{$.historyInit(function()
{action();});},save:function(variables)
{$.historySaveCurrent(variables);}};

var Ajax={};Ajax.executor=function()
{var that={};that.getHtml=function(url,data,cacheRequest,callback)
{Core.GetHtml(url,data,cacheRequest,callback);};return that;};

var ContactUsModal={_replaceAll:function(str,searchTerm,replaceWith,ignoreCase){var regex="/"+searchTerm+"/g";if(ignoreCase)
regex+="i";return str.replace(eval(regex),replaceWith);},_bindCountryInfo:function(countryCode){$("#cc_Countries > div").addClass('hidden');$("#cc_"+countryCode).removeClass('hidden');var mail=this._replaceAll($("#em_"+countryCode).val(),'_','@',true);mail=this._replaceAll(mail,'-','.',true);$("#countryEmail_"+countryCode).text(mail).attr("href","mailto:"+mail);if($("#tp_"+countryCode).val()==''){$("#countryTollFree_"+countryCode).addClass('hidden');}
if($("#mp_"+countryCode).val()==''){$("#countryMainPhone_"+countryCode).addClass('hidden');}
ContactUsModal.Modal._sizeDialog()},_openModal:function(){var context=ContactUsModal;context.Modal=new ModalDialog(430,0);context.Modal.content=Core.GetHtml("/Contact",null,false,function(data){context.Modal.content=data;context.Modal._show();ContactUsModal._bindCountryInfo($("#countries").val());$("#countries").bind("change",null,function(e){ContactUsModal._bindCountryInfo($(this).val());});});return false;},RegisterLink:function(selector){$(selector).click(this._openModal);}};$(document).ready(function(){var contactUsSelector=".contactUs";var temporaryHackSelector="a[href=#ContactUs]";var selector=[contactUsSelector,temporaryHackSelector].join(',');ContactUsModal.RegisterLink(selector);});

var Lightboxes=Lightboxes||{};