
function redireccionar(idioma) 
{
	var idioma, dir
			   switch (idioma){
				case 1:
				idioma="es"
				break;
				case 2:
				idioma="en"
				break;
				case 3:
				idioma="pt"
				break;
				case 4:
				idioma="fr"
				break;
				case 5:
				idioma="de"
				break;
				case 6:
				idioma="zh"
				break;
				case 7:
				idioma="qu"
				break;
				case 8:
				idioma="ay"
				break;
				default :
				idioma="es"
				}	
		

		if ( (screen.width =='800') && (screen.height =='600') )
		{
			switch (idioma){
				case "es":
				dir = "index1.asp";
				break;
				case "en":
				dir = "index1_uk.asp";
				break;
				case "ay":
				dir = "index1_ay.asp";
				break;
				case "qu":
				dir = "index1_qe.asp";
				break;
				case "pt":
				dir = "index1_br.asp";
				break;
				case "fr": 
				dir= "index1_fr.asp";
				break;
				case "de":
				dir = "index1_de.asp";
				break;
				case "zh":
				dir = "index1_cn.asp";
				break;
				default :
				dir = "index1.asp";
				break;
				}	
				
		}
		else
		{
			switch (idioma){
				case "es":
				dir = "index2.asp";
				break;
				case "en":
				dir = "index2_uk.asp";
				break;
				case "ay":
				dir = "index2_ay.asp";
				break;
				case "qu":
				dir = "index2_qe.asp";
				break;
				case "pt":
				dir = "index2_br.asp";
				break;
				case "fr": 
				dir= "index2_fr.asp";
				break;
				case "de":
				dir = "index2_de.asp";
				break;
				case "zh":
				dir = "index2_cn.asp";
				break;
				default :
				dir = "index2.asp";
				break;				
				}	
		}
		
		
		location.href=dir;	
		
}


function GoPage(Idioma) {

	location.href="http://www.petroperu.com.pe/PortalWeb/Main.asp?Idioma="+Idioma
}

function GoPage2(Idioma) {

	location.href="http://www.petroperu.com.pe/Main.asp?Idioma="+Idioma
}

function sendit(filename) 
	{
		location.href=filename
	}
	
function validarBuscarGeneral( val )
{
	if (val=="")
	{
		alert("Por favor, ingrese el termino de busqueda");
		document.fregistro.txtasunto.focus();
		return false;
	}
	
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú0123456789";
  var checkStr = val;
  
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      {if (ch == checkOK.charAt(j))
        break;
       if (j == checkOK.length) { 
       allValid = false; 
       break; 
      }
	  }
    }
  if (!allValid) { 
    alert("Por favor, Escriba caracteres validos"); 	
    return false; 
  }  
  
	if (val.length<3)
	{
		alert("Por favor, debe ingresar un termino no menor a 3 caracteres.");
		document.fregistro.txtasunto.focus();
		return false;
	}	

	return true;
}


function BusquedaGeneral()
{
	v = document.fregistro.txtasunto.value;

	if ( validarBuscarGeneral( v ) )
	{
		parent.location.href='Buscador.asp?q='+v;
	}
	
	
} 
function Busqueda()
{
	v = document.fregistro.txtasunto.value;

	if ( validarBuscarGeneral( v ) )
	{
		parent.location.href='index.asp?q='+v;
	}
	
	
} 
function BusquedaNoticia()
{
	v = document.frmBuscador.Noticia.value;

	if ( validarBuscarGeneral( v ) )
	{
		location.href='BuscadorNoticia.asp?q='+v;
	}
	
	
} 
function clearText(thefield){
	if (thefield.defaultValue == thefield.value)
	thefield.value = ""
} 

function Enlaces(idSeccion)
{
  location.href="Main.asp?Seccion="+idSeccion         
		  
}


//--------------Desplegar---------------//
var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style>.switchcontent{display:none;}<\/style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
//selectedComponents=selectedItem.split("|")
//for (i=0; i<selectedComponents.length-1; i++)
//document.getElementById(selectedComponents[i]).style.display="block"
}


function getselectedItem(){
//if (get_cookie(window.location.pathname) != ""){
//selectedItem=get_cookie(window.location.pathname)
//return selectedItem
//}
//else
//return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
//if (enablepersist=="on" && typeof ccollect!="undefined"){
//document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0"
//firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
//if (!firsttimeload)
revivecontent()
//}
}

function VerVideo(idVideo)
{
	ventana = "ReproducirVideo.asp?IdVideo=" + idVideo
      open (ventana,"", "toolbar=no,scrollbars=yes,width=620,height=500,directories=no,menubar=no, noresize=no");
	}
	
function Audio(Title, Filename, Format) {

document.writeln('<table><tr><td class="textom" valign="center">'+ Title +'</td><td>')
document.writeln('<object type="application/x-shockwave-flash" data="images/dewplayer-multi.swf?mp3=UpLoad/UpLoaded/' + Format + '/' + Filename + '" width="200" height="20">');
document.writeln('<param name="movie" value="images/dewplayer-multi.swf?mp3=UpLoad/UpLoaded/' + Format + '/' + Filename + '" />  </object>');
document.writeln('</td> </table>')
}

	
function OnlyAudio(Title, Filename, Format) {

document.writeln('<object type="application/x-shockwave-flash" data="images/dewplayer-multi.swf?mp3=UpLoad/UpLoaded/' + Format + '/' + Filename + '" width="200" height="20">');
document.writeln('<param name="movie" value="images/dewplayer-multi.swf?mp3=UpLoad/UpLoaded/' + Format + '/' + Filename + '" />  </object>');

}
	
	
function GoURL(URL)
{
 window.open(URL);
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate
