

/*** jquery.alerts.js ***/

(function(a){a.alerts={verticalOffset:-75,horizontalOffset:0,repositionOnResize:true,overlayOpacity:.01,overlayColor:"#FFF",draggable:true,okButton:" OK ",cancelButton:" Cancel ",dialogClass:null,alert:function(b,c,d){if(c==null)c="Alert";a.alerts._show(c,b,null,"alert",function(a){if(d)d(a)})},confirm:function(b,c,d){if(c==null)c="Confirm";a.alerts._show(c,b,null,"confirm",function(a){if(d)d(a)})},prompt:function(b,c,d,e){if(d==null)d="Prompt";a.alerts._show(d,b,c,"prompt",function(a){if(e)e(a)})},_show:function(b,c,d,e,f){a.alerts._hide();a.alerts._overlay("show");a("BODY").append('<div id="popup_container">'+'<h1 id="popup_title"></h1>'+'<div id="popup_content">'+'<div id="popup_message"></div>'+"</div>"+"</div>");if(a.alerts.dialogClass)a("#popup_container").addClass(a.alerts.dialogClass);var g=a.browser.msie&&parseInt(a.browser.version)<=6?"absolute":"fixed";a("#popup_container").css({position:g,zIndex:99999,padding:0,margin:0});a("#popup_title").text(b);a("#popup_content").addClass(e);a("#popup_message").text(c);a("#popup_message").html(a("#popup_message").text().replace(/\n/g,"<br />"));a("#popup_container").css({minWidth:a("#popup_container").outerWidth(),maxWidth:a("#popup_container").outerWidth()});a.alerts._reposition();a.alerts._maintainPosition(true);switch(e){case"alert":a("#popup_message").after('<div id="popup_panel"><input type="button" value="'+a.alerts.okButton+'" id="popup_ok" /></div>');a("#popup_ok").click(function(){a.alerts._hide();f(true)});a("#popup_ok").focus().keypress(function(b){if(b.keyCode==13||b.keyCode==27)a("#popup_ok").trigger("click")});break;case"confirm":a("#popup_message").after('<div id="popup_panel"><input type="button" value="'+a.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+a.alerts.cancelButton+'" id="popup_cancel" /></div>');a("#popup_ok").click(function(){a.alerts._hide();if(f)f(true)});a("#popup_cancel").click(function(){a.alerts._hide();if(f)f(false)});a("#popup_ok").focus();a("#popup_ok, #popup_cancel").keypress(function(b){if(b.keyCode==13)a("#popup_ok").trigger("click");if(b.keyCode==27)a("#popup_cancel").trigger("click")});break;case"prompt":a("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="'+a.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+a.alerts.cancelButton+'" id="popup_cancel" /></div>');a("#popup_prompt").width(a("#popup_message").width());a("#popup_ok").click(function(){var b=a("#popup_prompt").val();a.alerts._hide();if(f)f(b)});a("#popup_cancel").click(function(){a.alerts._hide();if(f)f(null)});a("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(b){if(b.keyCode==13)a("#popup_ok").trigger("click");if(b.keyCode==27)a("#popup_cancel").trigger("click")});if(d)a("#popup_prompt").val(d);a("#popup_prompt").focus().select();break}if(a.alerts.draggable){try{a("#popup_container").draggable({handle:a("#popup_title")});a("#popup_title").css({cursor:"move"})}catch(h){}}},_hide:function(){a("#popup_container").remove();a.alerts._overlay("hide");a.alerts._maintainPosition(false)},_overlay:function(b){switch(b){case"show":a.alerts._overlay("hide");a("BODY").append('<div id="popup_overlay"></div>');a("#popup_overlay").css({position:"absolute",zIndex:99998,top:"0px",left:"0px",width:"100%",height:a(document).height(),background:a.alerts.overlayColor,opacity:a.alerts.overlayOpacity});break;case"hide":a("#popup_overlay").remove();break}},_reposition:function(){var b=a(window).height()/2-a("#popup_container").outerHeight()/2+a.alerts.verticalOffset;var c=a(window).width()/2-a("#popup_container").outerWidth()/2+a.alerts.horizontalOffset;if(b<0)b=0;if(c<0)c=0;if(a.browser.msie&&parseInt(a.browser.version)<=6)b=b+a(window).scrollTop();a("#popup_container").css({top:b+"px",left:c+"px"});a("#popup_overlay").height(a(document).height())},_maintainPosition:function(b){if(a.alerts.repositionOnResize){switch(b){case true:a(window).bind("resize",a.alerts._reposition);break;case false:a(window).unbind("resize",a.alerts._reposition);break}}}};jAlert=function(b,c,d){a.alerts.alert(b,c,d)};jConfirm=function(b,c,d){a.alerts.confirm(b,c,d)};jPrompt=function(b,c,d,e){a.alerts.prompt(b,c,d,e)}})(jQuery)

/*** jquery.autocomplete.min.js ***/

/*
 * jQuery Autocomplete plugin 1.1
 *
 * Copyright (c) 2009 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
 */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)return[""];if(!options.multiple)return[$.trim(value)];return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null;});}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);if(words.length==1)return words[0];var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery);

