// functions

// get the specified parameter from page URL
function getURLParameters(paramID) 
{
  var sURL = window.document.URL.toString();
	
  if (sURL.indexOf("?") > 0)
  {
    var arrParams = sURL.split("?");
			
    var arrURLParams = arrParams[1].split("&");
		
    var arrParamNames = new Array(arrURLParams.length);
    var arrParamValues = new Array(arrURLParams.length);
		
    var i = 0;
    for (i=0;i<arrURLParams.length;i++)
    {
      var sParam =  arrURLParams[i].split("=");
      arrParamNames[i] = sParam[0];
      if (sParam[1] != "")
        arrParamValues[i] = unescape(sParam[1]);
      else
        arrParamValues[i] = "";
    }
    return arrParamValues[paramID];
  }
  else
  {
    return '';
  }
}

// change results/page on search page
function changeResNum()
{
  var urlParam = getURLParameters(0);
  window.location = "SearchResult.aspx?search=" + urlParam + "&pg=1&sres=" + document.getElementById("ResultNumber").value;
}

// change results/page on placeview page
function changeResNumPlace(place, ptext)
{
  window.location = "Place" + place + "-1-" + document.getElementById("ResultNumber").value + "_" + ptext + ".aspx";
  return true;
}

// open new window with
function openWindow()
{
  var urlParam = getURLParameters(0);
  window.open('ShowReviewImages.aspx?id='+urlParam,'Review photos','menubar=0,toolbar=0,width=750,height=600,resizable=1');
}

// remove HTML tags
function smartRmHTML( strSrc )
{
  return server.HTMLEncode( strSrc.replace( /<[^<|>]+?>/gi,'' ) );
}

// switch between small and large photo
function showPhoto(photoID, photoURL)
{
  document.getElementById('largephoto').src = photoURL.replace('s.','n.');
  document.getElementById('largephoto').alt = document.getElementById(photoID).alt;
  document.getElementById('largetitle').innerHTML = document.getElementById(photoID).title;
}

// switch between small and large photo on temp page
function showPhotoTemp(photoID, photoURL)
{
  document.getElementById('largephoto').src = photoURL.replace('_sres_','_res_');
  document.getElementById('largephoto').alt = document.getElementById(photoID).alt;
  document.getElementById('largetitle').innerHTML = document.getElementById(photoID).title;
}

// handle maxlength for multiline textbox (=textarea)
/*function tbMaxLength(tb, tbdisp, lgth)
{
  if (tb.value.length > lgth)
  {
    tb.value = tb.value.substring(0, lgth);
    alert("A '" + tbdisp + "' mez\u0151 \u00e9rt\u00e9ke maxim\u00e1lisan " + lgth + " karakter lehet!");
    return false;
  }
  else return true;
}*/
