//codemoutain.ca  copyrights 2008
// version 2.0 - pimiento custom functions for Pimiento.ca website


var sections = {

	show:function(id){
		sections.hideall();
		$("presse-"+id+"_content").show();
		presse.goto(id,1);
		
		sections.resetlinks();
		$("presse-"+id+"-link").className="presse2";
		
	},
	
	resetlinks:function(){
		
		var links = $$('.presse2'); 
		
		links.each(function(linkID){
			$(linkID.id).className="";	
		});
	},
	
	hideall:function(){
		$$('.top_sections').invoke('hide');
		
	}
	
}


var projet = {

	show:function(id){
		projet.hideall();
		$("projet_"+id).show();
		
		projet.resetmenu();
		if(id!=8){
			projet.video(id);
		} else {
			projet.photo(1,8);
			$$('.vidtitle').invoke('hide');
		}	
		$("projetmenu_"+id).className = "projetmenu2";
	},

	resetmenu:function(){
		
		var links = $$('.projetmenu2'); 
		
		links.each(function(linkID){
			$(linkID.id).className="projetmenu1";	
		});
	},

	hideall:function(){
		$$('.projet_sections').invoke('hide');
		
	},
	
	video:function(projetID){
		
		$("container_photo"+projetID).hide();
		projet.setbox("video",projetID);
		$("video"+projetID).show();
		$$('.vidtitle').invoke('show');
		$("vidlink_"+projetID).className = "bright";
		$("photolink_"+projetID).className = "";
		projet.resetlinks();
		
	},
	
	photo:function(photoID, projetID){

		$("video"+projetID).hide();
		projet.setbox("photo",projetID);
		$("container_photo"+projetID).show();
		
		projet.hidephotos(projetID);
		
		$("photo_"+projetID+"_"+photoID).show();
		
		$("photolink_"+projetID).className = "bright2";
		$("vidlink_"+projetID).className = "";
		
		projet.resetlinks();
		$("photolink_"+photoID+"_"+projetID).className="lightlink2";
		//console.log($("photolink_"+photoID+"_"+projetID));
	},
	
	hidephotos:function(projetID){
		
		$$('.photo1').invoke('hide');
		
	},
	
	resetlinks:function(){
		
		var links = $$('.lightlink2'); 
		
		links.each(function(linkID){
			$(linkID.id).className="lightlink";	
		});
	},
	
	setbox:function(typeID, boxID){
	
	if(typeID=="photo"){
		$("container_video"+boxID).style.height="200px";
		}
	
	if(typeID=="video"){
		$("container_video"+boxID).style.height="250px";
			
		}
	}
	
}

var bio = {

	show:function(id){
		bio.hideall();
		Effect.Appear("bio_"+id);
		
		bio.resetmenu();
		$("biomenu_"+id).className="biomenu2";
		
	},
	
	resetmenu:function(){
		
		var links = $$('.biomenu2'); 
		
		links.each(function(linkID){
			$(linkID.id).className="biomenu1";	
		});
	},
	
	hideall:function(){
		$$('.bio_sections').invoke('hide');
		
	}
	
}


current_comm = 0;
current_dossier = 1;
current_bio = 2;
current_photo = 3;
current_img = 4;

var current = new Array();
var totalpages = new Array();
current = [1,1,1,1,1];
totalpages = [1,1,1,1,1];

var presse = {
	
	goto:function(type,id){
		presse.hideall();
		section = "presse-"+type+"_content_"+id;
		Effect.Appear(section);
		currentName = String("current_"+type);
		currentNumber = window[currentName];
		
		
		
		//set link styles
		if(totalpages[currentNumber]>=2){
			linkid = "link-"+type+"-"+current[currentNumber];
			//console.log("linkid = "+linkid);
			$(linkid).className = "";
			
			current[currentNumber] = id;
			
			linkid = "link-"+type+"-"+current[currentNumber];
			$(linkid).className = "currentpage";
		}
		//alert("current = "+current[currentNumber]+"  of total"+totalpages[currentNumber]);
		
	},
	
	next:function(type){
		goto_number = 1;
		
		currentName = String("current_"+type);
		currentNumber = window[currentName];
		
		//alert("total pages = "+totalpages[currentNumber]+" current number = "+current[currentNumber]);
		
		if(current[currentNumber]>=totalpages[currentNumber]) {
			presse.goto(type, goto_number);	
		} else {
			goto_number = current[currentNumber] + 1;
			presse.goto(type, goto_number);	
		}
		
		
	},
	
	hideall:function(){
		$$('.layers').invoke('hide');
	}
	
	
	
}


function register(){
	//ajax call to plug in doc link if valid email;
		
		email2send = $("email").value;
		
	
	
	new Ajax.Updater('container_register', 'library/ajax/register.php',{
			parameters:{
				email:$('email').value
			},
			evalScripts: true 
			
			}); // end Ajax.Updater	
	
	
}


//email click disappear text functions
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}

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