/*** jquery.cookie.js ***/

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires='; expires='+date.toUTCString()}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};

/*** jquery.defaultvalue.js ***/

eval(function (p, a, c, k, e, d) { e = function (c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) { d[e(c)] = k[c] || e(c) } k = [function (e) { return d[e] } ]; e = function () { return '\\w+' }; c = 1 }; while (c--) { if (k[c]) { p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]) } } return p } ('(3(7){7.z.A({5:3(h){p i.y(3(){c $2=$(i),5=h||$2.6(\'u\');a($2.6(\'t\')==\'v\'){j()}m{k()}3 j(){c $f=s();$f.B($2);$2.e();$2.l(3(){a($2.4().b<=0){$f.o();$2.e()}})}3 k(){8();$2.J(3(){a($2.4().b>0){8()}}).l(8).g(3(){$2.4()==5&&$2.4(\'\')});$2.D("E").F(3(){$2.4()==5&&$2.4(\'\')})}3 8(){4=7.G($2.4());a(4.b<=0||4==5){$2.4(5).C(\'d\')}m{$2.H(\'d\')}}3 s(){c $9=7("<2 />").6({\'t\':\'I\',\'x\':5,\'q\':$2.6(\'q\')+\' d\',\'r\':$2.6(\'r\'),\'n\':$2.6(\'n\')});$9.g(3(){$9.e();$2.o();w(3(){$2.g()},1)});p $9}})}})})(7);', 46, 46, '||input|function|val|defaultValue|attr|jQuery|setState|el|if|length|var|empty|hide|clone|focus|str|this|handlePasswordInput|handleTextInputs|blur|else|tabindex|show|return|class|style|createClone|type|rel|password|setTimeout|value|each|fn|extend|insertAfter|addClass|closest|form|submit|trim|removeClass|text|keypress'.split('|'), 0, {}));

/*** jquery.hoverIntent.minified.js ***/

