var isIE =(/\bmsie\b/i.test(navigator.userAgent)&& document.all&&!(/\bopera\b/i.test(navigator.userAgent)));
var isIE6 =(/\bmsie 6.0\b/i.test(navigator.userAgent));
var linguagens = ['pt-br','en','fr','ale'];


//$ = function (a) { return document.getElementById(a); };


function mostraFlash(){
	var id = arguments[0];
	var swf = arguments[1];
	var width = arguments[2];
	var height = arguments[3];
	var parans = arguments[4] || {'scale':'noscale', 'wmode':'transparent'};
	var expressInstall = arguments[5] || '/media/swf/expressinstall.swf';
	
	var so = new SWFObject(swf, id+"movie", width, height, "8", "transparent", true);
	
	for (k in parans) so.addParam(k, parans[k]);
	
	so.useExpressInstall(expressInstall);
	
	so.write(id);
}

function getLinguagem(){ for (b in linguagens) if(document.location.toString().indexOf("/"+linguagens[b]+"/") != -1) return linguagens[b]; }

function apareceMenu(id){
	if (id.toString().indexOf("sub") != -1){
		var arr = id.toString().split("-");
		var top = (21 * parseInt(arr[1]));
		
		$("#"+id).css('top', top+"px");
	}
	$("#"+id).show();
}

function someMenu(id){ $("#"+id).hide(); }

String.prototype.is_mail = function() { return (/^[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?@[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?\.[A-Za-z]{2,4}$/.test(this)); }

var combos = [];
var combo = function(pt){
	for (var k in pt) this[k] = pt[k];	
	
	this.newIdCombo = combos.length;
	
	var newIdCombo = this.newIdCombo;
	
	document.write('<ul id="combo_'+this.id+'_'+this.newIdCombo+'" class="'+this.className+'" style="display:none;" onmouseover="combos['+this.newIdCombo+'].open();">');
	
	/*
	onmouseout="combos['+this.newIdCombo+'].close();"
	*/
	
	$('#'+this.id).find('option').each(function(){
		document.write('<li onclick="combos['+newIdCombo+'].doOnClick(this, \''+$(this).text()+'\');" value="'+$(this).val()+'">'+$(this).text()+'</li>');
	});	
	document.write('</ul>');
	
	
	this.doOnClick = function(obj, text){
		this.value = obj.value;
		this.close();
		this.onClick(obj, text);
		this.toString = function(){ return"[class Combo:Event->onClick]" };
	};
	
	this.open = function(){
		$("#combo_"+this.id+"_"+this.newIdCombo).css('display','block');
		this.onOpen();
		this.toString = function(){ return"[class Combo:Event->onOpen]" };		
	}
	
	this.close = function(){
		$("#combo_"+this.id+"_"+this.newIdCombo).css('display','none');
		this.onClose();
		this.toString = function(){ return"[class Combo:Event->onClose]" };
	}
	
	this.toString = function(){ return"[class Combo]" };
	combos.push(this);
	return this;
}

combo.prototype = {
	'id': '',
	'value': null,
	'className': '',
	'onClick': function(){},
	'onOpen': function(){},
	'onClose': function(){}
}

Date.prototype.getFullString = function() {
	return this.getFullYear()+''+this.getMonth()+''+this.getDate()+''+this.getHours()+''+this.getMinutes()+''+this.getSeconds();
};

// Retorna o tamanho de um objeto
getSize = function (e) {
	if (typeof e == 'string') e = document.getElementById(e);
	return {x:e.offsetWidth, y:e.offsetHeight};
};

// Retorna o scroll da p�gina
getScroll = function () {
	if (self.pageXOffset) {
		sX = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft) {
		sX = document.documentElement.scrollLeft;
	} else if (document.body) {
		sX = document.body.scrollLeft;
	}
	if (self.pageYOffset) {
		sY = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		sY = document.documentElement.scrollTop;
	} else if (document.body) {
		sY = document.body.scrollTop;
	}
	return {x:sX, y:sY};
};

// Retorna o tamanho da �rea visivel
getDocVisibleSize = function () {
	var _x, _y;
	if (window.innerWidth) {
		_x = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		_x = document.documentElement.clientWidth;
	} else if (document.body) {
		_x = document.body.clientWidth;
	}
	if (window.innerHeight) {
		_y = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		_y = document.documentElement.clientHeight;
	} else if (document.body) {
		_y = document.body.clientHeight;
	}
	return {x:_x, y:_y};	
};

// Retorna o tamanho total do documento
getDocSize = function () {
	return {x:document.body.offsetWidth, y:document.body.offsetHeight};
};

// Aplica um valor alpha de 0 a 100
setAlpha = function (e, a) {
	a = Math.round(a);
	if (typeof e == 'string') e = document.getElementById(e);
	with (e.style) {
		if (isIE) {
			filter = 'alpha(opacity='+a+')';
		} else {
			opacity = a/100;
		}
	}
};

var bgSite = {
	'show': function() {
		setAlpha('bgSite', 80);
		document.getElementById('bgSite').style.height = getDocSize().y+13+'px';
		document.getElementById('bgSite').style.display = 'block';
		var obj = document.getElementsByTagName('SELECT');
		for (var i = 0; i < obj.length; i++) {
			obj[i].style.display = "none";
		}
	},
	'hide': function() {
		document.getElementById('bgSite').style.display = 'none';
		var obj = document.getElementsByTagName('SELECT');
		for (var i = 0; i < obj.length; i++) obj[i].style.display = "block";
	},
	'alinha': function(){
		var newY;
		newY = (getDocVisibleSize().y > getDocSize().y)?getDocVisibleSize().y:getDocSize().y;
		document.getElementById('bgSite').style.width = getDocSize().x+'px';
		document.getElementById('bgSite').style.height = newY+'px';
	}
};

String.prototype.isWhite = function() {
  if (!isVoid(this)) {
	var value = this.replace(/^\s+/m,'').replace(/\s+$/m,'');
    return (value == '');
  }
  return true;
}

function validateEmail(email) {
  return (/^[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?@[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?\.[A-Za-z]{2,4}$/.test(email));
}

function isVoid(obj) {
	if (obj != null && typeof obj != 'undefined' && obj != "") return false;
	return true;
}

window.intervalstopscroll = null;
window.onstopscroll2 = function(){
	//SA.alinha();	
}
window.onscroll = function() {
	clearTimeout(window.intervalstopscroll);
	window.intervalstopscroll = setTimeout('window.onstopscroll2();window.onstopscroll();', 50);
};
window.onstopscroll = new Function();
