/* Helper Functions */
jQuery.fn._height = jQuery.fn.height;
jQuery.fn._width  = jQuery.fn.width;
jQuery.fn.height = function() {
	if ( this[0] == window ) return self.innerHeight || jQuery.boxModel && document.documentElement.clientHeight || document.body.clientHeight;	
	if ( this[0] == document ) return Math.max( document.body.scrollHeight, document.body.offsetHeight );	
	return this._height(arguments[0]);
};
jQuery.fn.width = function() {
	if ( this[0] == window ) return self.innerWidth || jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth;	
	if ( this[0] == document ) return Math.max( document.body.scrollWidth, document.body.offsetWidth );	
	return this._width(arguments[0]);
};
/* End Helper Functions */


function addFlash(file, w, h){
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'width', w,
		'height', h,
		'src', file,
		'movie', file,		
		'scale', 'noScale',
		'wmode', 'transparent',
		'menu', 'false',
		'AllowScriptAccess', 'always'
	); //end AC code	
}

function linksParceirosCheck() {
	if ($(window).width() < 1000) {
		$('#links_parceiros').hide();
	}
	else {
		$('#links_parceiros').show();
	}
}

function setVitrineLink(url, win, txt) {
	$('#destaque_link_vitrine a').attr('href', url).attr('target', win).text(txt);
}

// Esse objeto controla o over das imagens do menu de sites
MainMenu = {			
	aImgs : [],
	active : 0,
		 
	init : function (imgs, active) {
		this.active = active;
		for (key in imgs){
			this.addImage(key, imgs[key]);
		}
	},
		
	addImage : function(id, src) {
		this.aImgs[id] = new Image();
		this.aImgs[id].src = src;
	},
		
	over : function(id) {
		if(id == this.active) return;
		
		$('div#sites_menu_img img').attr('src', this.aImgs[id].src);
	},
	
	out : function() {
		$('div#sites_menu_img img').attr('src', this.aImgs[this.active].src);
	}
}

$(document).ready(function(){
	$('#main_menu ul > li').hover(function(){		
		var ul = $('ul', this);
		if(!ul.attr('bg_w')){
			ul.show().find('li').width(ul.width() + "px");	
			ul.attr('bg_w', '1');
		}
		else{
			ul.show();	
		}		
	}, function(){$('ul', this).hide();});
});




