
/* FILE# 1 /media/system/js/mootools.js */

/* FILE# 2 /media/system/js/caption.js */

/* FILE# 3 /plugins/system/target_blank.js */
//add Events to window and anchors
function makeEventHandler(o,e,fn)
  {
  if(o.addEventListener)
    o.addEventListener(e, fn, true);
  else if(o.attachEvent)
    o.attachEvent('on'+e, fn);
  }


//initialise
function initAnchors()
  {
  
  if(!document.getElementsByTagName)return;   //let it be, won't work anyway

  aArr = document.getElementsByTagName('a');

  for(i=0;i<aArr.length;i++)
    if(aArr[i].getAttribute('href')&& aArr[i].getAttribute('rel') == 'extern')
      {
      //target_blank
      aArr[i].target = '_blank';
      //count makeEventHandler(aArr[i],'click',countClick)
      }
  }

//now it counts
/*
function countClick(evt)
  {
  evt = (evt) ? evt : ((window.event) ? window.event : '');
  elem = (evt.target) ? evt.target : evt.srcElement;
  ctImg = new Image();
  now = new Date();
  nowStr=now.getFullYear()+'-'+now.getMonth()+'-'+now.getDate();
  src = "link_ext.php?link="+encodeURIComponent(elem.href)+"&page="+encodeURIComponent(document.location)+"&date="+nowStr;
  ctImg.src=src;
  //document.location.href=src;
  return true;
  }
*/

makeEventHandler(window,'load',initAnchors);
/* FILE# 4 /modules/mod_gk_image_show/js/style2/engine.js */
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-style2").each(function(el){
		var elID = el.getProperty("id");
		var wrapper = $(elID);
		var $G = $Gavick[elID];
		var opacity = $G['text_block_opacity'];
		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);
				
				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);
						
					slides.each(function(elmts){
						elmts.addEvent("mouseenter", function(){})
					});
				});
				
				$G['actual_slide'] = 0;
				
				if($G['autoanim']){
					$G['actual_animation'] = (function(){
						gk_is_style2_anim(wrapper, contents, slides, $G['actual_slide']+1, $G);
					}).periodical($G['anim_interval']+$G['anim_speed']);
				}
				
				if($E('.gk_is_overlay', wrapper)){
					var overlay = $E('.gk_is_overlay', wrapper);
					var fx = new Fx.Opacity(overlay,{duration:$G['overlay_speed'], wait:true});
					overlay.setStyle("display", "block");
					overlay.setOpacity(0);
					wrapper.addEvent("mouseenter", function(){
						fx.start($G['overlay_opacity']);
					});
					wrapper.addEvent("mouseleave", function(){
						fx.start(0);
					});
					overlay.addEvent("click", function(){
						window.location = overlay.getProperty("title");
					});
					overlay.setProperty("title", slides[0].getProperty("alt"));
				}
			}
		}).periodical(250);
	});
});

function gk_is_style2_anim(wrapper, contents, slides, 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_overlay', wrapper)) $E('.gk_is_overlay', wrapper).setProperty("title", slides[which].getProperty("alt"));
		
		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;
		}
	
		(function(){slides[$G['actual_slide']].setStyle("z-index",$G['actual_slide']);}).delay($G['anim_speed']);
		
		
	}
}
/* FILE# 5 /templates/gk_pulse/lib/scripts/template_scripts.js */
/*--------------------------------------------------------------
# Pulse - October 2009 (for Joomla 1.5)
# Copyright (C) 2007-2009 Gavick.com. All Rights Reserved.
# License: Copyrighted Commercial Software
# Website: http://www.gavick.com
# Support: support@gavick.com  
---------------------------------------------------------------*/

