// JavaScript Document

function open_url(url,lang)
{
	document.location.href = url + lang;
}

function link_jump(el, url)
{
	if(window.confirm(el))
	{
		document.location.href = url;
	}
}

function modific_campo(value, name)
{
	document.getElementById('artista_temp').value = value;
	document.getElementById('campo_view').style.display = "none";
	document.getElementById('campo_artista').style.display = "";
	document.getElementById('name_artista').innerHTML = name;
}

function limpiar_artista()
{
	document.getElementById('artista_temp').value = "";
	document.getElementById('campo_view').style.display = "";
	document.getElementById('campo_artista').style.display = "none";
	document.getElementById('name_artista').innerHTML = "";
}

function pago_change(array_pago)
{
	var obj_plan, obj_ciclo, obj_context;
	obj_plan = document.getElementById('plan');
	obj_ciclo = document.getElementById('ciclo');
	obj_context = document.getElementById('pago_view');
	
	if(array_pago[obj_plan.value] != '')
	{
		var sub_resultado = array_pago[obj_plan.value];
		obj_context.innerHTML = '$' +  (eval(sub_resultado) * eval(obj_ciclo.value));
	}
}

function search_user()
{
	var form_view, type_s;
	form_view = document.getElementById('form_search');
	type_s = document.getElementById('type_search');
	
	if(type_s.value == '1')
	{
		form_view.action = 'artistas';
		form_view.submit();
	}
	else if(type_s.value == '2')
	{
		form_view.action = 'obras';
		form_view.submit();
	}
	else if(type_s.value == '3')
	{
		form_view.action = 'actividades';
		form_view.submit();
	}
}

function search_website()
{
	var form_view, type_s, text_s;
	form_view = document.getElementById('form_search_general');
	type_s = document.getElementById('type_search_general');
	text_s = document.getElementById('text_search_general').value;
	
	if(type_s.value == '1')
	{
		form_view.action = 'artistas';
		document.getElementById('search_artista').value = text_s;
		form_view.submit();
	}
	else if(type_s.value == '2')
	{
		form_view.action = 'galerias';
		document.getElementById('search_galeria').value = text_s;
		form_view.submit();
	}
	else if(type_s.value == '3')
	{
		form_view.action = 'eventos';
		document.getElementById('search_eventos').value = text_s;
		form_view.submit();
	}
	else if(type_s.value == '4')
	{
		form_view.action = 'prensa';
		document.getElementById('search_prensa').value = text_s;
		form_view.submit();
	}
}

function pago_view(num)
{
	var div1, div2, div3;
	div1 = document.getElementById('div_view1');
	div2 = document.getElementById('div_view2');
	div3 = document.getElementById('div_view3');
	
	if(num == 1)
	{
		div1.style.display = "";
		div2.style.display = "none";
		div3.style.display = "none";
	}
	else if(num == 2)
	{
		div1.style.display = "none";
		div2.style.display = "";
		div3.style.display = "none";
	}
	else if(num == 3)
	{
		div1.style.display = "none";
		div2.style.display = "none";
		div3.style.display = "";
	}
	
}

function ismaxlength(obj)
{	
	var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
	
	if (obj.getAttribute && obj.value.length>mlength)
	{
		obj.value = obj.value.substring(0, mlength)
		return obj.value;
	}
}

function add_favorite(url, title)
{
	if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4))
	{
		window.external.AddFavorite(url, title)
	}
	else
	{
		window.sidebar.addPanel(title, url,'');
	}
}

function open_window(url, name, witdh, height)
{
	window.open(url,name,"menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=" + witdh +",height=" + height);
}

function Ajax_view()
{
	var xmlhttp=false;
 	try
	{
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	}
	catch (e) 
	{
 		try 
		{
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		}
		catch (E)
		{
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
 		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}

function list_imagen(num, cont, text)
{
	var contenedor;
	contenedor = document.getElementById(cont);
	
	if(num > 0)
	{		
	
		ajax=Ajax_view();
		ajax.open("GET", 'artista_ajax_list' + num, true);
		ajax.onreadystatechange=function() {
			if(ajax.readyState==1)
			{
				contenedor.innerHTML = text;
			}
			else if(ajax.readyState==4)
			{
				contenedor.innerHTML = ajax.responseText
			}
		}
		
		ajax.send(null)
		
	}
}

function pages_list_obras(cont, pages, type, artista)
{
	var contenedor;
	contenedor = document.getElementById(cont);
	
	ajax=Ajax_view();
	ajax.open("GET", 'obras_ajax_list' + pages + '_type' + type + '_artista' + artista, true);
	ajax.onreadystatechange=function() {
		if(ajax.readyState==1)
		{
			contenedor.style.MozOpacity = "20%";
			contenedor.style.filter = "alpha(opacity=20)";
		}
		else if(ajax.readyState==4)
		{
			contenedor.style.MozOpacity = "100%";
			contenedor.style.filter = "alpha(opacity=100)";
			contenedor.innerHTML = ajax.responseText
		}
	}
	
	ajax.send(null)
}

function artistas_listado(cont, artista)
{
	var contenedor;
	contenedor = document.getElementById(cont);
	
	ajax=Ajax_view();
	ajax.open("GET", 'artista_ajax_name_' + artista, true);
	ajax.onreadystatechange=function() {
		if(ajax.readyState==1)
		{
			contenedor.innerHTML = '<div align="center" style="padding: 5px;"><img src="../img/loading.gif" border="0"></div>';
		}
		else if(ajax.readyState==4)
		{
			contenedor.innerHTML = ajax.responseText
		}
	}
	
	ajax.send(null)
}