function verificaInput(obj,val){
  
  var valor = obj.value;
  
  if(valor == unescape(json[23]) || valor == val)
    obj.value = "";
	
  else if(valor == "")
	
    obj.value = val;
	
}


function verificaPesquisa(form){
  
  var formulario = document.getElementById(form);
  var txt = formulario.pesq;
  var texto = txt.value;
  var error;
  
  if((txt.value=="") || (txt.value==unescape(json[23]))){
    alert(unescape(json[24]));
    error = 1;
  }else if(txt.value!="" &&  texto.length<3){
    alert(unescape(json[25]));
    error = 2;
    
  }
  
  if((txt.value!=unescape(json[23])) && (texto.value!="") && (texto.length>=3)){
   error=0;
  }
  
  if(error>0){
    return false;
  }else {
    return true;
  }
  
}


function montavideo2(video,w,h,tipo) {
  
  
  
  var bw = jQuery('body').width();
  var bh = jQuery('body').height();
  
  
  jQuery('#fundo_opaco').css('width',bw + "px");
  jQuery('#fundo_opaco').css('height',bh + "px");
  
  var _left = (bw - w)/2;
  var _top = (bh - h)/2;
  
  jQuery('#div_flash').css("left",_left + "px");
  jQuery('#div_flash').css("top",_top + "px");
  
  
  if(tipo == 1)
    jQuery('#flash3_Mov').html("<object width='" + w + "' height='" + h + "' ><param name='movie' value='"+ video +"' ></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='"+ video +"' type='application/x-shockwave-flash' width='" + w + "' height='" + h + "' allowscriptaccess='always' allowfullscreen='true'></embed></object>");
	else if(tipo == 2)
	 jQuery('#flash3_Mov').html("<iframe src='"+ video +"' width='" + w + "' height='" + h + "' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>");
	
	jQuery('#div_flash').css('height',jQuery('#flash3_Mov embed').css('height'));
  jQuery('#div_flash').css('width',jQuery('#flash3_Mov embed').css('width'));
	
	jQuery('#btn_flash').show();
	jQuery('#div_flash').show();
	jQuery('#flash3_Mov').show();
		
	jQuery('#fundo_opaco').show(100);	
	
	
	
}

function montavideo(lg,id,w,h) {
  
  
  
  var bw = jQuery('body').width();
  var bh = jQuery('body').height();
  
  
  jQuery('#fundo_opaco').css('width',bw + "px");
  jQuery('#fundo_opaco').css('height',bh + "px");
  
  var _left = (bw - w)/2;
  var _top = (bh - h)/2;
  
  jQuery('#div_flash').css("left",_left + "px");
  jQuery('#div_flash').css("top",_top + "px");
  
  
  var flash = "flash/video" + id + "_"+ lg +".flv";
  
	var fo2 = new FlashObject("flash/video2.swf", "movie"+id,w,h, "9", "000000");
	fo2.addParam("wmode", "transparent");
	fo2.addParam("allowFullScreen", "true");
	
  fo2.addVariable("videoID","http://www.cinca.pt/" + flash);
  fo2.addVariable("typePlay", true);
	fo2.write("flash3_Mov");
	
	
	
	jQuery('#div_flash').css('height',jQuery('#flash3_Mov embed').css('height'));
  jQuery('#div_flash').css('width',jQuery('#flash3_Mov embed').css('width'));
	
	jQuery('#btn_flash').show();
	jQuery('#div_flash').show();
	jQuery('#flash3_Mov').show();
		
	jQuery('#fundo_opaco').show(100);	
	
	
	
}


function fechavideo(){
  
  jQuery('#fundo_opaco').hide(300,function(){
  	jQuery('#flash3_Mov').hide(function(){
        jQuery('#flash3_Mov').empty();
        
  	    jQuery('#div_flash').hide();
    });
	});
}

