﻿function findPosX(obj){
	var curleft=0
	if(obj.offsetParent)
		while(1){
			curleft+=obj.offsetLeft
			if(!obj.offsetParent)
				break;
			obj=obj.offsetParent
		}
	else if(obj.x)
		curleft+=obj.x
	return curleft
}
window.addEvent('domready', function() {
	/* Js fix for IE+, body missalign bug */
	if(navigator.appName == "Microsoft Internet Explorer"){
		var a=findPosX($('imenu_first'));
		$('body_inner').style.padding="0"
		$('body_inner').style.position="absolute"
		$('body_inner').style.zIndex="30"
		$('body_inner').style.left=parseInt(a-6)+"px"
	}
	/* Slider */
	if($('contact_inner')){
		var myVerticalSlide = new Fx.Slide('contact_inner').hide();
		$('v_toggle').addEvent('click', function(e){
			e.stop();
			myVerticalSlide.toggle();
		});
		myVerticalSlide.addEvent('complete', function() {
			$('contact_inner').set('display',"block");
		});
	}
	/* Accordion effect */
	var myAccordion = new Accordion($('accordion'), 'h2.box_title', 'div.element', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', 'black');
			toggler.setStyle('border-top','0');
			toggler.setStyle('background','#fed40b');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', 'black');
			toggler.setStyle('border-top','1px solid #fed40b');
			toggler.setStyle('background','transparent');
		}
	});
	if($('previous'))
	{
		var totIncrement		= 0;
		var increment			= 413;
		var items               = 4; // The number of items
		var maxRightIncrement	= increment*(-1);
		var fx = new Fx.Tween('slider-list',{
				property: 'margin-left',
				duration: 750,
				transition: Fx.Transitions.Sine.easeOut
		});
		$('previous').addEvents({ 
		  'click' : function(event){ 
		  if(totIncrement<0){
					totIncrement = totIncrement+increment;
					event.stop()
					fx.start(totIncrement);
				}
			}
		});
		$('next').addEvents({ 
		  'click' : function(event){ 
			 if(totIncrement>maxRightIncrement){
				event.stop()
				totIncrement = totIncrement-increment;
				fx.start(totIncrement);
			}
		  }
		});
	}
	/* SIFR 
	var din = { src: 'script/din.swf' };
	sIFR.activate(din);

	sIFR.replace(din, {
	  selector: '#imenu li a .title',  forceSingleLine: true, 
	  wmode:'transparent',
	  css: '.sIFR-root { color:#333333; font-size:18px; }'
	});
	*/
});