/* 
Scripts made for the Deesea.com website
*/

$(document).ready(
	function() {

	    //add tool tips
        $('.green_col .list li a[title]').qtip({
	        style: { name: 'light', tip: true, border: { width: 7, radius: 5, color: '#88da1e'} },
	        position: {
	            corner: {
	                target: 'topRight',
	                tooltip: 'bottomLeft'
	            }
	        }
	    })

	    $('.blue_col .list li a[title]').qtip({
	        style: { name: 'light', tip: true, border: { width: 7, radius: 5, color: '#2394ff'} },
	        position: {
	            corner: {
	                target: 'topRight',
	                tooltip: 'bottomLeft'
	            }
	        }
	    })

	    $('.green_col .list li a').hover(
		function() {
		    $(this).find("img").attr('src', $(this).find("img").attr('src').replace('bw', 'color'));
		    $(this).find("img").css('border', '2px solid #88da1e')

		},
		function() {
		    $(this).find("img").attr('src', $(this).find("img").attr('src').replace('color', 'bw'));
		    $(this).find("img").css('border', '2px solid #d6d6d6')
		}
		);

	    //Add click event to work icons
	    $('.green_col .list li a').click(
		function() {
		    $('.blue_col').animate({ "width": "0px" }, 400);
		    $('.green_col').animate({ "width": "665px" }, 400);
		    $('.list').hide();
		    $('#blue_col_content').hide();

		    $('.green_col').oneTime(425, function() {
		        $(this).addClass('inner_green');
		    });

		    LoadWork($(this).attr('id'));

		    return false;
		}
		);

	    //Add click event to work back button
	    $('.back').click(
		function() {
	        $('.list').show();
	        $('#blue_col_content').show();
		    $('.green_col').animate({ "width": "332px" }, 400);
		    $('.green_col').removeClass('inner_green');
		    $('.blue_col').animate({ "width": "333px" }, 400);
		    $('.green_col').find('.middle').hide();
		    return false;
		}
		);

	    SetActiveMenu();

	});

	function LoadWork(id) {
	    $('#projectHolder').hide();
	    $('#projectLoading').show();
	    $('#projectHolder').load('/Content/Customers/Customer' + id + '.aspx #Contents', function() {
	        $('#projectLoading').hide();
	        $('#projectHolder').show();

	        $(".links a[href*=.jpg],.links a[href$=.png],.links a[href$=.gif]").fancybox({
	            'titlePosition': 'over'
	        });
	    });
	}


	// set the active main menu item based on URL patterns
	function SetActiveMenu() {
	    var url = window.location.href.toLowerCase()
	    var activeMenuId = "mHome";

        if (url.indexOf('/contact') > 0 || url.indexOf('/mls/') > 0) {
	        activeMenuId = "mContact";
	    }
	    else if (url.indexOf('/services') > 0) {
	        activeMenuId = "mServices";
	    }
	    else if (url.indexOf('/about') > 0) {
	        activeMenuId = "mAbout";
	    }
	    else if (url.indexOf('/blogheader') > 0) {
	        activeMenuId = "mBlog";
	    }
	    else if (url.indexOf('/quote') > 0) {
	        activeMenuId = "mQuote";
	    }
	    else {
	        activeMenuId = "mHome";
	    }

	    $("#mainMenu").contents().removeClass("active");
	    $("#" + activeMenuId).addClass("active");
	}
