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 slides = [];


		var contents = [];


		var loadedImages = false;


		var btns = false;


		var btns_fx = false;


		var show_btns = false;


		var hovers = false;


		var hovers_fx = false;


		


		if(window.webkit){


			$E('.gk_is_content',wrapper).setStyles({"margin-left":0,"margin-right":0});


		}


		


		$E('.gk_is_content',wrapper).setStyle('overflow',"hidden");


		$E('.gk_is_content',wrapper).setStyle('height',wrapper.getSize().size.y+"px");


		$ES('.gk_is_art').removeClass('gk_unvisible');


		


		$ES('.gk_is_art',wrapper).setOpacity(0);


		$E('.gk_is_art',wrapper).setOpacity(1);


		


		switch($G['anim_type']){


			case 'opacity': break;


			case 'top': 


				$ES('.gk_is_art',wrapper).setStyle('margin-top',(-1) * wrapper.getSize().size.y);


				$E('.gk_is_art',wrapper).setStyle('margin-top',0);


			break;		


			case 'bottom':  


				$ES('.gk_is_art',wrapper).setStyle('margin-top', wrapper.getSize().size.y);


				$E('.gk_is_art',wrapper).setStyle('margin-top', 0);


			break;	


		}





		if($E('.gk_is_prev',wrapper)) {


			btns = [$E('.gk_is_prev',wrapper),$E('.gk_is_next',wrapper)];


			hovers = [$E('.gk_is_prev div',wrapper), $E('.gk_is_next div',wrapper)];


			btns_fx = [new Fx.Opacity(btns[0],{duration:350}),new Fx.Opacity(btns[1],{duration:350})];


			hovers[0].setStyle("display","block");


			hovers[1].setStyle("display","block");


			hovers_fx = [new Fx.Opacity(hovers[0],{duration:200}).set(0),new Fx.Opacity(hovers[1],{duration:200}).set(0)];


			btns[0].addEvent("mouseenter", function(){hovers_fx[0].start(1);});


			btns[0].addEvent("mouseleave", function(){hovers_fx[0].start(0);});


			btns[1].addEvent("mouseenter", function(){hovers_fx[1].start(1);});


			btns[1].addEvent("mouseleave", function(){hovers_fx[1].start(0);});


			


			if(window.getWidth() < wrapper.getSize().size.x + 80){


				btns[0].setStyles({'left': '10px', 'z-index' : 100});


				btns[1].setStyles({'right': '10px','z-index' : 100});


			}


		}


		


		var imagesToLoad = [];


		


		if(btns && btns[0].hasClass('anim')){


			btns_fx[0].set(0);


			btns_fx[1].set(0);


			


			wrapper.addEvent("mousemove",function(){


				show_btns = true


			});


			


			[$E('.gk_is_prev',wrapper), $E('.gk_is_next',wrapper), wrapper].each(function(el){


				el.addEvent("mouseenter", function(){


					show_btns = true;


					btns_fx[0].start(1);	


					btns_fx[1].start(1);	


				});	


			});


			


			[$E('.gk_is_prev',wrapper), $E('.gk_is_next',wrapper), wrapper].each(function(el){


				el.addEvent("mouseleave", function(){


					show_btns = false;


					(function(){


						if(show_btns == false){


							btns_fx[0].start(0);


							btns_fx[1].start(0);


						}


					}).delay(1000);


				});


			});


		}


				


		$ES('.gk_is_slide', wrapper).each(function(el,i){


			var newImg = new Element('img',{


				"title":el.getProperty('title'),


				"class":el.getProperty('class'),


				"style":el.getProperty('style')


			});


			


			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);


				


				wrapper.getElementsBySelector(".gk_is_slide").each(function(elmt,i){


					slides[i] = elmt;


				});


				


				slides.each(function(el,i){


					if(i != 0) 


						el.setOpacity(0);


				});


				


				$G['actual_slide'] = 0;


				


				if($E('.gk_is_list',wrapper)) $ES('.gk_is_list ul li',wrapper)[0].setProperty("class", "active");


				


				if($G['autoanimation']){


					$G['actual_animation'] = (function(){


						gk_is_style1_anim(wrapper, contents, slides, $G['actual_slide']+1, $G);


					}).periodical($G['anim_interval']+$G['anim_speed']);


				}


				


				if(btns){


					btns[0].addEvent("click", function(){


						$clear($G['actual_animation']);


						


						gk_is_style1_anim(wrapper, contents, slides, $G['actual_slide']-1, $G);


						


						if($G['autoanimation']){


							$G['actual_animation'] = (function(){


								gk_is_style1_anim(wrapper, contents, slides, $G['actual_slide']+1, $G);


							}).periodical($G['anim_interval']+$G['anim_speed']);


						}


					});


					


					btns[1].addEvent("click", function(){


						$clear($G['actual_animation']);


						


						gk_is_style1_anim(wrapper, contents, slides, $G['actual_slide']+1, $G);


						


						if($G['autoanimation']){


							$G['actual_animation'] = (function(){


								gk_is_style1_anim(wrapper, contents, slides, $G['actual_slide']+1, $G);


							}).periodical($G['anim_interval']+$G['anim_speed']);						


						}


					});


				}


				


				if($E('.gk_is_list',wrapper)){


					$ES('.gk_is_list li',wrapper).each(function(el,i){


						el.addEvent("click", function(){


							$clear($G['actual_animation']);


							gk_is_style1_anim(wrapper, contents, slides, i, $G);


							


							if($G['autoanimation']){


								$G['actual_animation'] = (function(){


									gk_is_style1_anim(wrapper, contents, slides, $G['actual_slide']+1, $G);


								}).periodical($G['anim_interval']+$G['anim_speed']);


							}


						});	


					});


				}


			}


		}).periodical(250);


	});


});





