// JavaScript Document
function getFlashMovieObject(movieName){
		if (window.document[movieName])
		  return window.document[movieName];
		if (navigator.appName.indexOf("Microsoft Internet") == -1)
			if (document.embeds && document.embeds[movieName])
			  return document.embeds[movieName];
		else
			return document.getElementById(movieName);
}

function goBrokers(){
	document.location.href = "brokers-team";
}

function goProducts(){
	document.location.href = "products";
}

function un_combo_ha_cambiado(){
	swf = getFlashMovieObject("id_banner");
	return swf.callJavaScriptOnChangeCombo();
}

function on_change_combo_filto($str_tipo){
	un_combo_ha_cambiado();
}

function get_valor_del_filtro($str_id_combo){
	return document.getElementById($str_id_combo).value;
}

function reset_filtros(){
	document.getElementById("combo_categorias").value = 0;
	document.getElementById("combo_uploaded").value = 0;
	document.getElementById("combo_consultant").value = 0;
}


function doMenuOver($str_menu){
	document.getElementById("menu_"+$str_menu+"_out").style.display = "none";
	document.getElementById("menu_"+$str_menu+"_over").style.display = "inline";
}
function doMenuOut($str_menu){
	document.getElementById("menu_"+$str_menu+"_out").style.display = "inline";
	document.getElementById("menu_"+$str_menu+"_over").style.display = "none";
}


function closeItem($id){
	document.getElementById("desc_corta_" + $id).style.display = "inline" ;
	document.getElementById("desc_larga_" + $id).style.display = "none" ;
	document.getElementById("item_cerrar_" + $id).style.display = "none" ;
}
function expandItem($id){
	document.getElementById("desc_corta_" + $id).style.display = "none" ;
	document.getElementById("desc_larga_" + $id).style.display = "inline" ;
	document.getElementById("item_cerrar_" + $id).style.display = "inline" ;
}
function validateForm()
{
	hide_errors();
	if(_('name').value == '')
	{
		_('name_error').style.display = 'block';
		_('name').style.backgroundColor = '#feb2b2';
		return false;	
	}
	else
	{
		_('name').style.backgroundColor = '#ffffff';
	}
	if(_('last_name').value == '')
	{
		_('last_name_error').style.display = 'block';
		_('last_name').style.backgroundColor = '#feb2b2';
		return false;	
	}		
	else
	{
		_('last_name').style.backgroundColor = '#ffffff';
	}
	if(_('email').value == '' || !/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/.test(_('email').value))
	{
		_('email_error').style.display = 'block';
		_('email').style.backgroundColor = '#feb2b2';
		return false;	
	}		
	else
	{
		_('email').style.backgroundColor = '#ffffff';		
	}
	if(
	   _('phone_1').value == '' || _('phone_2').value == '' || _('phone_3').value == ''
	   || !/^[0-9]+$/.test(_('phone_1').value) || !/^[0-9]+$/.test(_('phone_2').value) || !/^[0-9]+$/.test(_('phone_3').value)
		)
	{
		_('phone_error').style.display = 'block';
		_('phone_1').style.backgroundColor = '#feb2b2';
		_('phone_2').style.backgroundColor = '#feb2b2';
		_('phone_3').style.backgroundColor = '#feb2b2';				
		return false;	
	}	
	else
	{
		_('phone_1').style.backgroundColor = '#ffffff';
		_('phone_2').style.backgroundColor = '#ffffff';
		_('phone_3').style.backgroundColor = '#ffffff';						
	}
	
	return true;
}
function _(element)
{
	return document.getElementById(element);	
}
function hide_errors()
{
	_('name_error').style.display = 'none';
	_('last_name_error').style.display = 'none';
	_('email_error').style.display = 'none';		
	_('phone_error').style.display = 'none';				
	
}

function sendForm()
{
	if(validateForm())
	{
		var time;
		var analyze;
		if(_('time_am').checked)
			time = '0';
		else
			time = '1';
			
		if(_('analyze').checked)
			analyze = '1';
		else
			analyze = '0';
		
					_('last_name_error').innerHTML = '';
		_('email_error').innerHTML = '';
		_('phone_error').innerHTML = '';			
		_('name_error').innerHTML = '';
		
		petision('_send_form.php', 'form', 'POST', 'name='+_('name').value+'&last_name='+_('last_name').value+'&email='+_('email').value+'&phone='+_('phone_1').value+'-'+_('phone_2').value+'-'+_('phone_3').value+'&interest='+_('interest').value+'&analyze='+analyze+'&time='+time+'&captcha='+_('captcha').value);
		
		

	}
}

function changeSRC(img, url)
{
	img.src = url;
}

function cargar_lista()
{
	var category = _('combo_categorias').value;
	var broker = _('combo_consultant').value;	
	var date = _('combo_uploaded').value;	
	
	petision('_lista_videos.php', 'grilla_videos', 'POST', 'category='+category+'&broker='+broker+'&date='+date);
	
}
