var doc=$(document);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:{'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);});});var msg,sd,st;function ive(s)
{return(s.indexOf(".")>2)&&(s.indexOf("@")>0);}
function se(v)
{v.style.backgroundColor="#FAA";}
function re(v)
{v.style.backgroundColor="#FFF";}
function ci(v)
{if((!v.value)||(v.value.length==0)){se(v);return false;}
re(v);return true;}
function showE()
{sd.fadeOut(200);msg.fadeIn(200);}
function showSd()
{msg.fadeOut(200);sd.fadeIn(200);}
function showSt()
{sd.fadeOut(200);st.fadeIn(200);}
window['sf']=function()
{msg=$("#msg");sd=$("#sending");st=$("#sent");sd.html("Sending e-mail...");st.html("E-mail sent successfully");var p=true;var d=document['details'];if(!ci(d['name'])){p=false;}
if((!ci(d['from']))||(!ive(d['from'].value))){se(d['from']);p=false;}
if(!ci(d['subject'])){p=false;}
if(!ci(d['message'])){p=false;}
if(p)
{var ds=$("#details").serialize();showSd();$.ajax({type:"post",url:"send.php",data:ds,success:function()
{showSt();window.setTimeout(function()
{d['from'].value="";d['name'].value="";d['subject'].value="";d['message'].value="";d['address'].value="";st.fadeOut(200);msg.fadeIn(200);if($.galleria)
{$.galleria.next();}
else
{home();}},2000);}});}};(function($){var tmbary=[],divarry=[],infos=[],index=0,_prew,count=0,_cent,_stopload=false;$$=$.fn.galleria=function(_thumbs){tmbary=[],divarry=[],index=0,_prew=null,count=0,_cent=0,_stopload=false;_mimage.siblings().andSelf().empty();_cent=_mimage.width()/2;_loadg.css({display:'block'});_proginner.css({width:0});var _x,_m=false,_d=false;var lis=_thumbs.find('.thumbd');var progressinterval=_prog.width()/lis.length;var lindex=0;var _scroll=_thumbs;var _count=lis.length;var showPageUpAndDown=function(){if(_count<16){_gcpageup.css("display","none");_gcpagedown.css("display","none");_scroll.scrollTop(0);}
else
{pos=_scroll.scrollTop();maxpos=_scroll[0].scrollHeight-240;if(pos>0){_gcpageup.css("display","block");}
else
{_gcpageup.css("display","none");}
if(pos>=maxpos){_gcpagedown.css("display","none");}
else
{_gcpagedown.css("display","block");}
_gcpagedown.unbind("click").bind("click",function(){_gcpageup.unbind("click");_gcpagedown.unbind("click");_scroll.stop().animate({"scrollTop":_scroll.scrollTop()+70},200,showPageUpAndDown);});_gcpageup.unbind("click").bind("click",function(){_gcpageup.unbind("click");_gcpagedown.unbind("click");_scroll.stop().animate({"scrollTop":_scroll.scrollTop()-70},200,showPageUpAndDown);});}};var ensureVisibleThumb=function(thumb){if(_count>16){position=thumb.parent().position();t=position.top;pos=_scroll.scrollTop();if(t<0){while(t<0){pos=pos-70;t=t+70;}
_gcpageup.unbind("click");_gcpagedown.unbind("click");_scroll.stop().animate({"scrollTop":pos},200,showPageUpAndDown);}
if(t>210){while(t>210){pos=pos+70;t=t-70;}
_gcpageup.unbind("click");_gcpagedown.unbind("click");_scroll.stop().animate({"scrollTop":pos},200,showPageUpAndDown);}}};showPageUpAndDown();var loaded=function(c,t,d,i,im){t.attr('imagetop',((_mimage.height()-im.height)/2)+"px");t.attr('imageleft',((_mimage.width()-im.width)/2)-15+"px");t.attr('imagewidth',im.width+"px");t.attr('imageheight',im.height+"px");var w=im.width/50;var h=im.height/50;tmbary[i]=t;t.ensureVisible=function(){ensureVisibleThumb(t);};var innerText=c.html();c.html("");divarry[i]=$("<div class='imageholder'></div>").append(d);if(innerText!=""){infos[i]=$("<span class='photoinfo'>"+innerText+"</span>");divarry[i].append(infos[i]);}
else
{infos[i]=false;}
t.click(function(e)
{$$.onPageLoad(i,false);});c.prepend(t);c.css({display:'block'});t.css({display:'block'});if(i==index)
{hideLoading();$$.onPageLoad(i,true);}
window.setTimeout(loadNext,10);t.css({height:0,width:0,top:35,left:35})
.animate({width:64,height:64,top:3,left:3},200,function()
{if(i!=index){t.animate({width:50,height:50,top:10,left:10},200);}});}
var loadNext=function(){if(lindex==lis.length)
{_loadg.css({display:'none'});return;}
if(_stopload)
{return;}
_proginner.width(progressinterval*lindex);var c=$(lis.get(lindex));lindex++;_ldetails.html("Loading "+lindex+" of "+lis.length);var s="gallery/"+c.attr('gsrc')+".jpg";var ts="gallery/t"+c.attr('gsrc')+".jpg";var t=$(new Image()),d=$(new Image());t.addClass('thumb');d.addClass('image');var i=count;t.load(function(){d.load(function(){loaded(c,t,d,i,this);})
.error(function(){window.setTimeout(loadNext,10);c.html('<span class="error" style="color:red">Error loading image: '+_src+'</span>');});d.attr('src',s);})
.error(function(){window.setTimeout(loadNext,10);c.html('<span class="error" style="color:red">Error loading image: '+_src+'</span>');});t.attr('src',ts);count++;};window.setTimeout(loadNext,10);window.setTimeout(loadNext,200);};$$.onPageLoad=function(_id,reload){close();hideHome();var _thumb;if(_id==-1)
{_thumb=null;}
else
{_thumb=tmbary[_id];}
if(_id!=index||reload)
{if(!reload)
{if(tmbary[index])
{var olddiv=divarry[index];tmbary[index].stop();tmbary[index].animate({width:50,height:50,top:10,left:10},100);olddiv.fadeOut(500,function()
{olddiv.remove();});}}
index=_id;if(_thumb)
{_thumb.stop();_thumb.animate({width:64,height:64,top:3,left:3},100);var _img=divarry[_id];_mimage.append(_img);var t=_thumb.attr('imagetop'),l=_thumb.attr('imageleft'),w=_thumb.attr('imagewidth'),h=_thumb.attr('imageheight');_img.css({'display':'none','top':t,'left':l,width:w,height:h}).fadeIn(500);_thumb.ensureVisible();}}};$.extend({galleria:{activate:function(_id){$$.onPageLoad(_id,false);},deselect:function(){$.galleria.pause();$$.onPageLoad(-1,false);},close:function(){_stopload=true;},next:function(){var ni=index+1;if(tmbary[ni])
{tmbary[ni].click();}},prev:function(){var ni=index-1;if(tmbary[ni])
{tmbary[ni].click();}},first:function(){tmbary[0].click();},last:function(){tmbary[tmbary.length-1].click();},play:function(){_gcplay.css('display','none');_gcpause.css('display','inline');var f=function(i){var ni=index+1;if(tmbary[ni])
{tmbary[ni].click();}
else
{tmbary[0].click();}};f(0);doc.everyTime(4000,"slideshow",f);},pause:function(){_gcpause.css('display','none');_gcplay.css('display','inline');doc.stopTime("slideshow");}}});})(jQuery);window['gfirst']=$.galleria.first;window['gprev']=$.galleria.prev;window['gplay']=$.galleria.play;window['gpause']=$.galleria.pause;window['gnext']=$.galleria.next;window['glast']=$.galleria.last;function start(d){if(IE6)
{_gc.css({width:163});}
var gal=d.find('.galload');gal.galleria(gal);gal.removeClass('galload');}
jQuery.extend(jQuery.easing,{'easeOutBounce':function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},'easeOutBack':function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;}});var IE6=(navigator.userAgent.indexOf("MSIE 6")>=0)?true:false;var _w,_b,_mid,_midl,_home,_homel,_wrap,_mimage,_gcpause,_gcplay,_gc,_loading,_bf,_gcpageup,_gcpagedown;var _loadg,_prog,_proginner,_ldetails,_last=false,_lastl=false,_about,_packages,_contact;var pages=[];function loadPage(href,dialogtype,callback){if(pages[href]!=undefined){callback(pages[href]);}
else
{var d=$(document.createElement('div'));d.load(href+"?ajax=true",function(){pages[href]=d;d.addClass(dialogtype);callback(d);});}}
function prepareGDialogs(el)
{var d=el.find(".gdialog");d.each(function(){var _this=$(this);_this.click(function(){doGDialog(this);return false;});});}
function prepareRDialogs(el)
{var d=el.find(".rdialog");d.each(function(){var _this=$(this);_this.click(function(){doDialog(this);return false;});});}
function showMenu(div,h)
{div.stop();div.css({'display':'block'}).animate({height:h},700,'easeOutBounce');}
function hideMenu(div)
{div.stop();div.animate({height:0},150,function(){div.css({'display':'none'});});}
function prepareMenus(el)
{var d=el.find(".menulink");d.each(function(){var _this=$(this);var _div=_this.find(".menu");var h=_div.height(),w=_div.width();var e=$(document.createElement('div')).addClass('menuinner');var f=$(document.createElement('div')).addClass('menuback');e.css({width:w,height:h});_div.wrapInner(e);f.css({opacity:0.9,width:w,height:h});_div.prepend(f);_this.mouseenter(function(){showMenu(_div,h);return false;});_this.mouseleave(function(){hideMenu(_div);return false;});_div.css({height:0,width:w});});}
var uid=0;function getNextId()
{return"id"+(uid++);}
function hideLoading()
{_loading.css({display:'none'});_bf.css({display:'none'});}
function loading()
{_loading.css({'display':'block'});_bf.css({'opacity':'0','display':'block'});if(IE6)
{_bf.width(_w.width());_bf.height(_w.height());}}
function hideHome()
{_home.stop().animate({left:1000},1000,function(){_home.css({display:'none'});});}
function hideGallery()
{if($.galleria)
{$.galleria.deselect();}}
function loadRight(_href)
{if(pages[_href]==undefined||pages[_href]!=_last){loading();close();hideGallery();hideHome();loadPage(_href,"adialog",function(d){_last=d;d.width(500);d.height(400);prepareRDialogs(d);_mid.prepend(d);d.css({left:1000,display:'block'}).animate({left:0},1000,"easeOutBack");hideLoading();});}}
function loadLeft(_href)
{if(_lastl!=_href){loading();closeGallery();closeLeft();var d=$(document.createElement('div'));d.addClass("aldialog");d.load(_href+"?ajax=true",function(){_lastl=_href;width=400;height=400;d.width(400);d.height(400);_midl.prepend(d);d.css({left:0,display:'block'});_homel.stop().animate({left:-1000},1000,function(){_homel.css({display:'none'});});start(d);});}}
function doDialog(element)
{loadRight(element.getAttribute('href'));}
function closeGallery()
{if($.galleria)
{$.galleria.close();hideGallery();}}
function doGDialog(element)
{loadLeft(element.getAttribute('href'));}
function close()
{if(_last)
{var _o=_last;_last.stop().animate({left:1000},function(){_o.css({display:'none'});});}
_last=false;}
function closeLeft()
{$(".aldialog").stop().animate({left:-1000},function(){$(this).remove();});}
function home()
{var ald=$(".aldialog");loadRight("index.php");_homel.stop().css({display:'block'}).animate({left:0},1000,"easeOutBack",function(){ald.remove();});_lastl=false;}
doc.ready(function(){_w=$(window);_b=$("body");_mid=$("#frontr");_midl=$("#frontl");_home=$("#home");_homel=$("#homel");_wrap=$("#wrapper");_mimage=$("#main_image");_gcpause=$("#gcpause");_gcplay=$("#gcplay");_gcpageup=$("#gcpageup");_gcpagedown=$("#gcpagedown");_gc=$("#gal_control");_loading=$("#loading");_bf=$("#backfade");_loadg=$('#loadgallery');_prog=$('#progress');_proginner=$('#progressinner');_ldetails=$('#ldetails');if(IE6)
{document.execCommand("BackgroundImageCache",false,true);}
$("*").each(function(){$(this)[0].oncontextmenu=function()
{return false;};});});$(window).load(function(){$(".flink").each(function(e){_flink=$(this);var _flinki=_flink.children(".flinki");_flink.bind("mouseenter",(function(e){_flinki.stop();_flinki.css({display:'block'}).animate({fontSize:'30px',opacity:1},200,"swing",function(){if(jQuery.browser.msie){_flinki.get(0).style.removeAttribute('filter');}});}));_flink.bind("mouseleave",(function(e){_flinki.stop();_flinki.animate({fontSize:'1px',opacity:0},200,"swing",function(){_flinki.css({fontSize:'1px',display:'none'});});}));});_last=$(".rpage");if("undefined"!=typeof(lpage)){pages[lpage]=_last;}
if($(".aldialog").length>0)
{start($(".aldialog"));_lastl=lpage;_homel.css("left",-1000);}
prepareGDialogs(doc);prepareRDialogs(doc);var d=doc.find(".home");d.each(function(){var _this=$(this);_this.click(function(){home();return false;});});prepareMenus(doc);hideLoading();});