window.addEvent("load",function(){
	var $b = $(document.getElementsByTagName('body')[0]);
	// smoothscroll init
	new SmoothScroll();
	// animation classes - Fx.Height and Fx.Opacity
	Fx.Height = Fx.Style.extend({initialize: function(el, options){this.parent(el, 'height', options);this.element.setStyle('overflow', 'hidden');},toggle: function(){return (this.element.offsetHeight > 0) ? this.custom(this.element.offsetHeight, 0) : this.custom(0, this.element.scrollHeight);},show: function(){return this.set(this.element.scrollHeight);}});
	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);}});
	//
	if($('stylearea')){
		$A($$('.style_switcher')).each(function(element,index){
			element.addEvent('click',function(event){
				var event = new Event(event);
				event.preventDefault();
				changeStyle(index+1);
			});
		});
		$A($$('.bg_switcher')).each(function(element,index){
			element.addEvent('click',function(event){
				var event = new Event(event);
				event.preventDefault();
				changeBg(index);
			});
		});
		new SmoothScroll();
	}
	//
	if($('login')) $('login').addEvent("click",function(e){new Event(e).stop();
		gk_popup('popup_login',600,80);
	});
	
	if($('login_noborder')) $('login_noborder').addEvent("click",function(e){new Event(e).stop();
		gk_popup('popup_login',600,80);
	});
	
	if($('register')) $('register').addEvent("click",function(e){new Event(e).stop();
		gk_popup('popup_register',500,300);
	});
	//
	// users_wrap I
	//
	if($ES('.users_wrap')[0]){
		if($ES('.moduletable_content', $ES('.users_wrap')[0]).length > 0){
			var max = 0;
			$ES('.moduletable_content', $ES('.users_wrap')[0]).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	
			$ES('.moduletable_content', $ES('.users_wrap')[0]).each(function(el){ el.setStyle("height", max+"px"); });	
		}		
	}
	// users_wrap II
	if($ES('.users_wrap')[1]){
		if($ES('.moduletable_content', $ES('.users_wrap')[1]).length > 0){
			var max = 0;
			$ES('.moduletable_content', $ES('.users_wrap')[1]).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	
			$ES('.moduletable_content', $ES('.users_wrap')[1]).each(function(el){ el.setStyle("height", max+"px"); });	
		}			
	}
	// users_wrap III
	if($('bottom1')){
		if($ES('.moduletable_content', $('bottom1')).length > 0){
			var max = 0;
			$ES('.moduletable_content', $('bottom1')).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });
			$ES('.moduletable_content', $('bottom1')).each(function(el){ el.setStyle("height", max+"px"); });	
		}			
	}

});

function gk_popup(popup_id, x, y){
	var p = $(popup_id);
 	var overlay = $('gk_overlay');
 	overlay.setStyle("display","block");
 	var overlay_o = new Fx.Opacity(overlay,{duration:300}).set(0);
 
	if(p.getStyle("display") != "block"){
		p.setStyle("display","block");
		p.setStyle("left",((window.getSize().size.x - 40 - x) / 2)+"px");
	  
		var fintop = ((window.getSize().size.y - 40 - y) / 2);
	  
		if(window.opera) p.setStyle("top","50px");
		if(window.opera) fintop = 50;
		
		new Fx.Style(p,'top',{duration:350}).start(0,fintop);
		
		new Fx.Opacity(p,{duration:350}).start(1);
		overlay_o.start(0.7);
		p.setStyles({
			"width":x+40+"px",
			"height":y+40+"px"
		}); 
		
		new Fx.Style($E('.gkp_t',p),'width',{duration:350}).start(0,x);
		new Fx.Style($E('.gkp_b',p),'width',{duration:350}).start(0,x);
		new Fx.Style($E('.gkp_m',p),'width',{duration:350}).start(0,x);
		
		new Fx.Style($E('.gkp_m',p),'height',{duration:350}).start(0,y);
		new Fx.Style($E('.gkp_ml',p),'height',{duration:350}).start(0,y);
		new Fx.Style($E('.gkp_mr',p),'height',{duration:350}).start(0,y);
		
		$E('.gk_popup_close',p).setStyle("opacity",0);
		(function(){new Fx.Opacity($E('.gk_popup_close',p),{duration:350}).start(1);}).delay(350);
		
		$E('.popup_padding',p).setStyle('opacity',0);
		(function(){new Fx.Opacity($E('.popup_padding',p),{duration:350}).start(0,1);}).delay(350);
		
		$E('.gk_popup_close',p).onclick = function(){
			new Fx.Opacity($E('.gk_popup_close',p),{duration:350}).start(0);
			new Fx.Opacity($E('.popup_padding',p),{duration:350}).start(0);
			overlay_o.start(0);
			(function(){
				new Fx.Opacity(p, {duration:350}).start(0);
				new Fx.Style(p, 'top',{duration:350}).start(fintop, 0);
				new Fx.Style($E('.gkp_t', p),'width',{duration:350}).start(x, 0);
				new Fx.Style($E('.gkp_b', p),'width',{duration:350}).start(x, 0);
				new Fx.Style($E('.gkp_m', p),'width',{duration:350}).start(x, 0);
				
				new Fx.Style($E('.gkp_m', p),'height',{duration:350}).start(y, 0);
				new Fx.Style($E('.gkp_ml', p),'height',{duration:350}).start(y, 0);
				new Fx.Style($E('.gkp_mr', p),'height',{duration:350}).start(y, 0);
				
				(function(){
				 	p.setStyle("display","none");
				}).delay(350);
			}).delay(350); 
		};
	}
}
// Function to change backgrounds
function changeStyle(style){
	var file = $template_path+'/css/style'+style+'.css';
	new Asset.css(file);
	new Cookie.set('gk30_style',style,{duration: 200,path: "/"});
}
function changeBg(style){
	var file = $template_path+'/css/'+((style == 1) ? 'dark' : 'white')+'.css';
	new Asset.css(file);
	new Cookie.set('gk30_bg',(style == 1) ? 'dark' : 'white',{duration: 200,path: "/"});
}