jQuery.noConflict();

jQuery(document).ready(function(){
	// login
	function myfunction(){
		var bodyWidth = jQuery('body').width();
		if(bodyWidth > 960){
			jQuery('#loginWrapper').css({"width": bodyWidth});
		} else {
			jQuery('#loginWrapper').css({"width": 960});
		}
	}
	myfunction();
	jQuery(window).resize(function(){myfunction();});
	
	// klanten login
	jQuery("#loginLauncher a").click(
		function() {
			jQuery("#loginContent, #loginContainer").slideDown("slow");
			return false;
		  }
	);
	jQuery("a#loginCloser").click(
		function() {
			jQuery("#loginContent, #loginContainer").slideUp("slow");
			return false;
		}
	);
	
	// footer social items
	jQuery('#newFooterSocial .newFooterSocialItem:eq(1), #newFooterSocial .newFooterSocialItem:eq(3), #newFooterSocial .newFooterSocialItem:eq(5)').css({"width":"64px"});
	jQuery('a.twitter').hover(
		function () {
			jQuery('#followUs').toggle();
		}, 
		function () {
			jQuery('#followUs').toggle();
		}
	);
	
	// proj accordion
	if(jQuery('#latestFrontProjList')[0]){	
		jQuery('#latestFrontProjList').accordion({ 
                     header: '.projHead',
                     autoHeight: false,
                     active: false                                            
                }).bind('accordionchangestart', function(event, ui){
                     jQuery(ui.newHeader).slideUp();
                     jQuery(ui.oldHeader).slideDown();
                }).find('.projHead:first').click();

	}
	
	// news accordion
	if(jQuery('#latestFrontNewsList')[0]){		
		jQuery('#latestFrontNewsList').accordion({ 
                     header: '.newsHead',
                     autoHeight: false
                });
	}
	
	// input hint
	if(jQuery('input')[0]){
		jQuery('input').hint();
	}
	
	// menu first
	jQuery('#mainMenu ul li:first').addClass("firstItem");
	
	// tracing menu
	jQuery("#mainMenu ul li.active").prevAll().addClass('greyUnderline');
	if (jQuery("#mainMenu ul li.active:first-child")[0] || !jQuery("#mainMenu ul li.active")[0]){
		jQuery('div#traced').hide();
	}
	
	// folding
	jQuery('.foldedTrigger').addClass("closed");
	jQuery('.closed').live("click", function () {
	  if(jQuery('#opened')[0]){
	    jQuery(this).parent().children('.foldedHide').slideUp("slow");
	  } else {
      	    jQuery(this).parent().children('.foldedHide').slideDown("slow");
	  }
	  jQuery(this).removeClass("closed").addClass("opened");
	});
	
	jQuery('.opened').live("click", function () {
	  if(jQuery('#opened')[0]){
	    jQuery(this).parent().children('.foldedHide').slideDown("slow");
	  } else {
      	    jQuery(this).parent().children('.foldedHide').slideUp("slow");
	  }
	  jQuery(this).removeClass("opened").addClass("closed");
	});
	
	
	
	
	// portofolio
	jQuery('.portofolioItem:nth-child(2n)').css({"margin-right":"0"});
	
	// slideshow
	if(jQuery('#slideShow')[0]){
		jQuery('#slideShow').cycle({
			fx:      'scrollHorz',
			prev:    '#prevSlide',
			next:    '#nextSlide'
		});
		
		jQuery('#pauseSlide').click(function() { 
    		    jQuery('#slideShow').cycle('pause');
				jQuery(this).toggle()
				jQuery('#playSlide').toggle();
		    	return false;
		});
		
		jQuery('#playSlide').click(function() { 
    		    jQuery('#slideShow').cycle('resume', true);
				jQuery(this).toggle()
				jQuery('#pauseSlide').toggle();
				return false;
		});
	}
	
	// team highlight
	jQuery('.sales').hover(
      function () {
        jQuery(this).siblings('.sales').css({"background-image":"url(images/grey_box_hover.gif)"}).children('.teamImage').addClass("hovered");
		jQuery(this).css({"background-image":"url(images/grey_box_hover.gif)"}).children('.teamImage').addClass("hovered");
      }, 
      function () {
        jQuery(this).siblings('.sales').removeAttr("style").children('.teamImage').removeClass("hovered");
		jQuery(this).removeAttr("style").children('.teamImage').removeClass("hovered");
      }
    );
	 
	 // news archive
	 jQuery('table.newsTable tr:odd').addClass("odd");
	 jQuery('table.newsTable tr').hover(
		function () {
        	jQuery(this).addClass("hoverLine");
      	}, 
      	function () {
        	jQuery(this).removeClass("hoverLine");
      	}
      );
	 
	 // news navigation
	 var newsTableNav = jQuery('.tx-ttnews-browsebox table').width();
	 jQuery('.tx-ttnews-browsebox table').css({"margin-left": 252 - newsTableNav/2 })
	 
	 // cufon special fonts
	Cufon.replace('#loginForm h2, .frontBox h2, #loginTeaser h2, #frontTeaserLeft h1, #frontTeaserText h2, #employeeName, ul#rightMenu li a, .clientBox h2, #columnCenter h1, #columnCenter h2', { fontFamily: 'Dax', hover: true });
	Cufon.replace('#employeeTxt, .bigQuote, .smallQuote, .contentComment, .teamQuote', { fontFamily: 'Calisto MT', hover: true });
	
	//jQuery('li').highlight('bla');
	//jQuery('div#columnCenter').highlight('\?')

});
