
/*
* Utilidades js para caravanonline
* version 1: 04/09/2008
*
*
*/

function expandcollapse (pProId, pCountryId) {
  
  //whichpost = document.getElementById(postid);
  collapseall();
  //expandById(postid);
  expand(pProId, pCountryId);
  /*if (whichpost.className=="postshown") {
    whichpost.className="posthidden";
  } else {
    whichpost.className="postshown";
  }*/
  
}

function collapseall () {
  var n = 1;
  for (1; n < 6; n++) {
    whichpost = document.getElementById("protab" + n);
    whichspan = document.getElementById("proexpander" + n);  
    
    if (whichpost != null) {
      whichpost.className="posthidden"
    }
    if (whichspan != null) {
      whichspan.innerHTML="[+]"
    }
  }
}

function expand(pId, pCountryId) {
  
  whichpost = document.getElementById("protab" + pId);
  whichspan = document.getElementById("proexpander" + pId);
  //alert(whichexpander.value);
  changeMainMapUrl(pId, pCountryId);
  changeMainTitleGroupUrl(pId, pCountryId);
  if (whichpost != null) {
    whichpost.className="postshown"
  } else {
    //alert("No  hay menu para proveedor " + pId);
    whichpost = document.getElementById("protab1");
    if (whichpost != null)
      whichpost.className="postshown";
    
    changeMainMapUrl(1, pCountryId);
    changeMainTitleGroupUrl(1, pCountryId);
  }
  if (whichspan != null) {
      whichspan.innerHTML="[-]"
  }
}

function expandById(pId) {
  whichpost = document.getElementById(pId);
  
  if (whichpost != null) {
    whichpost.className="postshown"
  }
}



function changeMainMapUrl(pId, pCountryId) {
  lcurrentElement = document.getElementById("mainmapurl");

  if (pCountryId == "34") 
    pCountryId = "esp";
  
  if (pCountryId == "49") 
    pCountryId = "ger";
    
  if (pCountryId == "351") 
    pCountryId = "por";
    
  if (pCountryId == "33") 
    pCountryId = "fra";
    
  if (pCountryId == "31") 
    pCountryId = "hol";
  
  if (pCountryId == "39") 
    pCountryId = "ita";
  
  if (lcurrentElement != null) {
    //alert(lcurrentElement + "\n" + lcurrentElement.src);
    
    if (pId == 1) {
      lcurrentElement.src = "../imagenes/" + pCountryId + "/map_mcrent_" + pCountryId + ".jpg";
    } else if (pId == 2) {
      lcurrentElement.src = "../imagenes/" + pCountryId + "/map_drm_" + pCountryId + ".jpg";
    } else if (pId == 3) {
      lcurrentElement.src = "../imagenes/" + pCountryId + "/map_blurent_" + pCountryId + ".jpg";
    } 
    
    //lcurrentElement.src = temp[pId];
  }
}

function changeMainTitleGroupUrl(pId, pCountryId) {
  lcurrentElement = document.getElementById("maintitlegroupurl");

  if (pCountryId == "34") 
    pCountryId = "esp";
  
  if (pCountryId == "49") 
    pCountryId = "ger";
    
  if (pCountryId == "351") 
    pCountryId = "por";
    
  if (pCountryId == "33") 
    pCountryId = "fra";
    
  if (pCountryId == "31") 
    pCountryId = "hol";
  
  if (pCountryId == "39") 
    pCountryId = "ita";
  
  if (lcurrentElement != null) {
    //alert(lcurrentElement + "\n" + lcurrentElement.src);
    
    if (pId == 1) {
      lcurrentElement.src = "../imagenes/" + pCountryId + "/title_group_mcrent_" + pCountryId + ".jpg";
    } else if (pId == 2) {
      lcurrentElement.src = "../imagenes/" + pCountryId + "/title_group_drm_" + pCountryId + ".jpg";
    } else if (pId == 3) {
      lcurrentElement.src = "../imagenes/" + pCountryId + "/title_group_blurent_" + pCountryId + ".jpg";
    }
    
    //lcurrentElement.src = temp[pId];
  }
}

/*
* Submit generico de formularios
* 
*/

function submitForm(pForm, pTarget) {
  //alert("Submit del formulario: \n " + pForm + "\n" + pTarget);
  lForm = document.getElementById(pForm);
  //alert("Submit del formulario: \n " + pForm + "\n" + pTarget + "\n---------\n" + lForm + "\n" + lForm.action );
  lForm.action = pTarget;
  
  lForm.submit();
  
}

function submitForm(pForm, pTarget, pOp) {
  //alert("Submit del formulario: \n " + pForm + "\n" + pTarget);
  lForm = document.getElementById(pForm);
  //alert("Submit del formulario: \n " + pForm + "\n" + pTarget + "\n---------\n" + lForm + "\n" + lForm.action + "\npOp: " + pOp);
  lForm.action = pTarget;
  lForm.elements["pOp"].value = pOp;
  
  lForm.submit();
  
}

function setFocus(pElement) {
  //alert("Focus a " + pElement);
  document.forms[0].elements[pElement].focus();
}

function MM_openBrWindow(theURL,winName,features) { 
      //alert("Document3\n" + theURL + "\n" + winName + "\n" + features);
      window.open(theURL,"_blank",features);
      //window.open("http://www.google.com", "_blank", null);
      //window.open("http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf", "_blank", "");
      //window.open('../resource/conditions_ger_eng.pdf','NAME','');
    }

/*function submitForm(pfForm, pTarget, pNavigation) {
  submitForm(pfForm, pTarget, null, pNavigation);
}

function submitForm(pfForm, pTarget, pOp, pNavigation) {
  
  alert("Datos recuperados del formulario:\n" + pfForm.name + "\npOp: " + pOp + "\ntarget: " + pTarget + "\npNavigation: " + pNavigation);
  //alert("Submit del formulario:\n" + pfForm.name + "\npOp: " + pOp + "\n pSource: " + pSource + "\npTarget: " + pTarget + "\npNavigation: " + pNavigation);
  //alert("Submit del formulario:\n" + pfForm.name + "\npOp: " + pOp + "\npTarget: " + pTarget + "\npNavigation: " + pNavigation);
  pfForm.action = pTarget;
  if (pOp != null) pfForm.pOp.value = pOp;
  //if (pSource != null) pfForm.pSource.value = pSource;
  if (pNavigation != null) pfForm.pNavigation.value = pNavigation;
  //alert("Datos recuperados del formulario:\n" + pfForm.name + "\npOp: " + pfForm.pOp.value + "\n pSource: " + pfForm.pSource.value + "\ntarget: " + pfForm.action);
  //alert("Datos recuperados del formulario:\n" + pfForm.name + "\npOp: " + pfForm.pOp.value + "\ntarget: " + pfForm.action);
  pfForm.submit();
}*/



