function initMenu() {
   $('#menu ul').hide();
   $('#menu li a').click(function() {
   	  $('#promo-box').hide();
      var checkElement = $(this).next(); if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
         return false; }
      if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
         $('#menu ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; }
      }
   );

//	$('img.thumb').mouseover(function(){ if (thumbnailId !== this.id){alert("tnid is: "+thumbnailId); thumbnailId = this.id; alert(getId());}});
}

function initPromoBox() {
	$('#promo-box').append('<div id="slideshow" class="pics"><img src="/assets/promos/Display_1.jpg" title="Wideman TV Promo" /><img src="/assets/promos/Display_2.jpg" title="Wideman TV Promo" /><img src="/assets/promos/Display_3.jpg" title="Wideman TV Promo" /></div>');
	$('#slideshow').cycle();
}

function randomBg() {
   var r = Math.floor(Math.random() * 4);
   return "/assets/interface/News_Pattern/News_Pattern" + r + ".gif";
 
}

$(document).ready(function() {
	$('#news-articles').css("background-image", "url(" + randomBg() + ")");
	initMenu(); 
	initPromoBox();
	$('#contact-form').validate();
	
	// Configure the preview tooltips
	$('img.tt').each(function(){
		$(this).qtip({
			
			show: { effect: { type: 'slide' } },
			hide: { effect: { type: 'slide' } },
		
			tip: true,
			
			style: {
				background : '#333333', 
				width:350,
				border: {
					color : '#333333',
					width: 2,
					radius: 0
				},

				padding: 10,
				textAlign: 'left',
				tip: true,
				name: 'dark'
			},
			
			content: {
	            	url: '/work/' + $(this).attr('id') + '.html',
	            	method: 'get'
			},
			
			position : {
				corner : {
				    target : 'topMiddle', tooltip : 'bottomMiddle' 
				},
				adjust: { screen: true } 
			}	
	 
		});
	});
});	





