/*
Javascript function HASHes
copyright mountain studio 2007 and gotire 2007


gotire

*/

/*****************************************************************/
var ajx = {
	sendmail : function(){
		new Ajax.Updater('section_contact', 'library/ajax/ajax_send.php',
					{parameters:	{
								nom:$('nom').value,
								prenom:$('prenom').value,
								email:$('email').value,
								sujet:$('sujet').value,
								message1:$('message1').value
								},
					evalScripts: true
					//onComplete:function(data){feedback.fade()},
					//OnFailure:function(){feedback.fail('Error with your request');
					});
	
	}
};


var homepage = {
	
	init:function(){
		allLinks = $$('.homelinks');
		allInfos = $$('.infos');
		allLinks.each(function(e){
			e.observe('click',function(evt) {homepage.show(this.id) });					   
							   
		});
	
		this.show('qui');
	},
	
	show:function(id){
		contentID = "info_"+id;
		imgID = "section_"+id;
		allInfos.invoke('hide');
		Effect.Appear(contentID);
		Effect.Appear(imgID);
		//active the menu

		allLinks.each(function(e){
			e.removeClassName('active');
		});
		$(id).addClassName('active');


	}
	
}

var folio = {
	
	init:function(){
		allLinks= $$('.folionav1');	
		noItems = allLinks.length;
		currentVisible = 0;
		allFolio= $$('.folioimg1');	
		this.links();
		this.showFirst();
		
		//navPage from PHP to javascript transfer in header1.php
		$(navPage).addClassName('active');
		
	},
	
	links:function(){
		allLinks.each(function(e){
			e.observe('click',function(evt) {folio.show(this.id) });					   
							   
		});
	nextNav = 	$('next1');
	nextNav.observe('click',function(evt) {folio.next() });
	prevtNav = 	$('prev1');
	prevtNav.observe('click',function(evt) {folio.prev() });

	allFolio.each(function(e){
		e.observe('click',function(evt) {folio.next() });					   
						   
	});

	},
	
	
	show:function(id){
		allFolio.invoke('hide');
		folio_id = "top_"+id.split("_")[2];
		Effect.Appear(folio_id);
		
		this.activeMenu(id.split("_")[2]);
		currentVisible = id.split("_")[2];
		
	},
	
	activeMenu:function(id){

		allLinks.each(function(e){
			e.removeClassName('active');
		});
		$('menu_content_'+id).addClassName('active');
		
	},
	
	showFirst:function(){
		
		this.show(allLinks.first().id);
		currentVisible = 1;
		
	},
	
	next:function(){
		var gotoID = 0;
		if(currentVisible>=noItems){
			gotoID =1;
		} else {
			gotoID =  parseInt(currentVisible)+1;
			
		}
		this.show("menu_content_"+gotoID);
		console.log("goto:"+gotoID);
		
	},

	prev:function(){
		var gotoID = 0;
		if(currentVisible==1){
			gotoID =noItems;
		} else {
			gotoID =  parseInt(currentVisible)-1;
			
		}
		this.show("menu_content_"+gotoID);
		console.log("goto:"+gotoID);
		
	}

	
	
}



/*****************************************************************/



function clickclear(thisfield, defaulttext) {
		if (thisfield.value == defaulttext) {
		thisfield.value = "";
		}
		}
		
		function clickrecall(thisfield, defaulttext) {
		if (thisfield.value == "") {
		thisfield.value = defaulttext;
		}
}

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];}
}