/* default template js */
	Shadowbox.init({
	    language: "en",
	    // let's skip the automatic setup because we don't have any
	    // properly configured link elements on the page
	    skipSetup: true,
 		overlayColor: '#2f569b',
		overlayOpacity: '0.5',
		displayNav: false,
	    // include the html player because we want to display some html content
	    players: ["iframe"]
	});

$(document).ready(function()
{
	$(".parent").click(function() 
			{
//		var id = $(this).attr("id");
//		//$(this).addClass("parentopen");
//		$(".parent:not("+id+")").removeClass("parentopen");
//		$(this).toggleClass("parentopen");
//		$("#s_"+id).slideDown();
//		$(".sub:not(#s_"+id+")").slideUp();
		var kid = $(this).contents().children(':first');
		//console.debug(kid);
		var id = kid.attr("id");
		var page = id.replace('s_', "");
		var hostname = window.location.hostname;
		var protocol = window.location.protocol;
		location.href=protocol+'//'+hostname+'/'+page;
			});
	$("#c_menu li:not(.current)").hover(
		function()
		{
			$(this).css("color","#fff");
		},
		function()
		{
			$(this).css("color","#a3a3a3");
		});
		
	$("#c_menu li:not(.parent)").click(function()
		{
			var id = $(this).attr("id");
			var hostname = window.location.hostname;
			var protocol = window.location.protocol;
			location.href=protocol+'//'+hostname+'/'+id;
		});


    $(".result").live("mouseover", function () {
        $(this).toggleClass("highlight");
    });
    $(".result").live("mouseout", function () {
        $(this).removeClass("highlight");
    });

//    $(".result").live("click", function () {
//		var id = $(this).attr("id");
//		//alert(info[0]);
//	    // open a welcome message as soon as the window loads
//	    Shadowbox.open({
//	        content:    '/ajax/showMedia?media_id='+id,
//	        player:     'iframe',
//			//autoDimensions: true
//        	width: 800,
//        	height: 700
//	       });
//	
//	});

  $("#viewall").live("click", function () {
      $.ajax({
          type: "POST",
          url: "/ajax/makeSlides",
          cache: false,
          data: {
			first_last_buttons: "no",
              first_slide_is_intro: "no",
              hover_next_prev_buttons: "yes",
              next_prev_buttons: "no",
              pause_button: "no",
              slide_buttons: "yes",
              slide_directory: "_image/our_work",
              doctype: "html",
              slide_links: "no",
              slide_number_display: "no",
              water_mark: "no",
              category: "all"
          },
          success: function(html) {
              slide_containter_elem.html(html);
              carousel();
          }
      });
	pageTracker._trackPageview("/our_work/viewall" );
  });
	
	$("#sortby").change(function () {
          var category = "";
          $("#sortby option:selected").each(function () {
                category = $(this).val();
              });
          $("#"+category).show();
          $(".by:not(#"+category+")").hide();
   
    });
	 var evt = $.browser.msie ? "click" : "change";
	 
	 
	$("#industry").bind(evt, function () {
        var industry = "";
        $("#industry option:selected").each(function () { industry = $(this).val(); });
        $.ajax({
            type: "POST",
            url: "/ajax/makeSlides",
            cache: false,
            data: {
			first_last_buttons: "no",
                first_slide_is_intro: "no",
                hover_next_prev_buttons: "yes",
                next_prev_buttons: "no",
                pause_button: "no",
                slide_buttons: "yes",
                slide_directory: "_image/our_work",
                doctype: "html",
                slide_links: "no",
                slide_number_display: "no",
                water_mark: "no",
                category: "industry",
                industry: industry
            },
            success: function(html) {
                slide_containter_elem.html(html);
                carousel();
            }
        });
        pageTracker._trackPageview("/our_work/industry" );
 
	});

	
	$("#media_type").change(function () {
        var media_type = "";
        $("#media_type option:selected").each(function () { media_type = $(this).val(); });
        $.ajax({
            type: "POST",
            url: "/ajax/makeSlides",
            cache: false,
            data: {
			first_last_buttons: "no",
                first_slide_is_intro: "no",
                hover_next_prev_buttons: "yes",
                next_prev_buttons: "no",
                pause_button: "no",
                slide_buttons: "yes",
                slide_directory: "_image/our_work",
                doctype: "html",
                slide_links: "no",
                slide_number_display: "no",
                water_mark: "no",
                category: "media_type",
                media_type: media_type
            },
            success: function(html) {
                slide_containter_elem.html(html);
                carousel();
            }
        });

        pageTracker._trackPageview("/our_work/media_type" );
 	});
	
/*	$.ajax({ 
		url: '/basecamp/getProjects', 
		type: 'GET',
		beforeSend: function()
     	{	},
		complete: function(XMLHttpRequest, textStatus) 
		{ 
     		$("#debug").html(XMLHttpRequest.responseText);
		} 
}); */

	
	
	
	
	
});

function mediaClick(id){
	Shadowbox.open({
        content:    '/ajax/showMedia?media_id='+id,
        player:     'iframe',
	   width: 800,
	   height: 700
       });
}
function videoClick(id){
	Shadowbox.open({
        content:    '/ajax/showMedia?media_id='+id,
        player:     'iframe',
	   width: 600,
	   height: 480
       });
}

