﻿(function(jQuery){jQuery.fn.__bind__=jQuery.fn.bind;jQuery.fn.__unbind__=jQuery.fn.unbind;jQuery.fn.__find__=jQuery.fn.find;var hotkeys={version:'0.7.9',override:/keypress|keydown|keyup/g,triggersMap:{},specialKeys:{27:'esc',9:'tab',32:'space',13:'return',8:'backspace',145:'scroll',20:'capslock',144:'numlock',19:'pause',45:'insert',36:'home',46:'del',35:'end',33:'pageup',34:'pagedown',37:'left',38:'up',39:'right',40:'down',109:'-',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12',191:'/'},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"},newTrigger:function(type,combi,callback){var result={};result[type]={};result[type][combi]={cb:callback,disableInInput:false};return result;}};hotkeys.specialKeys=jQuery.extend(hotkeys.specialKeys,{96:'0',97:'1',98:'2',99:'3',100:'4',101:'5',102:'6',103:'7',104:'8',105:'9',106:'*',107:'+',109:'-',110:'.',111:'/'});jQuery.fn.find=function(selector){this.query=selector;return jQuery.fn.__find__.apply(this,arguments);};jQuery.fn.unbind=function(type,combi,fn){if(jQuery.isFunction(combi)){fn=combi;combi=null;}
if(combi&&typeof combi==='string'){var selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();var hkTypes=type.split(' ');for(var x=0;x<hkTypes.length;x++){delete hotkeys.triggersMap[selectorId][hkTypes[x]][combi];}}
return this.__unbind__(type,fn);};jQuery.fn.bind=function(type,data,fn){var handle=type.match(hotkeys.override);if(jQuery.isFunction(data)||!handle){return this.__bind__(type,data,fn);}
else{var result=null,pass2jq=jQuery.trim(type.replace(hotkeys.override,''));if(pass2jq){result=this.__bind__(pass2jq,data,fn);}
if(typeof data==="string"){data={'combi':data};}
if(data.combi){for(var x=0;x<handle.length;x++){var eventType=handle[x];var combi=data.combi.toLowerCase(),trigger=hotkeys.newTrigger(eventType,combi,fn),selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();trigger[eventType][combi].disableInInput=data.disableInInput;if(!hotkeys.triggersMap[selectorId]){hotkeys.triggersMap[selectorId]=trigger;}
else if(!hotkeys.triggersMap[selectorId][eventType]){hotkeys.triggersMap[selectorId][eventType]=trigger[eventType];}
var mapPoint=hotkeys.triggersMap[selectorId][eventType][combi];if(!mapPoint){hotkeys.triggersMap[selectorId][eventType][combi]=[trigger[eventType][combi]];}
else if(mapPoint.constructor!==Array){hotkeys.triggersMap[selectorId][eventType][combi]=[mapPoint];}
else{hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length]=trigger[eventType][combi];}
this.each(function(){var jqElem=jQuery(this);if(jqElem.attr('hkId')&&jqElem.attr('hkId')!==selectorId){selectorId=jqElem.attr('hkId')+";"+selectorId;}
jqElem.attr('hkId',selectorId);});result=this.__bind__(handle.join(' '),data,hotkeys.handler)}}
return result;}};hotkeys.findElement=function(elem){if(!jQuery(elem).attr('hkId')){if(jQuery.browser.opera||jQuery.browser.safari){while(!jQuery(elem).attr('hkId')&&elem.parentNode){elem=elem.parentNode;}}}
return elem;};hotkeys.handler=function(event){var target=hotkeys.findElement(event.currentTarget),jTarget=jQuery(target),ids=jTarget.attr('hkId');if(ids){ids=ids.split(';');var code=event.which,type=event.type,special=hotkeys.specialKeys[code],character=!special&&String.fromCharCode(code).toLowerCase(),shift=event.shiftKey,ctrl=event.ctrlKey,alt=event.altKey||event.originalEvent.altKey,mapPoint=null;for(var x=0;x<ids.length;x++){if(hotkeys.triggersMap[ids[x]][type]){mapPoint=hotkeys.triggersMap[ids[x]][type];break;}}
if(mapPoint){var trigger;if(!shift&&!ctrl&&!alt){trigger=mapPoint[special]||(character&&mapPoint[character]);}
else{var modif='';if(alt)modif+='alt+';if(ctrl)modif+='ctrl+';if(shift)modif+='shift+';trigger=mapPoint[modif+special];if(!trigger){if(character){trigger=mapPoint[modif+character]||mapPoint[modif+hotkeys.shiftNums[character]]||(modif==='shift+'&&mapPoint[hotkeys.shiftNums[character]]);}}}
if(trigger){var result=false;for(var x=0;x<trigger.length;x++){if(trigger[x].disableInInput){var elem=jQuery(event.target);if(jTarget.is("input")||jTarget.is("textarea")||jTarget.is("select")||elem.is("input")||elem.is("textarea")||elem.is("select")){return true;}}
result=result||trigger[x].cb.apply(this,[event]);}
return result;}}}};window.hotkeys=hotkeys;return jQuery;})(jQuery);


