﻿jQuery.noConflict();

jQuery(document).ready(function() {
	if (jQuery.browser.msie == false || jQuery.browser.version.substr(0,1)>6) {
		jQuery('.containerMainTab li')
		.focusin(function(e) {
			jQuery(this)
				.data('hasFocus',true)
				.children('.containerDropDown').addClass('hover');
		})
		.focusout(function(e){
			var self = this;
			jQuery(this).data('hasFocus',false);
			setTimeout(function(){
				if(!jQuery(self).data('hasFocus')) {
					jQuery(self).children('.containerDropDown').removeClass('hover');
				}
			});
		});
	}

	jQuery(".readMore a").click(function(e){
		e.preventDefault();
		window.open(this.href,'popup','width=800,height=550, scrollbars,resizable=1');
	});
	jQuery(".contentBlock08a h3 a").click(function(e){
		e.preventDefault();
		window.open(this.href,'popup','width=800,height=550, scrollbars,resizable=1');
	});
	jQuery(".contentBlock13 li a").click(function(e){
		e.preventDefault();
		window.open(this.href,'popup','width=800,height=550, scrollbars,resizable=1');
	});

	jQuery('#textSize').fontSize();	

	
	if(jQuery('.contentBlock13a').length != 0){
    var timer = parseInt(jQuery('#refreshTime').val())*1000;
    //console.log(timer);
    if(jQuery('.contentBlock13a > ul').children().length > 1)
      iTimerID = setInterval(doRoll, timer);
	}
});

var listIndex = 0;

function doRoll(){
  var list = jQuery('.contentBlock13a > ul');
  
  var listLength = jQuery(list).children();
    if (listIndex != (listLength.length-1)){
      jQuery(list).animate({
        'margin-top': '-=30'
      }, 3000, function() {
        listIndex = listIndex + 1;
      });
    }else{
    
      jQuery(list).animate({
        'margin-top': '-=15'
      }, 1500, function() {
      
        jQuery(this).css({'margin-top': '30px'});
        
        jQuery(this).animate({
          'margin-top': '-=30'
        }, 1500, function() {
          listIndex = 1;
        });
        
      });
      
    }
}

function showHide(id){
 jQuery('#'+id).slideToggle('slow');
} 


function getOutBoundLinks(){
	jQuery('a').each(function(){
		if(jQuery(this).attr('href').substr(0, 4) == 'http'){
			jQuery(this).click(function(){
				_gaq.push(['_trackEvent', 'outbound', 'URL:' + jQuery(this).attr('href'), location.href]);
			});
		}
	});
}

function trackThis($node, category, action, linked){
	action = action || 'URL:' + $node.attr('href');
	_gaq.push(['_trackEvent', category, action, location.href]);
	if(linked){
		_gaq.push(['_link', $node.attr('href')]);
	}
}
