function externalLinks()
{
	if (!document.getElementsByTagName) return;
	
	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		var relvalue = anchor.getAttribute("rel");
		
		if (anchor.getAttribute("href"))
		{
			var external = /external/;
			var relvalue = anchor.getAttribute("rel");
			
			if (external.test(relvalue))
			{
				anchor.target = "_blank";
			}
		}
	}
}
$(function(){
	var divCollapse=$("h3[rel*=collapse]");					
	jQuery.each(divCollapse, function(i,v) {	
	  $("#"+$(v).attr('title')).hide();
	});
	//$("h3[rel*=collapse],h4[rel*=collapse]").toggle();
	$("h3[rel*=collapse],h4[rel*=collapse],a[rel*=collapse]").click(function(){
		$("#"+$(this).attr('title')).toggle("slow");
	});
	
	
	$("a[rel*=dialog_link]").click(
		function(e) {
			e.preventDefault();
			var vardialog = $('#dialog') 
			  vardialog.html('<center><img src="images/loading.gif" /></center>');
			  vardialog.dialog('option','buttons',{"Close": function(){$(this).dialog("close");}});
			  vardialog.dialog('option','width',600);
			  vardialog.dialog('open');
			$.get("ProductInformation/"+$(this).attr('href'), function(data){
			  vardialog.html(data);// Dialog Link
			});

		}					
	);
	
	$("a[rel*=popup],img[rel*=popup]").click(
		function(e) {
			e.preventDefault();
			var vardialog = $('#dialog');
			  vardialog.html('');
			  vardialog.append('<center><img src="images/loading.gif" id="dialogpreloader" /></center>');
			  vardialog.dialog('option','buttons',{"Close": function(){$(this).dialog("close");}});
			  vardialog.dialog('option','width',600);
			  vardialog.dialog('open'); 
			  $("#dialogpreloader").attr('src',$(this).attr('href'));// Dialog Link
		}					
	);
	
	$('#dialog').dialog({
		autoOpen: false,
		width: 600,
		modal:true,
		buttons: {"Close": function(){$(this).dialog("close");} }
	});
	
	//hover states on the static widgets
	$('a[rel*=JQueryHovers],button[rel*=JQueryHovers]').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	
});