(function($) {
	$.infoBar = function(txt, options) {
		var text = txt || "&nbsp;",
			opties = $.extend({}, $.infoBar.defaults, options),
			random = parseInt(Math.random() * 10000),
			table = $("<table/>").attr("cellspacing", 0).attr("cellpadding", 0);  // menu;

		if (!opties.ID) {
			opties.ID = "infobar_R" + random;
		} else {
			opties.ID = "infobar_" + opties.ID;
			if (opties.cookie && !!$.cookie) {
				if ($.cookie(opties.ID) != null) {
					opties.hide = $.cookie(opties.ID) == "true" ? true : false;
				} else {
					$.cookie(opties.ID, opties.hide);
				}
			}
		}

		// add infobar;
		var root = $('<div/>').addClass("infobar").attr("id", opties.ID).toggle(!opties.hide).appendTo($(document.body));

		// add bar;
		$('<div/>').hide().addClass("infobar-bar").addClass(opties.type).append(
			$('<div/>').html(text).hover(function() {
				$(this).addClass("hover");
			}, function() {
				$(this).removeClass("hover");
			}).click(function(e) {
				var V = viewport(),
					W = $("#" + opties.ID + " .infobar-menu").width(),
					X = e.pageX - V.x,
					Y = e.pageY - V.y;
				$("#" + opties.ID + " .infobar-menu").css("top", Y).css("left", (X <= V.w - W ? X : Math.min(X - W, X))).show();
				V = W = X = Y = null;  // clean up;
			}).append(
				$("<input/>").attr("type", "button").attr("value", "x").click(function() {
					hider();
					return false;
				})
			)
		).appendTo(root).slideDown();
/*
		// add menu & items;
		opties.menu.push(null, { txt: "Close InfoBar" }, { txt: "Info about InfoBar for jQuery...",
			fn: "http://www.jeroenvanwarmerdam.nl/content/resources/javascript/jquery/infobar/infobar.aspx"
		});
		*/
		
		$.each(opties.menu, function(i, val) {
			if (!!val) {
				var txt = !!val.txt ? val.txt.toString() : "",
					fn = !!val.fn ? val.fn : function() { };
				table.append(
					$("<tr/>").append(  // image;
						$("<th/>").html(!!val.icon ? '<img src="' + val.icon.toString() + '" title="' + txt + '" />' : "&nbsp;")
					).append(  // verticale divider;
						$("<td/>").addClass("dividerH").html("&nbsp;")
					).append(  // text;
						$("<td/>").text(txt)
					).click(function() {  // extra function;
						if (typeof (fn) == "string" ? (function() { window.open(fn); return true; })() : (fn() == false ? false : true)) {
							hider();
						}
					})
				);
			} else {  // horizontale divider;
				table.append(
					$("<tr/>").addClass("dividerV").append(
						$("<th/>").html("&nbsp;")
					).append(
						$("<td/>").addClass("dividerH").html("<div><!-- no content fix for Chrome & empty div fix for IE --></div>")
					).append(
						$("<td/>").html("<div><!-- no content fix for Chrome & empty div fix for IE --></div>")
					)
				);
			}
		});

		// add menu;
		$("<div/>").hide().addClass("infobar-menu").append(table).appendTo(root)
		.find("tr:not(.dividerV)").hover(function() {
			$(this).addClass("hover");
		}, function() {
			$(this).removeClass("hover");
		});

		function hider() {
			$("#" + opties.ID + " .infobar-bar").fadeOut("slow");
			$("#" + opties.ID + " .infobar-menu").hide("fast");
			if (opties.cookie && !!$.cookie && !opties.ID.match("infobar_R")) {
				$.cookie(opties.ID, !opties.hide);
			}
		}

		// window helper;
		function viewport() {
			return {
				x: $(window).scrollLeft(),
				y: $(window).scrollTop(),
				w: $(window).width(),
				h: $(window).height()
			};
		};

		// hide menu on blur;
		$().click(function(e) {
			if (!jQuery(e.target).is("#" + opties.ID + " *")) {
				$("#" + opties.ID + " .infobar-menu").hide("fast");
			}
		});

		// clean up;
		text = random = table = null;

		// return this InfoBar;
		return root;
	};

	// public enum;
	$.infoBar.type = {
		exclamation: "exclamation",
		error: "error",
		help: "help",
		ok: "ok",
		warning: "warning"
	};

	// public defaults;
	$.infoBar.defaults = {
		ID: null,
		type: $.infoBar.type.warning,
		menu: [],
		hide: false,
		cookie: true,
		zOrder: 1
	};
})(jQuery);  // plugin code end;