function mostraVideo(lg,id,w,h) {
  
  
  
  
  
  
  var flash = "flash/banner" + id + "_"+ lg +".flv";
  
	var fo2 = new FlashObject("flash/video2.swf", "movie"+id,w,h, "9", "000000");
	fo2.addParam("wmode", "transparent");
	fo2.addParam("allowFullScreen", "true");
	//fo2.addVariable("servidor", "http://www.livromilionario.com");
  fo2.addVariable("videoID","http://www.cinca.pt/" + flash);
  fo2.addVariable("typePlay", true);
	fo2.write("videoBanner");
	
	
	
	jQuery('#videoBanner').css('height',jQuery('#videoBanner embed').css('height'));
  jQuery('#videoBanner').css('width',jQuery('#videoBanner embed').css('width'));
	
	
	
	jQuery('.topovideo').show(100);	
	jQuery('#videoBanner').show();
	
	jQuery('.containervideo').show();
	jQuery('.movie').show();
	
	
	
	// ]]>
}

function fechaVideoBanner(){
  
  jQuery('.movie').hide(300,function(){
  	jQuery('.containervideo').hide(function(){
        jQuery('#videoBanner').empty();
    });
	});
}


var childsNews;
var curNew = 1;
function NewsSlider(){
	jQuery('ul.ulnewshome > li.current > span:first').text(1);
	jQuery('ul.ulnewshome > li.current > span + span').text(jQuery('.wrappernews').children().length);

	childsNews = jQuery('.wrappernews').children();
	jQuery(childsNews[0]).show(500);
	
	jQuery('ul.ulnewshome > li > a.prev2').click(function(ev){
		ev.preventDefault();
		
		jQuery(childsNews[curNew - 1]).hide(500, function(){
			if(curNew == 1){
				jQuery(childsNews[childsNews.length - 1]).show(500);
				curNew = childsNews.length;
				jQuery('ul.ulnewshome > li.current > span:first').text(curNew);
			}
			else{
				jQuery(childsNews[curNew - 2]).show(500);
				curNew--;
				jQuery('ul.ulnewshome > li.current > span:first').text(curNew);
			}
		}).delay(1000);
	});
	
	jQuery('ul.ulnewshome > li > a.next2').click(function(ev){
		ev.preventDefault();
		
		jQuery(childsNews[curNew - 1]).hide(500, function(){
			if(curNew == childsNews.length){
				jQuery(childsNews[0]).show(500);
				curNew = 1;
				jQuery('ul.ulnewshome > li.current > span:first').text(curNew);
			}
			else{
				jQuery(childsNews[curNew]).show(500);
				curNew++;
				jQuery('ul.ulnewshome > li.current > span:first').text(curNew);
			}
		}).delay(1000);
	});
}
function EventSubMenuTop(){

  jQuery('ul.menuheader > li').hover(function(){
		jQuery('ul.submenuheader:not(:animated)', this).show(0, function(){
			SetSubmenuWidthIE7(jQuery(this));
		});
		
	}, function(){
		jQuery('ul.submenuheader:not(:animated)', this).hide(0);
	});
	
} 
function EventSubMenuTop2(){

  jQuery('ul.submenuheader > li').hover(function(){

		jQuery('ul.submenuheader2:not(:animated)', this).show(0, function(){
		
			SetSubmenuWidthIE7(jQuery(this));
		});
		
	}, function(){
		jQuery('ul.submenuheader2:not(:animated)', this).hide(0);
	});
} 
function SetSubmenuWidthIE7(that){
	if(jQuery.browser.msie && jQuery.browser.version == '7.0'){
		var childs = jQuery('li', that);
		var maxW = 0;
		
		childs.each(function(){
			var thatW = jQuery(this).outerWidth();
      
     // alert(maxW);
			if(thatW > maxW){
				maxW = thatW;
			}
		});
		
		that.width(maxW);
	}
}

jQuery(document).ready(function(){
	EventSubMenuTop();
	EventSubMenuTop2();

	});

/*jQuery("ul.submenuheader > li").live("mouseover",function(){

  SetSubmenuWidthIE7(jQuery(this));
  jQuery(".submenuheader2",jQuery(this)).show();
});

jQuery("ul.submenuheader > li").live("mouseout",function(){
  jQuery(".submenuheader2",jQuery(this)).hide();
});*/

jQuery(".submenuheader2 li").live("mouseover",function(){
  jQuery(".submenuheader3",jQuery(this)).show();

});

jQuery(".submenuheader2 li").live("mouseout",function(){
  
  jQuery(".submenuheader3",jQuery(this)).hide();

});

