if (document.domain.indexOf("bike-gps.com")>0) document.domain="bike-gps.com";

//getting url parameter
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function getLang(){
	var lang="";
  	try{
  		lang=document.getElementsByTagName('html')[0].lang.split("-")[0];
  	}catch(err){
	   //alert(err);
	}
	
	if (lang=="de") return "";
	
  	if (lang==""){
  		var uri=window.location.href;
  		if (uri.search(/\/en\//i)>0) return "_en";
  		if (uri.search(/\/it\//i)>0) return "_it";
  	}else return "_"+lang;
  	
  	return "";
}

var region=gup("region");
var tour=gup("tour");
var tourenplaner=urldecode(gup("tourenplaner"));
var src="";

var langstr=getLang();

var nrstr=gup("nr");
if (nrstr!="") nrstr="%20"+nrstr;

if (region!= "") {
  if (region=="alta_rezia" ||
      region=="alta_rezia_en" ||
      region=="alta_rezia_it" ||
      region=="region_dachstein" ||
      region=="region_dolomiten_sued" ||
      region=="region_grossglockner" ||
      region=="tourendownload" ||
	region=="tourendownload_en" ||
	region=="tourendownload_it" ||
      region=="transalp_ulp" ||
      region=="etappenliste_eingeben"
  )   {
         src="/static/"+region+".htm";
  }
  else {
         src="http://shop.bike-gps.com/cgi-bin/gshop"+langstr+"/tourenliste.pl?"+region;
       }

}

if (tour!= "") {
  src="http://shop.bike-gps.com/cgi-bin/gshop"+langstr+"/tourdetail.pl?"+tour+nrstr;
}

if (tourenplaner!= "") {
  src="http://shop.bike-gps.com/cgi-bin/gshop"+langstr+"/gshop_korb.pl?"+tourenplaner;
}

document.write("<p><iframe id=\"BikeGPS\" name=\"BikeGPS\" src=\""+src+"\" scrolling=\"no\" width=\"800\" frameborder=\"0\" height=\"1000\" onload=\"adaptH(this);\"></iframe></p>");



function adaptH(iframe){

  var ie= (document.all) ? 1 : 0;
  var h=0;

  try
  {
    if (window.frames['BikeGPS'].contentHeight>0) h=window.frames['BikeGPS'].contentHeight;
  }catch(err){
   //alert(err);
  }
  if( h>0 ) iframe.height=h;
  else{
     try{
       if (document.frames['BikeGPS'].document.body.scrollHeight>0){
          h=document.frames['BikeGPS'].document.body.scrollHeight;
       }
     }catch(e){}
  }
  if( h>0 ) iframe.height=h;
  else {
      iframe.scrolling="auto";
    }
}

function urldecode( str ) {

    var histogram = {};
    var ret = str.toString();

    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };

    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';

    for (replace in histogram) {
        search = histogram[replace];
        ret = replacer(search, replace, ret)
    }

    ret = decodeURIComponent(ret);

    return ret;
}