/*	ColorBox v1.3.5 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 */
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function N(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i)}function Z(b){i=b;a=c(i).data(q);Y();var d=a.rel||i.rel;if(d&&d!=="nofollow"){h=c(".cboxElement").filter(function(){return(c(this).data(q).rel|| this.rel)===d});j=h.index(i);if(j<0){h=h.add(i);j=h.length-1}}else{h=c(i);j=0}if(!C){D=C=n;O=i;O.blur();c().bind("keydown.cbox_close",function(e){if(e.keyCode===27){e.preventDefault();f.close()}}).bind("keydown.cbox_arrows",function(e){if(h.length>1)if(e.keyCode===37){e.preventDefault();E.click()}else if(e.keyCode===39){e.preventDefault();F.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",f.close);c.event.trigger(aa);a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w= r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");f.position(0);P&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}Q.add(E).add(F).add(t).add(H).hide();R.html(a.close).show();f.slideshow();f.load()}var q="colorbox",x="hover",n=true,f,y=!c.support.opacity,P=y&&!window.XMLHttpRequest,aa="cbox_open",I="cbox_load",S="cbox_complete",T="resize.cbox_resize",s,k,u,p,U,V,W,X,h,m,l,J,K,L,H,Q,t,F,E, R,z,A,v,w,i,O,j,a,C,D,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:n,slideshow:false,slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"start slideshow", slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};f=c.fn.colorbox=function(b,d){var e=this;if(!e.length)if(e.selector===""){e=c(e);b.open=n}else return this;e.each(function(){var g=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,g).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(e);return this};f.init=function(){function b(d){return c('<div id="cbox'+d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s= b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),K=b("LoadingOverlay"),L=b("LoadingGraphic"),H=b("Title"),Q=b("Current"),t=b("Slideshow"),F=b("Next"),E=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"});J=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>"); c("body").prepend(s,k.append(u,J));if(y){k.addClass("cboxIE");P&&s.css("position","absolute")}p.children().addClass(x).mouseover(function(){c(this).addClass(x)}).mouseout(function(){c(this).removeClass(x)});z=U.height()+X.height()+p.outerHeight(n)-p.height();A=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":z,"padding-right":A}).hide();F.click(f.next);E.click(f.prev);R.click(f.close);p.children().removeClass(x);c(".cboxElement").live("click", function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};f.position=function(b,d){function e(B){U[0].style.width=X[0].style.width=p[0].style.width=B.style.width;L[0].style.height=K[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=B.style.height}var g=m.height();g=Math.max(g-a.h-v-z,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-A,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()===a.h+v?0:b;u[0].style.width= u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:g,left:o},{duration:b,complete:function(){e(this);D=false;u[0].style.width=a.w+w+A+"px";u[0].style.height=a.h+v+z+"px";d&&d()},step:function(){e(this)}})};f.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function e(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function g(G){f.position(G,function(){if(C){if(y){B&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+(a.href||i.href)+"' "+(y?"allowtransparency='true'":"")+" />");l.show();H.html(a.title||i.title);H.show();if(h.length>1){Q.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,h.length)).show();F.html(a.next).show();E.html(a.previous).show();a.slideshow&&t.show()}K.hide();L.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(M,1,function(){y&&k[0].style.removeAttribute("filter")}); m.bind(T,function(){f.position(0)})}})}if(C){var o,B,M=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(J).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:e()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});P&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(M,0,function(){g(0)})||g(M);if(a.preloading&&h.length>1){b=j>0?h[j-1]:h[h.length-1];o=j<h.length-1?h[j+1]:h[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;N(o)&&c("<img />").attr("src",o);N(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());f.position(M)},1)}};f.load=function(){var b,d,e,g=f.resize;D=n;i=h[j];a=c(i).data(q);Y();c.event.trigger(I); a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-z:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-A:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-A;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-z;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href||c(i).attr("href");K.show();L.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(I+" cbox_cleanup",function(){c(this).replaceWith(l.children())}); g(c(b))}else if(a.iframe)g(" ");else if(a.html)g(a.html);else if(N(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){e=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;e()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;e()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";g(d);h.length>1&&c(d).css({cursor:"pointer"}).click(f.next); if(y)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(J).load(b,function(o,B){B==="success"?g(this):g(c("<p>Request unsuccessful.</p>"))})};f.next=function(){if(!D){j=j<h.length-1?j+1:0;f.load()}};f.prev=function(){if(!D){j=j>0?j-1:h.length-1;f.load()}};f.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){e=setTimeout(f.next,a.slideshowSpeed)}).bind(I,function(){clearTimeout(e)}).one("click",function(){d();c(this).removeClass(x)});k.removeClass(g+ "off").addClass(g+"on")}var d,e,g="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(e);k.removeClass(g+"off "+g+"on")});d=function(){clearTimeout(e);t.text(a.slideshowStart).unbind(S+" "+I).one("click",function(){b();e=setTimeout(f.next,a.slideshowSpeed);c(this).removeClass(x)});k.removeClass(g+"on").addClass(g+"off")};if(a.slideshow&&h.length>1)a.slideshowAuto?b():d()};f.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);C=false;c().unbind("keydown.cbox_close keydown.cbox_arrows"); m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){l.remove();k.css({opacity:1});try{O.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};f.element=function(){return c(i)};f.settings=$;c(f.init)})(jQuery);


jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.event.special

jQuery.extend({
	timer: {
		global: [],
		guid: 1,
		dataKey: "jQuery.timer",
		regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseFloat(result[1]);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});
			
			if (!timers[label])
				timers[label] = {};
			
			fn.timerID = fn.timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.timerID = fn.timerID;
			
			if (!timers[label][fn.timerID])
				timers[label][fn.timerID] = window.setInterval(handler,interval);
			
			this.global.push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = jQuery.data(element, this.dataKey), ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.timerID ) {
							window.clearInterval(timers[label][fn.timerID]);
							delete timers[label][fn.timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					jQuery.removeData(element, this.dataKey);
			}
		}
	}
});

