$(function(){

	var customizeForDevice = function(){
	    var ua = navigator.userAgent;
	    var checker = {
	      iphone: ua.match(/(iPhone|iPod)/),
		  ipad: ua.match(/(iPad)/),
	      blackberry: ua.match(/BlackBerry/),
	      android: ua.match(/Android/),
		  desktop: ua.match(/Mac|Windows|Linux/)
	    };
		
		var docHeight = $(document).height()+'px';
		// console.log(ua);
		
	    if (checker.android){
	        $('body').addClass('android mobile');
	    }
	    else if (checker.iphone){
			$('body').addClass('iphone mobile');
	    }
		else if (checker.ipad){
			$('body').addClass('ipad');
	    }
	    else if (checker.blackberry){
	        $('body').addClass('blackberry');
	    }
		else if (checker.desktop){
	        $('body').addClass('desktop');
			$('head').append('<link media="screen" href="css/desktop.css" type= "text/css" rel="stylesheet" />');
	    }
	    else {
	        $('body').addClass('simplephone');
			
	    }
	}

	customizeForDevice();

	
	/* Date Filter */
	if ($('#filter').hasClass('filter_nav')) {
		
		if ($('body').hasClass('desktop')) {
			$(".nonCircular .jCarouselLite").jCarouselLite({
				start:13,
			    btnNext: ".nonCircular .date_next",
			    btnPrev: ".nonCircular .date_prev",
			    circular: false,
				visible:7
				
			});
		} else if ($('body').hasClass('ipad')) {
			$(".nonCircular .jCarouselLite").jCarouselLite({
			    btnNext: ".nonCircular .date_next",
			    btnPrev: ".nonCircular .date_prev",
			    circular: false,
				visible: 7
			});
		
		} else  {
			$(".nonCircular .jCarouselLite").jCarouselLite({
				start:16,
			    btnNext: ".nonCircular .date_next",
			    btnPrev: ".nonCircular .date_prev",
			    circular: false,
				visible: 4
			});
		}
	}
	
	

	/* TABS */
	$( "#tab_container" ).tabs();


	/* Dialog Login */
	if ($('body').hasClass('desktop')) {
	    $(".btn_login").click(function() {
	        $("#user_register").dialog('close');
	        $("#user_forgot").dialog('close');
	        $("#user_login").dialog({ resizable: false, modal: true, width: 400, height: 300 });
	    });
	} else if ($('body').hasClass('ipad')) {
	    $(".btn_login").click(function() {
	        $("#user_register").dialog('close');
	        $("#user_forgot").dialog('close');
	        $("#user_login").dialog({ resizable: false, modal: true, width: 400, height: 300 });
	    });
	} else if ($('body').hasClass('mobile')) {
	    $(".btn_login").click(function() {
	        $("#user_register").dialog('close');
	        $("#user_forgot").dialog('close');
	        $("#user_login").dialog({ resizable: false, modal: true, width: 320, height: 420 });
	    });
	}



	/* Dialog Register */
	if ($('body').hasClass('desktop')) {
	    $(".btn_register").click(function() {
	        $("#user_login").dialog('close');
	        $("#user_register").dialog({ resizable: false, modal: true, width: 400, height: 270 });
	    });
	} else if ($('body').hasClass('ipad')) {
	    $(".btn_register").click(function() {
	        $("#user_login").dialog('close');
	        $("#user_register").dialog({ resizable: false, modal: true, width: 400, height: 270 });
	    });
	} else if ($('body').hasClass('mobile')) {
	    $(".btn_register").click(function() {
	        $("#user_login").dialog('close');
	        $("#user_register").dialog({ resizable: false, modal: true, width: 320, height: 420 });
	    });
	}



	/* Dialog Forgot Password */
	if ($('body').hasClass('desktop')) {
	    $(".btn_forgot_password").click(function() {
	        $("#user_login").dialog('close');
	        $("#user_forgot").dialog({ resizable: false, modal: true, width: 400, height: 200 });
	    });
	} else if ($('body').hasClass('ipad')) {
	    $(".btn_forgot_password").click(function() {
	        $("#user_login").dialog('close');
	        $("#user_forgot").dialog({ resizable: false, modal: true, width: 400, height: 200 });
	    });
	} else if ($('body').hasClass('mobile')) {
	    $(".btn_forgot_password").click(function() {
	        $("#user_login").dialog('close');
	        $("#user_forgot").dialog({ resizable: false, modal: true, width: 320, height: 420 });
	    });
	}
	
	
	



	
	
});
