
var mobile = function(){
		return {
			detect:function(){
				var uagent = navigator.userAgent.toLowerCase(); 
				var list = this.mobiles;
				var ismobile = false;
				for(var d=0;d<list.length;d+=1){
					if(uagent.indexOf(list[d])!=-1){
						ismobile = true;
					}
				}
				return ismobile;
			},
			mobiles:[
				"midp","240x320","blackberry","netfront","nokia","panasonic",
				"portalmmm","sharp","sie-","sonyericsson","symbian",
				"windows ce","benq","mda","mot-","opera mini",
				"philips","pocket pc","sagem","samsung","sda",
				"sgh-","vodafone","xda","palm","iphone","ipad",
				"ipod","android"
			]
		};
	}();

$(document).ready(function() {
	
	
	
/*-------------------------------------------
Helper
*/	

//Add a class to last child of ul and ol
	$('li:last-child').addClass('last');
	//Add a class to first child of ul and ol
	$('li:first-child').addClass('first');

$("li").hover(function(){
	$(this).addClass("hover");
}, function() {
	$(this).removeClass("hover");
});

$("table tr:even td").addClass("alt");

	$("a[href=#], area[href=#]").click(function(){
		return false;
	});
	
	//$("a[href=#]").css('cursor', 'default');
	

/*
	$("#navigation ul li").mouseenter(function() {
		$(this).children('ul').slideDown('slow');
	}).mouseleave(function(){
      	$(this).children('ul').slideUp();
    });

	
	$("#navigation ul li a").click(function (){
		var status = $(this).next('ul').css('display');

		$("#navigation ul li ul").slideUp();
		if (status == 'none'){

			$(this).next('ul').slideDown('slow');
		}
		return false;
	}); */
	
	ddsmoothmenu.init({
		mainmenuid: "navigation", //menu DIV id
		orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		shadow: {enable:false},
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
	
	ddsmoothmenu.init({
		mainmenuid: "navigation-top", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		shadow: {enable:false},
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
	
	$("a.zoom_qtvr").fancybox({
		'autoScale'		: false,
		'overlayOpacity'  : 0.7,
		'zoomSpeedIn'   : 500,
		'zoomSpeedOut'    : 500,
		'overlayColor'    : '#FFF',
		'hideOnOverlayClick' : true,
		'hideOnContentClick' : false,
		'width' : 815,
		'height' : 616,
		'type'	: 'iframe',
		'padding' : 0
    });
	
	$("a.zoomVideo").click(function() {
		$.fancybox({
				
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});
	
	$("a.zoomCadastre").click(function() {
		$.fancybox({
				
				'autoScale'		: false,
				'autoDimensions': false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'margin'		: 5,
				'padding'		: 10,
				'width'			: 760,
				'height'		: 837,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					'wmode'				: 'transparent',
					'allowfullscreen'	: 'true',
					'allowScriptAccess' : 'always',
					'FlashVars'			: 'flashcontext=web'
				}
			});
	 
		return false;
	}); 



$(".zoom-slideshow").fancybox({
				openEffect  : 'none',
				closeEffect : 'none',
				type : 'iframe',
				padding : 0,

				prevEffect : 'none',
				nextEffect : 'none',
				fitToView : true,

				closeBtn  : false,

				helpers : {
					title : {
						type : 'outside'
					},
					buttons	: {}
				}

				
			});
			
	/*$(".zoom-slideshow").fancybox({
	type : 'iframe',
	prevEffect		: 'none',
		nextEffect		: 'none',
		closeBtn		: false,
		helpers		: { 
			title	: { type : 'inside' },
			buttons	: {}
		}
			
			
			
	'width'				: 800,
	'height'			: 600,
	'titleShow'			: false,
	'overlayOpacity'	: 0.9,
	'overlayColor'		: '#000',
	'padding'			: 0,
			
	});*/
	
	$("a.zoomIframeBig").fancybox({
		'autoScale'		: false,
		'overlayOpacity'  : 0.7,
		'zoomSpeedIn'   : 500,
		'zoomSpeedOut'    : 500,
		'overlayColor'    : '#FFF',
		'hideOnOverlayClick' : true,
		'hideOnContentClick' : false,
		'width' : 800,
		'height' : 520,
		'type'	: 'iframe',
		'padding' : 0,
		helpers : {
					title : {
						type : 'outside'
					},
					buttons	: {}
				}
    });
	
	$(".zoom").fancybox({
		'titleShow'			: true,
		'titlePosition' 	: 'over'
		
	});
	
	$(".zoom-small").fancybox({
		'titleShow'			: true,
		'titlePosition' 	: 'over',
		'width'				: 852
	});
	
	$(".zoom-contact").click( function(){
		$("#employee_id").val($(this).attr('rel'));					
	});
	
	$(".zoom-contact").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: true,
		'onClosed'		: function() {
			$("#login_error").hide();
		}
	});
	
	$(".zoom-video").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'width'				: 852,
		'height'			: 496,
		'type'				: 'iframe',
		'scrolling' 		: 'no',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});
	
	$(".zoom-iframe").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'width'				: 900,
		'height'			: 700,
		'type'				: 'iframe',
		'scrolling' 		: 'no',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});
	
	$("a[rel=group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});
	
	$("#send").bind("click", function() {
		$('#contact-form').ajaxSubmit({
			url: '/ajax.html',
			data: {context: 'Site_Ajax', action: 'send_sms'},
			type: 'POST',
			dataType: 'json',
			beforeSubmit :  function(data) {
				if ($("#sms_name").val().length < 1 || $("#tel_1").val().length < 1 || $("#tel_2").val().length < 1 || $("#tel_3").val().length < 1) {
					$("#login_error").show();
					$.fancybox.resize();
					
				}else{
					$.fancybox.showActivity();	
				}
			},
			success: function(data) {
				if (data.status == 'OK') {
					$.fancybox(data.html);
				}
			}
		});
	});
	
	$('#form_search').live("submit", function() {
        $('#form_search').ajaxSubmit({
			url: '/ajax.html',
			data: {context: 'Site_Ajax', action: 'search_houses'},
			type: 'POST',
			dataType: 'json',
			beforeSubmit:  function(data) {
				$(".search_results").html('<img src="/images/administration/loading.gif">');
			},
			success: function(data) {
				if (data.status == 'OK') {
					$(".search_results").html(data.html);
				}
			}
		});
    });

	
	$("#send_friend").bind("click", function() {
		$('#sendfriend-form').ajaxSubmit({
			url: '/ajax.html',
			data: {context: 'Site_Ajax', action: 'send_friend', url: window.location.href},
			type: 'POST',
			dataType: 'json',
			beforeSubmit :  function(data) {
				if ($("#send_email").val().length < 1 || $("#send_email").val().length < 1) {
					$("#login_error").show();
					$.fancybox.resize();
					
				}else{
					$.fancybox.showActivity();	
				}
			},
			success: function(data) {
				if (data.status == 'OK') {
					$.fancybox(data.html);
				}
			}
		});
	});
	

	
});


function addfav(){
	if (document.all){
  		window.external.AddFavorite("http://www.voyer.ca","Voyer Constructions");
	}
}

/* Modified to support Opera */
function bookmarksite(title,url){

	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
	
/*
	  if (window.sidebar){
		window.sidebar.addPanel(title, url, "");
	  } else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	  }
	  else if(document.all){
		window.external.AddFavorite(url, title);
	  } */

}