jQuery(window).bind("unload", function() {
	jQuery.each(jQuery.timer.global, function(index, item) {
		jQuery.timer.remove(item);
	});
});


(function($) {
	$.hrzAccordion = {
       
	   
	   setOnEvent: function(i, container, finalWidth, settings){
			$("#"+container+"Handle"+i).bind(settings.eventTrigger,function() {			 
			   			
						var status = $('[rel='+container+'ContainerSelected]').data('status');
						
						if(status ==1 && settings.eventWaitForAnim === true){
						 return false;	
						}
						
						if( $("#"+container+"Handle"+i).attr("rel") != container+"HandleSelected"){
			    		
						  settings.eventAction;
							
							$('[id*='+container+'Handle]').attr("rel","");			   				
			   				
							$('[id*='+container+'Handle]').attr("class",settings.handleClass);
		
			   				$("#"+container+"Handle"+i).addClass(settings.handleClassSelected);
										   
			   		
							$("."+settings.contentWrapper).css({width: finalWidth+"px" });
							
							switch(settings.closeOpenAnimation)
							{
							case 1:
      
				   
						if($('[rel='+container+'ContainerSelected]').get(0)  ){
						$('[rel='+container+'ContainerSelected]').data('status',1);
							
							//current_width = $('[rel='+container+'ContainerSelected]').width();
							
							$('[rel='+container+'ContainerSelected]').animate({width: "0px",opacity:"0"}, { queue:true, duration:settings.closeSpeed ,easing:settings.closeEaseAction,complete: function(){	
				 																																	
							$('[rel='+container+'ContainerSelected]').data('status',0);																																											} ,step: function(now){
																																																		 							width = $(this).width();
						
							//new_width = finalWidth- (finalWidth  * (width/current_width));
							new_width = finalWidth - width;
							$('#'+container+'Content'+i).width(Math.ceil(new_width)).css("opacity","1");
							
							}});
		
						}else{
							$('[rel='+container+'ContainerSelected]').data('status',1);
								
							$('#'+container+'Content'+i).animate({width: finalWidth,opacity:"1"}, { queue:false, duration:settings.closeSpeed ,easing:settings.closeEaseAction,complete: function(){
																																																	  $('[rel='+container+'ContainerSelected]').data('status',0);	
																																																	  }});
							
								
							}
							
							break;
							case 2:
								$('[id*='+container+'Content]').css({width: "0px"});
								$('#'+container+'Content'+i).animate({width: finalWidth+"px",opacity:"1"}, { queue:false, duration:settings.openSpeed ,easing:settings.openEaseAction, complete: 
 settings.completeAction																																																									});						
							
							break;
							}

							$('[id*='+container+'Content]').attr("rel","");			
							$("#"+container+"Handle"+i).attr("rel",container+"HandleSelected");
							$("#"+container+"Content"+i).attr("rel",container+"ContainerSelected");					
							
						
						}
						
					});	
}
	    };
	
	$.fn.extend({
	   
		hrzAccordionLoop: function(options) {
			return this.each(function(a){  
				
				var container = $(this).attr("id") || $(this).attr("class");
				var elementCount = $('#'+container+' > li, .'+container+' > li').size();
				var settings = $(this).data('settings');
				
				variable_holder="interval"+container ;
				var i =0;
				var loopStatus  = "start";
				
				variable_holder = window.setInterval(function(){							
				
				$("#"+container+"Handle"+i).trigger(settings.eventTrigger);
				
				if(loopStatus =="start"){
						i = i + 1;
					}else{
						i = i-1;	
					}
					
					if(i==elementCount && loopStatus  == "start"){
						loopStatus  = "end";
						i=elementCount-1;

					}
					
					if(i==0 && loopStatus  == "end"){
						loopStatus  = "start";
						i=0;

					}
												},settings.cycleInterval);
				
				
				});
			},
		hrzAccordion: function(options) {
			this.settings = {
			eventTrigger	   		: "click",
			containerClass     		: "container",
			listItemClass      		: "listItem",					
			contentContainerClass  	: "contentContainer",
			contentWrapper     		: "contentWrapper",
			contentInnerWrapper		: "contentInnerWrapper",
			handleClass        		: "handle",
			handleClassOver    		: "handleOver",
			handleClassSelected		: "handleSelected",
			handlePosition     		: "right",
			handlePositionArray		: "", // left,left,right,right,right
			closeEaseAction    		: "swing",
			closeSpeed     			: 500,
			openEaseAction     		: "swing",
			openSpeed      			: 500,
			openOnLoad		   		: 2,
			hashPrefix		   		: "tab",
			eventAction		   		: function(){
								 	//add your own extra clickAction function here
								 	},
			completeAction	   		: function(){
								 	//add your own onComplete function here
								 	},
			closeOpenAnimation 		: 1,// 1 - open and close at the same time / 2- close all and than open next
			cycle			   		: false, // not integrated yet, will allow to cycle through tabs by interval
			cycleInterval	   		: 10000,
			fixedWidth				: "",
			eventWaitForAnim		: true
				
		};
	
		if(options){
			$.extend(this.settings, options);
		}
			var settings = this.settings;
			
			
			
			return this.each(function(a){    		
				
				var container = $(this).attr("id") || $(this).attr("class");			
				
				$(this).data('settings', settings);
				
				$(this).wrap("<div class='"+settings.containerClass+"'></div>");
			
				var elementCount = $('#'+container+' > li, .'+container+' > li').size();
												
				var containerWidth =  $("."+settings.containerClass).width();
				
				var handleWidth = $("."+settings.handleClass).css("width");
		
				handleWidth =  handleWidth.replace(/px/,"");
			    var finalWidth;
				var handle;
				
				if(settings.fixedWidth){
					finalWidth = settings.fixedWidth;
				}else{
					finalWidth = containerWidth-(elementCount*handleWidth)-handleWidth;
				}
				
				$('#'+container+' > li, .'+container+' > li').each(function(i) {
			
					$(this).attr('id', container+"ListItem"+i);
			   		$(this).attr('class',settings.listItemClass);
		       		$(this).html("<div class='"+settings.contentContainerClass+"' id='"+container+"Content"+i+"'>"
								 +"<div class=\""+settings.contentWrapper+"\">"
								 +"<div class=\""+settings.contentInnerWrapper+"\">"
								 +$(this).html()
								 +"</div></div></div>");
			   		
					if($("div",this).hasClass(settings.handleClass)){
					
					var html = $("div."+settings.handleClass,this).attr("id",""+container+"Handle"+i+"").html();
					$("div."+settings.handleClass,this).remove();
					
					 handle = "<div class=\""+settings.handleClass+"\" id='"+container+"Handle"+i+"'>"+html+"</div>";
					}else{
					 handle = "<div class=\""+settings.handleClass+"\" id='"+container+"Handle"+i+"'></div>";
					}
					
				
					
					if(settings.handlePositionArray){
						splitthis 				= settings.handlePositionArray.split(",");
						settings.handlePosition = splitthis[i];
					}
					
					switch(settings.handlePosition ){
						case "left":
						$(this).prepend( handle );
						break;
						case "right":	
						$(this).append( handle );	
						break;
						case "top":	
						$("."+container+"Top").append( handle );	
						break;
						case "bottom":	
						$("."+container+"Bottom").append( handle );	
						break;
					}					
				
					$("#"+container+"Handle"+i).bind("mouseover", function(){
						$("#"+container+"Handle"+i).addClass(settings.handleClassOver);
					});
			    
					$("#"+container+"Handle"+i).bind("mouseout", function(){
						if( $("#"+container+"Handle"+i).attr("rel") != "selected"){
							$("#"+container+"Handle"+i).removeClass(settings.handleClassOver);
						}
					});
					
				
					$.hrzAccordion.setOnEvent(i, container, finalWidth, settings);				
					
					if(i == elementCount-1){
						$('#'+container+",."+container).show();					
					}
					
					
								
					if(settings.openOnLoad !== false && i == elementCount-1){
							var location_hash = location.hash;
							location_hash  = location_hash.replace("#", "");	
							if(location_hash.search(settings.hashPrefix) != '-1' ){
							var tab = 1;
							location_hash  = location_hash.replace(settings.hashPrefix, "");
							}
							
							if(location_hash && tab ==1){
						 		$("#"+container+"Handle"+(location_hash)).attr("rel",container+"HandleSelected");
								$("#"+container+"Content"+(location_hash)).attr("rel",container+"ContainerSelected");		
								$("#"+container+"Handle"+(location_hash-1)).trigger(settings.eventTrigger);
												
							}else{
								$("#"+container+"Handle"+(settings.openOnLoad)).attr("rel",container+"HandleSelected");
							    $("#"+container+"Content"+(settings.openOnLoad)).attr("rel",container+"ContainerSelected");	
								$("#"+container+"Handle"+(settings.openOnLoad-1)).trigger(settings.eventTrigger);
							}					
					}	
				});	
				
				if(settings.cycle === true){
					$(this).hrzAccordionLoop();
				}
			});				
		}		
	});
})(jQuery);	