function gk_is_style1_anim(wrapper, contents, slides, which, $G){


	if(which != $G['actual_slide']){


		var max = slides.length-1;


		if(which > max) which = 0;


		if(which < 0) which = max;


		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);	


		var text_fx1 = new Fx.Opacity($ES('.gk_is_art',wrapper)[actual],{duration: $G['anim_speed'] / 2});


		var text_fx2 = new Fx.Opacity($ES('.gk_is_art',wrapper)[which],{duration: $G['anim_speed'] / 2});


		text_fx1.start(1,0);


		text_fx2.start(0,1);


		


		switch($G['anim_type']){


				case 'opacity': break;


				case 'top': new Fx.Style($ES('.gk_is_art',wrapper)[actual],'margin-top',{duration: 0.25 * $G['anim_speed'], transitions:Fx.Transitions.Circ.easeOut}).start(0, wrapper.getSize().size.y);break;


				case 'bottom': new Fx.Style($ES('.gk_is_art',wrapper)[actual],'margin-top',{duration: 0.25 * $G['anim_speed'], transitions:Fx.Transitions.Circ.easeOut}).start(0, (-1) * wrapper.getSize().size.y);break;


		}


			


			//if(Cufon) Cufon.refresh('.gk_is_art h4');


			switch($G['anim_type']){


				case 'opacity': break;


				case 'top': new Fx.Style($ES('.gk_is_art',wrapper)[which],'margin-top',{duration: 0.75 * ($G['anim_speed']), transitions:Fx.Transitions.Circ.easeOut}).start((-1)*wrapper.getSize().size.y,0);break;


				case 'bottom': new Fx.Style($ES('.gk_is_art',wrapper)[which],'margin-top',{duration: 0.75 * ($G['anim_speed']), transitions:Fx.Transitions.Circ.easeOut}).start(wrapper.getSize().size.y,0);break;


			}


			text_fx1.start(0,1);


	


		


		if($E('.gk_is_list',wrapper)){


			$ES('.gk_is_list ul li',wrapper).setProperty("class", "");


			$ES('.gk_is_list ul li',wrapper)[which].setProperty("class", "active");


		}


		


		(function(){slides[$G['actual_slide']].setStyle("z-index",$G['actual_slide']);}).delay($G['anim_speed']);


	}


}