(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

/*** jquery.lazyload.js ***/

(function(a){function d(){var d=[],e,f=0,g,h,i=a.expando;a.each(a.cache,function(b,c){var e=c.events;if(!e){c=this[i];e=c&&c.events}if(e&&e.inview){if(e.live){var f=a(c.handle.elem);a.each(e.live,function(){if(this.origType.substr(0,6)==="inview"){d=d.concat(f.find(this.selector).toArray())}})}else{d.push(c.handle.elem)}}});e=d.length;if(e){g=b();h=c();for(;f<e;f++){if(!a.contains(document.documentElement,d[f])){continue}var j=a(d[f]),k={height:j.height(),width:j.width()},l=j.offset(),m=j.data("inview"),n,o,p;if(l.top+k.height>=l.top&&l.top<h.top+g.height&&l.left+k.width>=h.left&&l.left<h.left+g.width){n=h.left>l.left?"right":h.left+g.width<l.left+k.width?"left":"both";o=h.top>l.top?"bottom":h.top+g.height<l.top+k.height?"top":"both";p=n+"-"+o;if(!m||m!==p){j.data("inview",p).trigger("inview",[true,n,o])}}else if(m){j.data("inview",false).trigger("inview",[false])}}}}function c(){return{top:window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop,left:window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft}}function b(){var b,c,d={height:window.innerHeight,width:window.innerWidth};if(!d.height){b=document.compatMode;if(b||!a.support.boxModel){c=b==="CSS1Compat"?document.documentElement:document.body;d={height:c.clientHeight,width:c.clientWidth}}}return d}setInterval(d,500)})(jQuery);

/*** jquery.tooltip.js ***/

(function(a){function o(d){function h(){b.parent.removeClass(g.extraClass).hide().css("opacity","")}if(a.tooltip.blocked)return;if(e)clearTimeout(e);c=null;var g=i(this);if((!f||!a.fn.bgiframe)&&g.fade){if(b.parent.is(":animated"))b.parent.stop().fadeTo(g.fade,0,h);else b.parent.stop().fadeOut(g.fade,h)}else h();if(i(this).fixPNG)b.parent.unfixPNG()}function n(){return{x:a(window).scrollLeft(),y:a(window).scrollTop(),cx:a(window).width(),cy:a(window).height()}}function m(d){if(a.tooltip.blocked)return;if(d&&d.target.tagName=="OPTION"){return}if(!g&&b.parent.is(":visible")){a(document.body).unbind("mousemove",m)}if(c==null){a(document.body).unbind("mousemove",m);return}b.parent.removeClass("viewport-right").removeClass("viewport-bottom");var e=b.parent[0].offsetLeft;var f=b.parent[0].offsetTop;if(d){e=d.pageX+i(c).left;f=d.pageY+i(c).top;var h="auto";if(i(c).positionLeft){h=a(window).width()-e;e="auto"}b.parent.css({left:e,right:h,top:f})}var j=n(),k=b.parent[0];if(j.x+j.cx<k.offsetLeft+k.offsetWidth){e-=k.offsetWidth+20+i(c).left;b.parent.css({left:e+"px"}).addClass("viewport-right")}if(j.y+j.cy<k.offsetTop+k.offsetHeight){f-=k.offsetHeight+20+i(c).top;b.parent.css({top:f+"px"}).addClass("viewport-bottom")}}function l(){e=null;if((!f||!a.fn.bgiframe)&&i(c).fade){if(b.parent.is(":animated"))b.parent.stop().show().fadeTo(i(c).fade,c.tOpacity);else b.parent.is(":visible")?b.parent.fadeTo(i(c).fade,c.tOpacity):b.parent.fadeIn(i(c).fade)}else{b.parent.show()}m()}function k(){if(a.tooltip.blocked||this==c||!this.tooltipText&&!i(this).bodyHandler)return;c=this;d=this.tooltipText;if(i(this).bodyHandler){b.title.hide();var e=i(this).bodyHandler.call(this);if(e.nodeType||e.jquery){b.body.empty().append(e)}else{b.body.html(e)}b.body.show()}else if(i(this).showBody){var f=d.split(i(this).showBody);b.title.html(f.shift()).show();b.body.empty();for(var g=0,h;h=f[g];g++){if(g>0)b.body.append("<br/>");b.body.append(h)}b.body.hideWhenEmpty()}else{b.title.html(d).show();b.body.hide()}if(i(this).showURL&&a(this).url())b.url.html(a(this).url().replace("http://","")).show();else b.url.hide();b.parent.addClass(i(this).extraClass);if(i(this).fixPNG)b.parent.fixPNG();j.apply(this,arguments)}function j(b){if(i(this).delay)e=setTimeout(l,i(this).delay);else l();g=!!i(this).track;a(document.body).bind("mousemove",m);m(b)}function i(b){return a.data(b,"tooltip")}function h(c){if(b.parent)return;b.parent=a('<div id="'+c.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if(a.fn.bgiframe)b.parent.bgiframe();b.title=a("h3",b.parent);b.body=a("div.body",b.parent);b.url=a("div.url",b.parent)}var b={},c,d,e,f=a.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),g=false;a.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){a.tooltip.blocked=!a.tooltip.blocked}};a.fn.extend({tooltip:function(c){c=a.extend({},a.tooltip.defaults,c);h(c);return this.each(function(){a.data(this,"tooltip",c);this.tOpacity=b.parent.css("opacity");this.tooltipText=this.title;a(this).removeAttr("title");this.alt=""}).mouseover(k).mouseout(o).click(o)},fixPNG:f?function(){return this.each(function(){var b=a(this).css("backgroundImage");if(b.match(/^url\(["']?(.*\.png)["']?\)$/i)){b=RegExp.$1;a(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+b+"')"}).each(function(){var b=a(this).css("position");if(b!="absolute"&&b!="relative")a(this).css("position","relative")})}})}:function(){return this},unfixPNG:f?function(){return this.each(function(){a(this).css({filter:"",backgroundImage:""})})}:function(){return this},hideWhenEmpty:function(){return this.each(function(){a(this)[a(this).html()?"show":"hide"]()})},url:function(){return this.attr("href")||this.attr("src")}})})(jQuery)

/*** z_custum.js ***/

$(document).ready(function () {

    $('.lazyload').live('inview', function (event, isVisible) {
        if ($(this).attr("longdesc") != $(this).attr("src")) $(this).attr("src", $(this).attr("longdesc"));
    });

    $(".tooltip").tooltip({
        "delay": 0,
        "track": true,
        "fade": 250,
        "showURL": false,
        "top": 15,
        "positionLeft": true,
        "left": -15
    });

    $(".search_box_text").autocomplete("/Addons/Search/Webservice/GoogleSuggestions.ashx",
        {
            selectFirst: false
        }
     ).result(function (event, item) {
         var btn = document.getElementById("ctl00_Top_ctl02_ib1");
         if (btn) btn.click();
     });

    var config = {
        over: makeTall, // function = onMouseOver callback (REQUIRED)    
        timeout: 1000, // number = milliseconds delay before onMouseOut    
        out: makeShort // function = onMouseOut callback (REQUIRED)    
    };
    $(".search_tab").hoverIntent(config);
    $(".search_tab").click(makeTall);
    $(".search_tab_bg_right").html($(".search_tab_content_1").html());

    function makeTall() {
        $(".search_tab").removeClass("active");
        $(this).addClass("active");
        var tabName = ".search_" + $(this).attr("id");
        $(".search_tab_bg_inner").html($(tabName).html());
        $.cookie("search_tab", $(this).attr("id"), { path: '/' });
        return false;
    }

    function makeShort() {
        return false;
    }

    function BindDD(parrentClass, childClass, notBindName, BindName, ParentName) {
        $("." + childClass).attr("disabled", "disabled");
        $("." + childClass).append($("<option></option>").val("0").html(notBindName));
        $("." + parrentClass).change(function () {
            $("." + childClass).html("");
            $("." + childClass).attr("disabled", "disabled");
            var ID = $("." + parrentClass + " option:selected").attr("value");
            if (ID != 0) {
                $("." + childClass).append($("<option></option>").val("0").html(BindName));
                $.getJSON('/Addons/Search/Webservice/DropDown.ashx?id=' + ID + '&name=' + ParentName, function (items) {
                    $.each(items, function () {
                        $("." + childClass).append($("<option></option>").val(this['ID']).html(this['Title']));
                    });
                    $("." + childClass).attr("disabled", "");
                });
            }
            else {
                $("." + childClass).append($("<option></option>").val("0").html(notBindName));
            }
        });
    }

    function ClearDD(parrentClass, childClass, notBindName) {
        $("." + parrentClass).change(function () {
            $("." + childClass).html("");
            $("." + childClass).attr("disabled", "disabled");
            $("." + childClass).append($("<option></option>").val("0").html(notBindName));
        });
    }

    BindDD("search_box2_dd1", "search_box2_dd2", "בחר קטגוריה", "כל הקטגוריות", "2");
    BindDD("search_box2_dd1", "search_box2_dd3", "בחר סוג", "כל הסוגים", "3");
    BindDD("search_box2_dd1", "search_box2_dd4", "בחר אזור", "כל האזורים", "4");
    BindDD("search_box2_dd4", "search_box2_dd5", "בחר יישוב", "כל הישובים", "");
    ClearDD("search_box2_dd1", "search_box2_dd5", "בחר יישוב");

    //check if in cookie
    var search_tab = $.cookie("search_tab");
    if (search_tab != null) {
        $('.search_tab').each(function () {
            var id = $(this).attr("id");
            if (search_tab == id) {
                $(".search_tab").removeClass("active");
                $(this).addClass("active");
                var tabName = ".search_" + $(this).attr("id");
                $(".search_tab_bg_inner").html($(tabName).html());
                $.cookie("search_tab", $(this).attr("id"), { path: '/' });
            }
        });
    }

    if ($.cookie("add_coupons") == null) {
        $.cookie("add_coupons", " ", { path: '/' });
        registerPopupOpen();
    }
    $('.add_coupon_to_list').each(function () {
        var items = $.cookie("add_coupons");
        var id = $(this).attr('id').replace("add_coupon_to_list_", "");
        if (items.indexOf(id) != -1) $(this).attr("checked", "checked");
    });

    //cupon add click
    $('.add_coupon_to_list').click(function () {
        if ($(this).is(':checked')) {
            var items = $.cookie("add_coupons");
            var id = $(this).attr('id').replace("add_coupon_to_list_", "");
            if (items.indexOf(id) == -1) {
                items = items + id + ",";
                $.cookie("add_coupons", items, { path: '/' });
            }
            jAlert('הקופון נוסף לרשימת הדפסה. להדפסה לחץ על<br /> "הדפסת קופון" או "קופונים שלי" בצד שמאל.', 'הדפסת קופון');
            $.get('/Addons/UserProfile/Controlers/UpdateStatistic.ashx?id=' + id + '&type=2');
            if ($.cookie("aff_id") != null && $.cookie("aff_id") != "0") {
                $.get('/Addons/UserProfile/Controlers/UpdateStatistic.ashx?id=' + $.cookie("aff_id") + '&type=8');
            }
        }
        else {
            var items = $.cookie("add_coupons");
            var id = $(this).attr('id').replace("add_coupon_to_list_", "");
            items = items.replace(id + ",", "");
            $.cookie("add_coupons", items, { path: '/' });
        }
    });

    $('.coupon_box_print_a').click(function () {
        var items = $.cookie("add_coupons");
        var id = $(this).attr('id').replace("coupon_box_print_", "");
        if (items.indexOf(id) == -1) {
            items = items + id + ",";
            $.cookie("add_coupons", items, { path: '/' });
        }
        $.get('/Addons/UserProfile/Controlers/UpdateStatistic.ashx?id=' + id + '&type=2');
        if ($.cookie("aff_id") != null && $.cookie("aff_id") != "0") {
            $.get('/Addons/UserProfile/Controlers/UpdateStatistic.ashx?id=' + $.cookie("aff_id") + '&type=8');
        }
        popup('/print');
        return false;
    });

    $('.side_cupons').click(function () {
        popup('/print');
        return false;
    });

    $('.send_sms').click(function () {
        return false;
    });


    function popup(url) {
        var width = 530;
        var height = 600;
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 2;
        var params = 'width=' + width + ', height=' + height;
        params += ', top=' + top + ', left=' + left;
        params += ', directories=no';
        params += ', location=no';
        params += ', menubar=no';
        params += ', resizable=no';
        params += ', scrollbars=yes';
        params += ', status=no';
        params += ', toolbar=no';
        newwin = window.open(url, 'Print', params);
        if (window.focus) { newwin.focus() }
        return false;
    }

});

function shareFacebook(title,content,img,url) {
	var url = "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=http://www.cuponim.co.il"+url+"&p[images][0]=http://www.cuponim.co.il"+img+"&p[summary]="+content+"&p[title]=" + title
	window.open(url, 'Share', 'toolbar=0,status=yes,resizable=yes,status=0,width=626,height=436');
}

function shareTwitter(title,url) {
	var url = "http://twitter.com/home?status="+title+"%20http://www.cuponim.co.il"+ url;
	window.open(url, 'Share', 'toolbar=0,status=yes,resizable=yes,width=626,height=436');
}

function registerPopupOpen() {
    $("#register_popup").removeClass("dn");
    $("#register_popup").html("<div id='register_popup_content'><iframe src='/LandingPage/index_small.html' width='843' height='416' scrolling='no' frameborder='0'  allowTransparency='true' /></div/><div id='register_popup_bg'></div/>");
}

function registerPopupClose() {
    $("#register_popup").addClass("dn");
    $("#register_popup").html("");
}

function getQuerystring(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}
