$(function() {	
	/* on DOM ready
	----------------------------------------------- */	
	$('body').addClass('hasJS');
	$("span.nojs").remove();
	
	if (navigator.platform.indexOf("Mac")>=0) { 
		$('body').addClass('isMac')
	}
	
	/* last-child classes for IE */
	$('ul.horizontal li:last-child').addClass('last-child');
	$('ul.horizontal li:first-child').addClass('first-child');
	$('div.product-summary:last-child').addClass('last-child');
/* --------------------------------------------------------------
	Table styling helpers and sorting
---------------------------------------------------------------- */
	/* rows highlight */
	$('table.data tbody tr').hover(
		function() {$(this).addClass('over');},
		function() {$(this).removeClass('over');}
	);
	
	$("table.data tbody tr:nth-child(odd)").addClass("odd");
	$("table.data tbody tr:nth-child(even)").addClass("even");
	
	/* make the tr's clickable  */
    $('table.data tbody tr.entity').click(function(){
        location.href = $('td a', this).attr('href');
    });
   
/* --------------------------------------------------------------
	Popups / Generic
---------------------------------------------------------------- */
	// Generic Popup 
	$('a[@rel=popup]').click(function(){
		var href = $(this).attr('href');
		window.open(href,'popup','location=0,status=1,scrollbars=1,resize=1,width=820,height=600');
		return false;
	});
	
/* --------------------------------------------------------------
	New window links
---------------------------------------------------------------- */
    $("a[@rel~=external]").click( function() { 
        var href = $(this).attr('href');
        window.open( href );
        return false;
    });
	
/* --------------------------------------------------------------
	Clickable Containers
---------------------------------------------------------------- */
	$(".clickable").click(function(){
		window.location=$(this).find("a").attr("href"); return false;
	});
	
	$("#qv h3").click(function(){ window.location = "/products/view/quotevision/"; });
	$("#dv h3").click(function(){ window.location = "/products/view/datavision/";  });
	$("#av h3").click(function(){ window.location = "/products/view/alphavision/"; });
	
/* --------------------------------------------------------------
	JS Dependent links
---------------------------------------------------------------- */
	var printLink = '<li id="printit"><a href="javascript:window.print()">Print</a></li>';
	$('#email-friend').after(printLink);

/* --------------------------------------------------------------
	add class to linked img to get rid of border-bottom 
---------------------------------------------------------------- */
	// $('a:has(img)').addClass('image'); });
	
/* --------------------------------------------------------------
	init JQ plug-ins
---------------------------------------------------------------- */
	$('a.zoom').each(function() { $(this).fancyZoom({width:520, height:299});});
	$('a.lightbox').lightBox(); 
	
	if ( $('div.tweet').length ) {
		$(".tweet").tweet({
	          join_text: "auto",
	          username: "cmavision",
	          // avatar_size: 48,
	          count: 3,
	     //     auto_join_text_default: "we said,", 
	     //     auto_join_text_ed: "we",
	     //     auto_join_text_ing: "we were",
	     //     auto_join_text_reply: "we replied",
	     //     auto_join_text_url: "we were checking out",
	     	  auto_join_text_default: "", 
	          loading_text: "loading tweets..."
	        });
	}
/* -----------------------------------------------
	End DOM ready
----------------------------------------------- */
});