jQuery.cookie = function(name, value, options) {
	if (typeof document.cookie == "undefined") return undefined;
	if (typeof value != 'undefined') { // name and value given, set cookie
		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(); // use expires attribute, max-age is not supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		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 { // only name given, get cookie
		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]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};


function init_break_news(){

$.get("break-news.php", function(data){ 


		if(data != "")
		{
			if(data.length == break_news_html_size)
				return false;
			
			break_news_html_size = data.length;
			

			
			if($('.break-news-ct').is(":hidden"))
			{
				$('.break-news-ct').fadeIn();
			}
			
				if(!$.cookie("break_news_" + break_news_html_size))
				{
					$("#break-alert").html('<embed src="beimg/fpnp/break-news/shababfm2.swf" width="1" height="1" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
					$.cookie("break_news_" + break_news_html_size, "1", { expires: 7 });
				}
				
			$("#break-news-bits").html(data);
			
			rreea = data.split('</a></div>').length;
			
			if(rreea > 2)
			
			setTimeout(function(){
				$(".block_43_container").scrollable({vertical:true, size: 1,speed: 2500}).mousewheel().circular().autoscroll({steps: 1,interval: 5000});
								 }, 2000);
			
			return false;
			
		}
		});										
   				
 }

function update_break_news(){

$.get("break-news.php", function(data){ 



	
		if(data != "")
		{
			if(data.length == break_news_html_size)
				return false;
			
			break_news_html_size = data.length;
			

			
			if($('.break-news-ct').is(":hidden"))
			{
				$('.break-news-ct').fadeIn();
			}
			
				if(!$.cookie("break_news_" + break_news_html_size))
				{
					$("#break-alert").html('<embed src="beimg/fpnp/break-news/shababfm2.swf" width="1" height="1" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
					$.cookie("break_news_" + break_news_html_size, "1", { expires: 7 });
				}
			$("#break-news-bits").html(data);
			
			rreea = data.split('</a></div>').length;
		
			if(rreea > 2)
				$(".block_43_container").scrollable().reload();
			
			
			
			return false;
			
		}else{
				
				if($('.break-news-ct').is(':visible'))
				{
					$('.break-news-ct').fadeOut();
					$('#break-news-bits').html("");
					$("#break-alert").html('');
					
				}
				return false;
			
			}
						 });										
   				
 }
 

$().ready(function() {
				   
if(!$.cookie("infobar_fpnp") && $.cookie("user_id") <= 0)
	$('#add-to-fav-img').slideDown("slow");

	break_news_html_size = 0;
	jQuery(document).bind('keydown', 'f5',function (evt){ window.location.href=window.location.href; return false; });

	


//setInterval(function() { update_break_news()}, 30000);
//setTimeout(function(){ init_break_news(); }, 100);

				   
   
$("a[rel='item_page_gallery']").colorbox({slideshow:true, slideshowStart: 'تشغيل',slideshowStop: 'ايقاف', current:"{current}/{total}"});
$("#add_ehdaa").click( function(){window.open("http://www.fpnp.net//chat/index.php","send_ehdaa","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=670, height=530")});


$("#print_link").click( function(){ window.open($("#print_link").attr("href"),"print_item","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=670, height=530"); return false});

	$('.comment_bit_title').click(function() {
				$('.comment_bit_content').slideUp();
				this_id = $(this).attr('id').split("comment-title-")[1];
				$('#comment-content-' + this_id).slideDown();
	
	}) ;

$('.comment_report').click(function() { $(this).colorbox({width:'40%',height:'250px', href: 'ar/report-comment/' + $(this).attr("id").split('-')[1] + '.html'});});


$('.comment_delete').click(function(){comment_delete($(this)); });
$('.comment_edit').click(function(){comment_edit($(this)); });
$('.comment_ban').click(function(){user_ban($(this)); });

animate_poller();

});


function comment_delete(e)
{
	var id = e.attr("rel");

	if(confirm("delete ?"))
		$.post("be_comment.php",{ "do": "delete", "id": id }, function(data){ alert(data.split("|=|")[0]); if(data.split("|=|")[1] == "1") window.location.reload(); });

}

function comment_edit(e)
{
	var id = e.attr("rel");
	
		$.post("be_comment.php",{ "do": "edit", "id": id }, function(data){
																	 

							if(data.split("|=|")[2] == "1")
							{
								$("#comment-btext-" + id).html('<textarea class="comment_text_input" cols="58" rows="8" name="comment_new_text" id="comment-new-text-' + id + '">' + data.split("|=|")[0] + '</textarea><div align="left"><input type="button" class="button" onclick="comment_edit_save('+id+')" value="save"  /></div>');
								
								$("#comment-btitle-" + id).html('<input name="comment_new_title" id="comment-new-title-' + id + '" size="45" class="comment_title_input" value="' + data.split("|=|")[1] + '" maxlength="100" type="text">');
							}
							
					});

}

function comment_edit_save(id)
{
	var new_txt = $("#comment-new-text-" + id).val();
	var new_title = $("#comment-new-title-" + id).val();
	
	$.post("be_comment.php",{ "do": "update", "id": id, "txt": new_txt, "title": new_title }, function(data){
				
				if(data.split("|=|")[1] == "1")
					{
						$("#comment-btext-" + id).html(new_txt);
						$("#comment-btitle-" + id).html(new_title);
					}
																 
																 
		});
}

function user_ban(e)
{
	var id = e.attr("rel");

	if(confirm("ban this user ?"))
		$.post("be_comment.php",{ "do": "ban", "id": id }, function(data){ alert(data.split("|=|")[0]); if(data.split("|=|")[1] == "1") window.location.reload(); });

}

function animate_poller()
{

poller_option_cc = 1;

$('.poller_bar').each(function(){
							   		
									width_factor = ($(this).parent().width() - 6)/100;
									poller_width = $(this).attr("rel")*width_factor;
									poller_per = $(this).attr("rel");
									//alert($(this).attr("rel"));

									$(this).everyTime(10, 'controlled', function() {

										newval = parseInt($(this).html()) + 1;
										if(newval <= $(this).attr("rel"))
										{
												$(this).width(newval+'%');
												$(this).html(newval+'%' );
										}

									
							   		 });


			poller_option_cc++;
		});


$("#poller_form").submit( function(){
								   
										var selected_choice = $("input[@name='vote_choice']:checked").val();
									   
										if(selected_choice == null)
										{
										   if($("#vote-choice:disabled").length > 0)
											   	alert("عذرا، لقد قمت بالتصويت مسبقا على هذا الاستفتاء");
											else
												alert("poller_please_select_an_option");
										   
										}
										
										else{
												
												$.post("poller.php", { poller_id: $("#poller_id").val(), choice: selected_choice },
														
														function(data){
																		
																		poller_res_array = data.split("|");
																		if(poller_res_array[0] != "" && poller_res_array[0] != "-")
																			alert(poller_res_array[0]);

																		if(typeof(poller_res_array[1]) != "undefined")
																			{
																				$('#poller-' + $("#poller_id").val()).html(poller_res_array[1]);
																				 animate_poller();
																				
																			}
																		

																	  });
											}
										
										
										   return false;
									} );
}



function AddToFavorite() {
		
		$.cookie("infobar_fpnp", true, { path: '/', expires: 365 });
		title = "شبكة فراس الإعلامية";
		url = "http://www.fpnp.net/ar/home";
		
		if (window.sidebar) { 
		return window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { 
		return window.external.AddFavorite( url, title); }
		else if(window.opera && window.print) {
		return true; }
		

				}
	
/*
if(!$.cookie("infobar_fpnp"))
{
		(function($) {
			$(function() {
				$.infoBar("اضغط هنا لإضافة هذا الموقع إلى مفضلتك",
					{ ID: "fpnp",cookie:false,zOrder:9999, type: $.infoBar.type.help}).click(function(){ AddToFavorite(); $(this).hide(); $('#add-to-fav-img').hide();});

			});
		})(jQuery);
}
*/