// JavaScript Document

var Belden_Dropdown_Select = 
{
	init: function() 
	{
		Belden_Dropdown_Select.Address = 'http://www.belden.com';
		Belden_Dropdown_Select.Target = document.getElementById('utility-select');
		Belden_Dropdown_Select.Target.onchange = function()
		{
			Belden_Dropdown_Select.gotoAddress();
		}
	},
	
	gotoAddress: function()
	{
		var pTarget = Belden_Dropdown_Select.Target;
		var szValue = pTarget.options[pTarget.selectedIndex].getAttribute('value');
		
		if (szValue == null)
		{
			return;
		}
		
		location.href = Belden_Dropdown_Select.Address + szValue;
	}
}

function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }
 
 function switchTab(tabName, divName, tabClass, divClass){
	$('.' + divClass).hide();
	$('#' + divName).show();
	
	$('.' + tabClass).removeClass('active');
	$('#' + tabName).addClass('active');
}

jQuery(document).ready(function($){
	$("#news-ticker").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 3000);
	$('#news-ticker').hover(function(){
			$(this).tabs('rotate', 0, false);
		},function(){
			$(this).tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 3000);
	});
	$('#news-ticker').click(function(){
		$(this).tabs('rotate', 0, false);
		$(this).unbind('hover');
	});
	
	$( "#accordion" ).accordion();
	
	//$('select').selectmenu({style: 'dropdown'});
	
	//$('.scrollable').scrollable({});
	$('.scrollable').scrollable({circular: true}).autoscroll({ autoplay:true });
	
	
	$('.brand-scrollable').bind('onSeek', function(event){
		var brand = ($($('.brand-scrollable').data('scrollable').getItems()[$('.brand-scrollable').data('scrollable').getIndex()]).find('img').attr('alt'));
		var brandURL = ($($('.brand-scrollable').data('scrollable').getItems()[$('.brand-scrollable').data('scrollable').getIndex()]).find('img').attr('class'));
		$('span.brand-name').text(brand); 
		//$('span.brand-name').parents('a').attr('href', 'http://www.belden.com/' + brand + '.html');
		$('span.brand-name').parents('a').attr('href', brandURL);
	});

	$('.home-brands').bind('onSeek', function(event){
		var brand = ($($('.home-brands').data('scrollable').getItems()[$('.home-brands').data('scrollable').getIndex()]).find('img').attr('alt'));
		var brandURL = ($($('.home-brands').data('scrollable').getItems()[$('.home-brands').data('scrollable').getIndex()]).find('img').attr('class'));
		$('span.brand-name').text(brand); 
		//$('span.brand-name').parents('a').attr('href', 'http://www.belden.com/' + brand + '.html');
		$('span.brand-name').parents('a').attr('href', brandURL);
	});
	

	//$('select').selectmenu({style:'dropdown'});
	$('#belden_site_form').selectmenu({style:'dropdown'});
	$('#belden-login-select').selectmenu({style:'dropdown'});
	
	$('.section-header.partnerForm, .section-header.generalForm').hide();
		$('.form-change').change(function() {
			var form = $('#select-form-type').change(function(){}).val();
			var category = $('#select-form-category').change(function(){}).val();

			if (form == 'Partner Inquiry' && category == 'Partners'){
				
				$('.section-header.generalForm').hide();
				$('.section-header.partnerForm').show();
			}
			if (form == 'General Inquiry' && category == 'General'){
				$('.section-header.partnerForm').hide();
				$('.section-header.generalForm').show();
			}
			
		});
		
	 $('.menu-2').hover(
		function () {
		$(this).children('.mega-wrap').show().css('left','-15px');	
		},
		function () {
		$(this).children('.mega-wrap').hide().css('left','-9999px');
		}
	);
	
	 $('.menu-3').hover(
		function () {
		$(this).children('.mega-wrap').show().css('left','-209px');	
		},
		function () {
		$(this).children('.mega-wrap').hide().css('left','-9999px');
		}
	);
	
	 $('.menu-4').hover(
		function () {
		$(this).children('.mega-wrap').show().css({'right' : '-15px', 'left' : 'auto'});	
		},
		function () {
		$(this).children('.mega-wrap').hide().css('left','-9999px');
		}
	);
	
	 $('.menu-5').hover(
		function () {
		$(this).children('.mega-wrap').show().css({'right' : '0px', 'left' : 'auto'});	
		},
		function () {
		$(this).children('.mega-wrap').hide().css('left','-9999px');
		}
	);
});
