// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




var Site = {
	
	start: function(){
		
		if ($('feature')) Site.parseFeatures();
		
		if ($('download')) Download.start();
		
		if ($('sidebar')){
			Site.appearText();
			if (!window.ie6) Site.makeShadow();
		}
	},
	
	parseFeatures: function(){
		var features = $$('#feature .feature');
		var fx = new Fx.Elements(features, {wait: false, duration: 300, transition: Fx.Transitions.quadOut});
		features.each(function(feature, i){
			feature.addEvent('mouseenter', function(e){
				var obj = {};
				obj[i] = {
					'width': [feature.getStyle('width').toInt(), 360]
				};
				features.each(function(other, j){
					if (other != feature){
						var w = other.getStyle('width').toInt();
						if (w != 200) obj[j] = {'width': [w, 200]};
					}
				});
				fx.start(obj);
			});
		});
		
		$('feature').addEvent('mouseleave', function(e){
			var obj = {};
			features.each(function(other, j){
				obj[j] = {'width': [other.getStyle('width').toInt(), 210]};
			});
			fx.start(obj);
		});
	},
	
	appearText: function(){
		var timer = 0;
		var sideblocks = $$('#sidebar li');
		
		var slidefxs = [];
		var colorfxs = [];
		
		sideblocks.each(function(el, i){
			el.setStyle('margin-left', '-155px');
			timer += 150;
			slidefxs[i] = new Fx.Style(el, 'margin-left', {
				duration: 400,
				transition: Fx.Transitions.backOut,
				wait: false,
				onComplete: Site.createOver.pass([el, i])
			});
			slidefxs[i].start.delay(timer, slidefxs[i], 0);

		}, this);
	},
	
	createOver: function(el, i){
		var first = el.getFirst();
		if (!first || first.getTag() != 'a') return;
		var overfxs = new Fx.Styles(first, {'duration': 200, 'wait': false});
		var tocolor, fromcolor;
		if (first.hasClass('big')){
			tocolor = '333';
			fromcolor = 'fff';
		} else {
			tocolor = 'faec8f';
			fromcolor = '595965';
		}
		el.mouseouted = true;
		el.addEvent('mouseenter', function(e){
			overfxs.start({
				'color': tocolor,
				'margin-left': 10
			});
		});
		el.addEvent('mouseleave', function(e){
			overfxs.start({
				'color': fromcolor,
				'margin-left': 0
			});
		});
	},
	
	makeShadow: function(){
		new Element('img').injectInside('container').setStyles({
			'position': 'absolute', 'top': '0', 'margin-top': '-30px', 'left': '644px', 'z-index': '999999'
		}).setProperties({
			'height': $('sidebar').offsetHeight + 70, 'width': '10', 'src': '/assets/images/menubig_shadow.png'
		});
	}
	



};

window.addEvent('domready', function() {
	// HERE IS WHAT YOU READ IN JS CODE


/*
var list = $$('#topnavlist li a');
list.each(function(element) {
 
	var fxList = new Fx.Styles(element, {duration:200, wait:false});
 
	element.addEvent('mouseenter', function(){
		fxList.start({
			'margin-left': 5,
			'margin-right': 5,
			'color': '#564330'
		});
	});
 
	element.addEvent('mouseleave', function(){
		fxList.start({
			'margin-left': 0,
			'margin-right': 0,
			'color': '#598BC1'
		});
	});
 
});
*/

//var myEffects = $('main').effects({duration: 1000, transition: Fx.Transitions.Sine.easeInOut});
//myEffects.start({'margin-top': [-1500, 0]});


//var myEffects_2 = $('topnav').effects({duration: 1500, transition: Fx.Transitions.Sine.easeInOut});
//myEffects_2.start({'margin-top': [-1500, 0]});


var myEffects_3 = $('getintouch').effects({duration: 3000, transition: Fx.Transitions.Sine.easeInOut});
myEffects_3.start({'margin-top': [-1000, -30]});



 
$('getintouch').addEvent('click', function(e){
	e = new Event(e);
window.location.href='index.php?id=17';

	e.stop();
});
 
 
 
//hide / show contact area
/* */
var mySlideClientLogin = new Fx.Slide('clientlogin');

mySlideClientLogin.hide();
	
$('slideout_2').addEvent('click', function(e){
	e = new Event(e);
	mySlideClientLogin.slideOut();
	e.stop();
});
 
$('toggle_2').addEvent('click', function(e){
	e = new Event(e);
	mySlideClientLogin.toggle();
	//mySlide.slideOut();
	e.stop();
});

 
 
 //hide/show contact flag reminder
 var fadeout_2 = new Fx.Style($('getintouch'), 'opacity', {duration: 400}).set(1);

 	$('header').addEvent('mouseleave', function(){
 		$('getintouch').setStyle('visibility', 'visible');
 		fadeout_2.start(1,0);
 	});
	$('header').addEvent('mouseenter', function(){
 		$('getintouch').setStyle('visibility', 'hidden');
 		fadeout_2.start(0,1);
 	});
 
 


//fade in of feature images

 
var listRollover = $$('#feature li a div');
listRollover.each(function(element) {
 
	var fxFade = new Fx.Styles(element, {duration:200, wait:false});
 	fxFade.start({			'opacity': 0.001		});
	
	element.addEvent('mouseenter', function(){
		fxFade.start({
			'opacity': 1
		});
	});
 
	element.addEvent('mouseleave', function(){
		fxFade.start({
			'opacity': 0.001
		});
	});
 
});




});



function submitform(theForm){
		document.clientloginform.action = 'index.php?id=35';
		document.clientloginform.submit();
	}


window.addEvent('load', Site.start);