﻿// JScript File

function toggleSection(pSection) {
  el = getElement('div' + pSection);
  elHdr = getElement('divHdr' + pSection);
  if(el.style.display=='none') {
    el.style.display='block';
    elHdr .style.backgroundImage = 'url(/community/images/site/arrow_open.gif)';
  }
  else {
    el.style.display='none';
    elHdr.style.backgroundImage = 'url(/community/images/site/arrow_shut.gif)';
  }  
}

function goSearch(pPage,pKey,pElement,pTuid) {
  if (getElement(pElement).value != "0" && getElement(pElement).value != "") {
    window.location.href=pPage + "?" + pKey + "=" + getElement(pElement).value + "&tuid=" + pTuid ;
  }
}

function goTagSearch(pPage,pKey,pElement,pRestrict) {
  if (getElement(pElement).value != "0" && getElement(pElement).value != "") {
    window.location.href=pPage + "?" + pKey + "=" + getElement(pElement).value + "&restrict=" + pRestrict ;
  }
}

function goGeneralSearch(pPage,pKey,pInstance,pTuid) {
  var tids="";
  var loc="";
  if (getElement("ddlCountry" + pInstance).value != "0") {
    tids += getElement("ddlCountry" + pInstance).value + ",";
  }
  //if (getElement("ddlActivity" + pInstance).value != "0") {
  //  tids += getElement("ddlActivity" + pInstance).value + ",";
  //}
  if (getElement("_txtLocation" + pInstance).value.length > 0) {
    loc="&location=" + escape(getElement("_txtLocation" + pInstance).value);
  }
  if (tids.length > 0 || loc.length > 0) {
    tids=tids.substring(0,tids.length-1);
    window.location.href=pPage + "?" + pKey + "=" + tids + "&tuid=" + pTuid + loc + "&restrict=1" ;
  }
  else {
    window.alert("Select a country or a location to search");
  }
} 

function goGeneralActivitySearch(pPage,pKey,pInstance,pTuid) {
  var tids="";
  var loc="";
  if (getElement("ddlCountry" + pInstance).value != "0") {
    tids += getElement("ddlCountry" + pInstance).value + ",";
  }
  if (getElement("ddlActivity" + pInstance).value != "0") {
    tids += getElement("ddlActivity" + pInstance).value + ",";
  }
  if (getElement("_txtLocation" + pInstance).value.length > 0) {
    loc="&location=" + escape(getElement("_txtLocation" + pInstance).value);
  }
  if (tids.length > 0 || loc.length > 0) {
    tids=tids.substring(0,tids.length-1);
    window.location.href=pPage + "?" + pKey + "=" + tids + "&tuid=" + pTuid + loc + "&restrict=1" ;
  }
  else {
    window.alert("Select a country, an activity or a location to search");
  }
} 

function goTipSearch(pPage,pKey,pInstance,pTuid) {
  var tids="";
  var mistakes=""
  var loc="";
  if (getElement("ddlCountry" + pInstance).value != "0") {
    tids += getElement("ddlCountry" + pInstance).value + ",";
  }
  if (getElement("_txtLocation" + pInstance).value.length > 0) {
    loc="&location=" + escape(getElement("_txtLocation" + pInstance).value);
  }
  /*
  if (getElement("ddlProfile" + pInstance).value != "0") {
    tids += getElement("ddlProfile" + pInstance).value + ",";
  }
  if (getElement("chkMistakes" + pInstance).checked) {
    mistakes="&mistakes=1";
  }
  */
  if (tids.length > 0 || loc.length > 0) {
    tids=tids.substring(0,tids.length-1);
    window.location.href=pPage + "?" + pKey + "=" + tids + "&tuid=" + pTuid + mistakes + loc + "&restrict=1";
  }
} 