﻿var MM = window.MM ||
{};

if (!MM.Moti)
{ MM.Moti = {}; }

MM.Moti.serverID = (function()
{
    var serverControls = {};
    
    function registerServerControlID(serverId, clientId)
	{
		serverControls[serverId] = clientId;
	}
	
	return {
		serverControls: serverControls,
		registerServerControlID: registerServerControlID
	};
})();


MM.Moti.Tracking = (function($)
{ 
    $(document).ready(function() {
         $('#facebook').click(function() {
            
            try {
                //alert("foo");
                pageTracker._trackEvent('Links - Facebook', 'Click', 'Link to Moti Mahal Facebook page');
            } catch (e) { }
         }); 	
         
         $('#twitter').click(function() {
            try {
                pageTracker._trackEvent('Links - Twitter', 'Click', 'Link to Moti Mahal Twitter page');
            } catch (e) { }
         }); 
    });  
  
 
})(jQuery);



MM.Moti.FormCheck = (function($) {
	$(document).ready(function() {


		$('#submitnewsletter').click(function() {

			var fn = $('#firstname').val();
			var ln = $('#lastname').val();
			var c = $('#company').val();
			var e = $('#email').val();
			var t = $('#type').val();

			
			
			if (fn.length > 0 && ln.length > 0 && e.length > 0) {
				
				document.location = "/sendmail.aspx?firstname=" + fn + "&lastname=" + ln + "&company=" + c + "&email=" + e + "&type=" + t;
				
			}
			else {
				alert("Please give a Firtsname, Lastname and Email.");
				return false;
			}

		});

		$('#submitmembership').click(function() {

			var fn = $('#firstname').val();
			var ln = $('#lastname').val();
			var cr = $('#cardnumber').val();
			var e = $('#email').val();
			var t = $('#type').val();

			

			if (fn.length > 0 && ln.length > 0 && e.length > 0 && cr.length > 0) {

				

				document.location = "/sendmail.aspx?firstname=" + fn + "&lastname=" + ln + "&cardnumber=" + cr + "&email=" + e + "&type=" + t;

				
			}
			else {
				alert("Please give a Firtsname, Lastname, Email and Card Number.");
				return false;
			}


		});


		$('#submitevent').click(function() {

			var fn = $('#firstname').val();
			var ln = $('#lastname').val();
			var c = $('#company').val();
			var m = $('#mobile').val();
			var co = $('#contact').val();
			var com = $('#comments').val();
			var e = $('#email').val();

			if (fn.length > 0 && ln.length > 0 && e.length > 0) {
				document.location = "/sendmail.aspx?firstname=" + fn + "&lastname=" + ln + "&company=" + c + "&email=" + e + "&mobile=" + m + "&contact=" + co + "&comments=" + com + "&type=" + t;
			}
			else {
				alert("Please give a Firtsname, Lastname and Email.");
				return false;
			}

		});

	});

})(jQuery);            

MM.Moti.PageSlides = (function($)
{

	var slideshowEngine;
	var config = {
		quoteFadeInterval: 6000,
		quoteFadeSpeed: 500
	};

	function init()
	{
		//picture slider	
	$('#slide-images').cycle({ 
		fx:     'fade', 
		speed:  500, 
		timeout: 4000, 
		next:   '#next', 
		prev:   '#prev',
		pause: 1
	});
	
	//hide the cycle navigation buttons if there is only one image
	var imagenumber = $("#slide-images > img").size();
	if( imagenumber == 1)
	{
	$(".slidesnow-nav-container").hide();
	}
	
	// Tabs
	$('#tabs').tabs();
				
		
	var cancelhideGallery = window.setTimeout(function hideGallery() {
		$("#main-images .imageoverlay,  #quotations").show("slide", { direction: "down" }, 1000);
	}, 4000 );
		 
	//navigation hover effect	
	$("#mainnav ul li, #subnav ul li").hover(function() {
				$(this).nextAll().stop().fadeTo(500, 0.5);
			$(this).prevAll().stop().fadeTo(500, 0.5);
		}, function() {
					$(this).nextAll().stop().fadeTo(500, 1);
			$(this).prevAll().stop().fadeTo(500, 1);
		});
		
	if($('body').hasClass('specialevents')) {
	
	 $('.all-events').addClass('display');
	  }
	  else{
	  $('.all-events').removeClass('display');
	  }
		//rignt column hover effect	
	
		$("#highlight").hover(function() {
				$("#event-list, .single-link").stop().fadeTo(500, 0.3);
			}, function() {
				$("#event-list, .single-link").stop().fadeTo(500, 1);
		});
		
		
		$("#event-list li, .all-events").hover(function() {
				$("#highlight, .single-link").stop().fadeTo(500, 0.3);
			}, function() {
				$("#highlight, .single-link").stop().fadeTo(500, 1);
		});
		
		//checks if there are any empty unit divs in the linkboxes section and hides them otherwise they shows up in ie 
		
		$(".unit").hover(function() {
			if ($("div.unit:empty"))
			{
				$("div.unit:empty").css('display','none');
			}
			else{
			
				$(this).nextAll().stop().fadeTo(500, 0.5);
				$(this).prevAll().stop().fadeTo(500, 0.5);
			}
			}, function() {
			if ($("div.unit:empty"))
			{
			
			}
			else{
				$(this).nextAll().stop().fadeTo(500, 1);
				$(this).prevAll().stop().fadeTo(500, 1);
				}
		});
		
		
		// slide engine
		slideshowEngine = new imageslideshowEngine();
		slideshowEngine.images = $('#main-images > img').get();
		slideshowEngine.init(config.quoteFadeInterval, config.quoteFadeSpeed);
		
		slideshowEngine = new imageslideshowEngine();
		slideshowEngine.images = $('#quotations > div').get();
		slideshowEngine.init(config.quoteFadeInterval, config.quoteFadeSpeed);
	}

	return {
		init: init
	};

})(jQuery);


jQuery(MM.Moti.PageSlides.init);
