$(document).ready(function(){
	
	$(function () {
		//affectation de lightbox
	$('a[rel*=lightbox]').colorbox();
	$('a[rel*=lightboxAlone]').colorbox({iframe:true, innerWidth:500, innerHeight:500});
	
	$('input[type="text"]').addClass("idleField");
		$('input[type="text"]').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
	    if (this.value == this.defaultValue){ 
	    	this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
	    if ($.trim(this.value) == ''){
	    	this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});	
	
		
//////////When you look at me ... I completely disappear
		$("#top").find("input").each(function(){
			$(this).focus(function () {
				$(this).val("");
			});
		});

//////////Cookie monster just around the corner
		function setCookie(name,value,expiredays){
			var exdate=new Date();
			exdate.setDate(exdate.getDate()+expiredays);
			document.cookie=name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/;domains=";
		}
		
		function getCookie(c_name){
			if (document.cookie.length>0){
			  c_start=document.cookie.indexOf(c_name + "=");
				  if (c_start!=-1){ 
				    c_start=c_start + c_name.length+1; 
				    c_end=document.cookie.indexOf(";",c_start);
				    if (c_end==-1) c_end=document.cookie.length;
				    return unescape(document.cookie.substring(c_start,c_end));
			    } 
			}
		return "";
		}
			
//////////Put some decoration on my links
		$("a[href$=pdf]").addClass("pdf").attr("target","_blank");
		$("a[href$=xls]").addClass("xls").attr("target","_blank");
		
//////////Tell me where i'm going
		$("a[rel='3m4il']").each(function(){
			var spaceShip = $(this).text();
			var spaceStation = $(this).attr('href');
			
			$(this).attr({
				href: 'mailto:'+ spaceShip +'@'+ spaceStation +'',
				rel: 'nofollow'
			});
			$(this).text(''+ spaceShip +'@'+ spaceStation +'');
		});
		
//////////Please help me J.J. Abrams i'm lost...
		if($("#siteMap").length !=0) {
			$("#siteMap").treeview({
				collapsed: false,
				animated: "medium",
				control:"#expandCollapse",
				persist: "location"
			});
		};

//////////Gmap
		if ($('#gmap').length != 0) {
				function initialize() {
					var latlng = new google.maps.LatLng(45.476341,-73.78521);
					var myOptions = {
						zoom: 13,
						center: latlng,
						noClear:false,
						mapTypeControl: true,
						mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
						navigationControl: true,
						navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
						scrollwheel: false,
						mapTypeId: google.maps.MapTypeId.ROADMAP
					};
					var map = new google.maps.Map(document.getElementById("gmap"), myOptions);

			          var contentString = '<div id="infoBulle"><strong>Lutek Inc.</strong><br />2274, rue St-François<br />Dorval, Qc, Canada, H9P 1K2</div>';
			              
			          var infowindow = new google.maps.InfoWindow({
			              content: contentString
			          });
          
					var marker = new google.maps.Marker({
						position: latlng, 
						map: map
					});	
					
					infowindow.open(map,marker);
				};
				initialize();
		};

//////////Popup Window (jquery.popupWindow.js)
		/*$('a[rel="popup"]').popupWindow({
			centerBrowser: 1
		});
		$('#mainMenu .secure a').popupWindow({
			width: 500,
			height: 450,
			centerBrowser: 1
		});*/

//////////Homepage suppliers logo rotation (jquery.cycle.lite.min.js)
		if ($('#jsCycleSuppliers').lenght !=0) {
			$('#jsCycleSuppliers').cycle({
				height: '115px',
				timeout: 6000,
				speed: 1000,
				fit: 1,
				sync: 0,
				pause: 0
			});
		};

	});
});

