$(document).ready(function(){
	$("head").prepend('<style>.rounded {  position:relative; } .lt, .lb, .rt, .rb, .left_home, .right_home, .rthome, .rbhome { position:absolute; z-index:3010;display:block;text-indent:-9999px; height:10px;width:10px; background-repeat:no-repeat; } .lt, .lthome { left:0; top:0; background-position:left top; } .lb, .lbhome { left:0; bottom:0; background-position:left bottom; } .rt, .rthome { right:0; top:0; background-position:right top; }.rb, .rbhome {right:0; bottom:0; background-position:right bottom; }</style>');
	$(".rounded").append('<span class="lt"></span><span class="rt" /><span class="rb" /><span class="lb" />');
	$(".roundedMain").append('<span class="left_home"></span><span class="right_home" />');
	//$(".roundedBottom").append('<span class="rbhome" /><span class="lbhome" />');
	$(".top-bottom").append('<span class="top" /><span class="bottom" />');
	
	var menuPath = (window.location.pathname).split('/');
	var menuPath = menuPath[1];
	
	if (menuPath == 'o-que-vendemos') {
		$("ul#menu-principal a.o-que-vendemos").addClass("ativo");
	} else if (menuPath == 'plataforma-ikeda') {
		$("ul#menu-principal a.plataforma-ikeda").addClass("ativo");
	} else if (menuPath == 'clientes') {
		$("ul#menu-principal a.clientes").addClass("ativo");
	} else if (menuPath == 'parceiros') {
		$("ul#menu-principal a.parceiros").addClass("ativo");
	} else if (menuPath == 'quem-e-ikeda') {
		$("ul#menu-principal a.quem-e-ikeda").addClass("ativo");
	} else if (menuPath == 'suporte') {
		$("ul#menu-principal a.suporte").addClass("ativo");
	} else if (menuPath == 'administrativo') {
		$("ul#menu-principal a.administrativo").addClass("ativo");
	} 
	
	var sidebarAba = $(".sidebar ul.botoes-home li a");
	sidebarAba.click(function(){
		if( $(this).hasClass("blog") || $(this).hasClass("eventos")){
			var css = $(this).attr("class").split(' ');
			$(".content").hide();
			$("." + css[1]).show();

			$.each(sidebarAba, function(index, item) {
				var current = $(item).attr("class");
				$(item).attr("class", current.replace("on", "off"));
			});

			$(this).attr("class", css.join(" ").replace("off", "on"))
			return false;
		}
	});
	
	$(".campo").addClass("idleField");
	
	$(".campo").focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$(".campo").blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
});

function OrderTicker()
{
	if (document.getElementById("span_pedidos"))
	{
		home_Default.OrderTicker(callback_OrderTicker);
	}
}

function callback_OrderTicker(res)
{
	if (res.error)
	{
		alert(res.error);
	}
	else if (res.value)
	{
		if (document.getElementById("span_pedidos"))
		{
		    if (res.value != "")
		    {
			    document.getElementById("span_pedidos").innerHTML = res.value;
			}
			
			setTimeout("OrderTicker()", 5000);
		}
	}
}

function exibiFlash (arquivo, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
	document.write('<param name="movie" value="' + arquivo + '">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="' + arquivo + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	document.write('</object>');
}

function SomenteNumero(e)
{
	var key;

	if (window.event)
		key = event.keyCode;
	else
		key = e.which;

	if(key > 47 && key < 58 || key == 8 || key == 0)
		return;
	else
	{
		if(window.event)
			window.event.returnValue = null;
		else
			e.preventDefault();
	}
}

function SomenteNumero2(e, src, mask)
{
	SomenteNumero(e);

	var key;

	if (window.event)
		key = event.keyCode;
	else
		key = e.which;

	if(	key != 8)
		Mascara(src,mask);
}

function Mascara(src, mask)
{
	 var i = src.value.length;
	 var saida = mask.substring(0,1);
	 var texto = mask.substring(i)
	 
	 if (texto.substring(0,1) != saida)
		  src.value += texto.substring (0,1);
}
