/*
*  Show the correct styles in the 'Advanced Search' on all public pages
*/

function showStyle(type) {
  var styleAccom=ID('styleSelectAccom');
  if(type=='Accommodation') {
    styleAccom.name='style';
    styleAccom.style.display='';
  }
  else {
    styleAccom.name='';
    styleAccom.style.display='none';
  }

  var styleTour=ID('styleSelectTour');
  if(type=='Tour') {
    styleTour.name='style';
    styleTour.style.display='';
  }
  else {
    styleTour.name='';
    styleTour.style.display='none';
  }

}

function pop(w,h,url) {
  window.open(BASE_URL+url,"","width=" + w + ",height=" + h + ",scrollbars=no,resizable=yes");
  /*
  if(typeof(window.event)!='undefined')
    window.event.returnValue = false;
	return false;
	*/
}

function ID(name) {
  return document.getElementById(name);
}

function AlertObject(f) {
  msg='';
  for (var i in f) {
    msg += ('['+i+']=>'+f[i]);
  }
  np = window.open('');
  np.document.write('<pre>'+msg+'<pre>');
}

function safeParseInt(x) {
  var cleanNumReg = new RegExp ('[^0-9\.]+', 'g') ;
  x=x.replace(cleanNumReg, '');
  if(x=='' || isNaN(x))
    return 0;
  return parseInt(x);
}

function safeParseFloat(x) {
  x=String(x);
  var cleanNumReg = new RegExp ('[^0-9\.]+', 'g') ;
  x=x.replace(cleanNumReg, '');
  if(x=='' || isNaN(x))
    return 0;
  return parseFloat(x);
}

/*
 Event system.
 eg 
 events['onResize'].push('changePage()');
*/

events=new Object;
events['onLoad']=Array();
events['onResize']=Array();
function eventsExec(eventName) {

  if(typeof(events)!='object')
    return;
  if(typeof(events[eventName])!='object')
    return;
  
  for(var i=0; i<events[eventName].length; i++) {
    eval(events[eventName][i]);
  }
}

function eventsExecOnload() {
  eventsExec('onLoad');
}

function DisplayFeature(b,idfeature) 
{
  window.location = b+'feature/'+idfeature;
  //window.location = b+'index.php/'+idfeature;
}

function PopVideo(param) 
{
  window.open(BASE_URL+'video.php?p='+param,"","width=543,height=440,scrollbars=no,resizable=yes");
}

function Displaytour(targeturl) 
{
  window.location = targeturl;
  
}

function ChangeType(url, type) 
{
	if(url.endsWith('tours')) {
		window.location=url.gsub('tours','style/'+type+'/tours');
	}
}

function Search() 
{
  var criteria = $('QSAdvanced').serialize();
  //console.log(criteria);
  window.opener.location='index.php?'+criteria;
  window.close();
}



function featuredisp() 
{
  var ado = $('do').value;
  window.location='/'+ado;
  
}


