//slide show of banners in main page
   function init_rotator() {

	// Does element exist?
	if (!$('#rotator').length) {

		// If not, exit.
		return;
	}

	// Rotate speed.
	var speed = 2000;

	// Pause setting.
	var pause = false;

	// Rotator function.
	function rotate(element) {

		// Stop, if user has interacted.
		if (pause) {
			return;
		}

		// Either the next /first <li>.
		var $next_li = $(element).next('li').length ? $(element).next('li') : $('#rotator li:first');

		// Either next / first control link.
		var $next_a = $('#rollicon a.current').parent('li').next('li').length ? 
		$('#rollicon a.current').parent('li').next('li').find('a') : $('#rollicon a:first');

		// Animate.
		$('#rollicon a.current').removeClass('current');
		$next_a.addClass('current');

		// Continue.
		function doIt() {
			rotate($next_li);
		}

		// Fade out <li>.
		$(element).fadeOut(speed);

		// Show next <li>.
		$($next_li).fadeIn(speed, function() {

			// Slight delay.
			setTimeout(doIt, speed);
		});
	}

	// Add click listeners for controls.
	$('#rollicon a').click(function() {

		// Change button text.
		$('#pauseicon').html('PLAY');

		// Show target, hide other <li>.
		$($(this).attr('href')).show().siblings('li').hide();

		// Add class="current" and remove from all others.
		$(this).addClass('current').parent('li').siblings('li').find('a').removeClass('current');;

		// Pause animation.
		pause = true;

		// Nofollow.
		this.blur();
		return false;
	});

	
 
	$('#pauseicon').click(function() {

		// What does the button say?
		if ($(this).html() === 'PAUSE') {

			// Stop rotation.
			pause = true;

			// Change the text.
			$(this).html('PLAY');

		} else {

			// Remove class="pause".
			pause = false;

			// Start the rotation.
			rotate('#rotator li:visible:first');

			// Change the text.
			$(this).html('PAUSE');

		}

		this.blur();
		return false;
	});
 
 
	// Hide all but first <li>.  

   $('#rotator li:first').show();
		
	
	// Wait for page load.
	$(window).load(function() {	 
		
		// Begin rotation.
		rotate($('#rotator li:visible:first'));
	});
}

// Kick things off.
$(document).ready(function() {
	init_rotator();
});


// ------------- End Of rotator ----------------------------

	
// ----------- show quotes in main page ---------------------

   function showhide(){
    var whichImage = Math.floor(Math.random()*9);
	$(".quotebox img").hide();
	$(".quotebox img").attr("src", "/global/newimages/quotes/tquote" + whichImage + ".png");
	$(".quotebox img").fadeIn(3000);
   }
   
   window.setInterval(showhide, 17000);
	showhide();
  
  // International Select Box Code //
  function switchpage(select) {
  var index;

  for(index=0; index<select.options.length; index++)
    if(select.options[index].selected)
      {
        if(select.options[index].value!="")
          window.location.href=select.options[index].value;
        break;
      }
 }

 // Subnavigation Tree Code //
 menu_status = new Array();
 plus_status = new Array();

function showHide(theid){
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
	}
}

function plusMinus(tree){
    if (document.getElementById) {
    var plus_id = document.getElementById(tree);

        if(plus_status[tree] != 'cOpen') {
           plus_id.className = 'cOpen';
           plus_status[tree] = 'cOpen';
        }else{
           plus_id.className = 'cClosed';
           plus_status[tree] = 'cClosed';
        }
    }
}

function searchmips(){
 var temp = "http://search.mips.com/search?q="+ document.getElementById('gSearch').value;
 window.open (temp);
}

