//Less parameter better for Google Search and time to load
function OpenBrowse(theURL)
{
  if (browseWin2 && !browseWin2.closed) {
     browseWin2.close();
  }
  browseWin2 = browseWin1;

	var theTitle  = theURL; /* nothing interesting yet */
  var winWidth  = screen.availWidth;
  var winHeight = (screen.availHeight / 6) * 5;
  /* winLeft  = screen.availLeft useful when taskbar in vertical but property only in NN4+ */ 
		
  var winSettings ='height='+winHeight+',width='+winWidth+',top=0,left=0,toolbar=yes,location=yes,scrollbars=yes,resizable=yes,titlebar=no';

  browseWin1= window.open("", "_blank", winSettings);
  browseWin1.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"+
          "<html><head>"+
					"<title>" + theTitle + "</title>" +
					"<link rel=\"stylesheet\" href=\"assets/in-Riga.css\" type=\"text/css\"></head>" +
					"<frameset rows=\"12%, 88%\">" +
							"<frame src=\"frame-top.aspx?link=" + theURL + "\" name=\"RigaHead\" marginwidth=\"0\" scrolling=\"no\" frameborder=\"0\" />" + 
					    "<frame src=\"" + theURL.replace(/\"/g, "&quot;") + "\" name=\"RigaInfo\" marginwidth=\"0\" scrolling=\"yes\" frameborder=\"0\" />" + 
              "<noframes>"+
					       "Seems that your browser does not support FRAMES, please go to: " + theURL + " to visit the link" +
					    "</noframes>" +
					"</frameset></html>");
		browseWin1.document.close();
}

function OpenBrowsePop(theURL)
{
  if (browseWin2 && !browseWin2.closed) {
     browseWin2.close();
  }
  browseWin2 = browseWin1;

	var theTitle  = theURL; /* nothing interesting yet */
  var winWidth  = screen.availWidth;
  var winHeight = (screen.availHeight / 3) * 2;
  /* winLeft  = screen.availLeft useful when taskbar in vertical but property only in NN4+ */ 
		
  var winSettings ='height='+winHeight+',width='+winWidth+',top=0,left=0,toolbar=yes,location=no,scrollbars=yes,resizable=yes,titlebar=no';

  browseWin1= window.open("", "_blank", winSettings);
  browseWin1.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"+
          "<html><head>"+
					"<title>" + theTitle + "</title>" +
					"<link rel=\"stylesheet\" href=\"assets/in-Riga.css\" type=\"text/css\"></head>" +
					"<frameset rows=\"25%, 75%\">" +
							"<frame src=\"frame-top.aspx?org=pop&link=" + theURL + "\" name=\"RigaHead\" marginwidth=\"0\" scrolling=\"no\" frameborder=\"0\" />" + 
					    "<frame src=\"" + theURL + "\" name=\"RigaInfo\" marginwidth=\"0\" scrolling=\"yes\" frameborder=\"0\" />" + 
              "<noframes>"+
					       "Seems that your browser does not support FRAMES, please go to: " + theURL + " to visit the link" +
					    "</noframes>" +
					"</frameset></html>");
		browseWin1.document.close();
}


var genWin;
function OpenWindow(theURL, theTitle, theWidth, theHeight)
{
  if (genWin && !genWin.closed) {
     genWin.close()
  }
  
  var availHeight = screen.availHeight - 50;  //discount for Windows taskbar		
  var winWidth  = (screen.availWidth >= theWidth ) ? theWidth : screen.availWidth;
  var winHeight = (availHeight       >= theHeight) ? theHeight : availHeight;
  var winLeft   = (screen.availWidth-winWidth)/2;
		
  var winSettings ='height='+winHeight+',width='+winWidth+',top=0,left='+winLeft+',toolbar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no';
      
  genWin = window.open(theURL, "_blank", winSettings);
}

var photoWin;
function OpenPhoto(theURL, theTitle, theWidth, theHeight)
{
  if (photoWin && !photoWin.closed) {
     photoWin.close()
  }
  
  var availHeight = screen.availHeight - 50;  //discount for Windows taskbar
		
  var winWidth  = (screen.availWidth >= theWidth ) ? theWidth : screen.availWidth;
  var winHeight = (availHeight       >= theHeight) ? theHeight : availHeight;
  var winLeft   = (screen.availWidth-winWidth)/2;
		
  var winSettings ='height='+winHeight+',width='+winWidth+',top=0,left='+winLeft+',toolbar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no';
      
  photoWin = window.open(theURL, "_blank", winSettings);

  /*
    photoWin.document.write("<html><head><title>"+theTitle+"</title></head><body>" +
       "<img src=\""+theURL+ "\" width=\""+theWidth+ "\" height=\""+theHeight+ "\" name=\"photo\""+
       " onclick=\"javascript:photo.height*=2;photo.width*=2\" "+
       " ondblclick=\"javascript:photo.height/=2;photo.width/=2\">"+
					  "</body></html>");
		  photoWin.document.close();
  */
}

var mapWin1, mapWin2; //two active subwindows so user can compare
function OpenMap(theAddress)
{
  if (mapWin2 && !mapWin2.closed) {
     mapWin2.close();
  }
  mapWin2 = mapWin1;

  var winWidth  = 700;
  var winHeight = 600;
  var winLeft   = (screen.availWidth-winWidth)/2;
		
  var winSettings ='height='+winHeight+',width='+winWidth+',top=0,left='+winLeft+',toolbar=no,location=no,scrollbars=no,resizable=no,titlebar=no';
    
  mapWin1 = window.open("http://www.in-riga.com/map-search.aspx?lang=en&isearch=" + theAddress, 
  //mapWin1 = window.open("http://www.118.lv/karte?lang=en&isearch=" + theAddress, 
  //mapWin1 = window.open("http://link2.map24.com/?lid=3a3e90a1&amp;maptype=JAVA&amp;width0=1500&amp;q0=Riga-" + theAddress + "&amp;country0=LV&amp;logo_url0=&amp;name0=&amp;description0=", 
                        "_blank", winSettings);
                        
}

//Write the map icon and the link to open the window with the map
function WriteMap(theAddress){
   document.write("<a href=\"javascript:\" onclick=\"OpenMap('" + theAddress + "')\" >");
   document.write("<img src=\"assets/images/icon_Map.gif\" width=\"25\" height=\"10\" alt=\"Check the Location in the Map\" /></a>");
}

function WriteEM(user, domain){

   document.write('<a href=\"');
   document.write('mailto:');
   document.write(user + '@' + domain + '\">');
   document.write(user + '@' + domain + '</a>');
}

function WriteBrokenLink(link){
//Make a script to report a broken link and add it to all the links so a visitor can report broken links easily and you get feedback and automaintenance (limit the number by IP)
}

// ADD TO FAVOURITES: FIRST STEP
function AddFavour(lang){
var url=window.location;
var title;

   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
	  switch (lang.toLowerCase()){
	  case 'es':
		    title = "In-Riga.com Guia de viaje";
		 break;
	  case 'it':
      title = "In-Riga.com (Lettonia)";
		 break;
   default:
		    title = "In-Riga.com Guide (Latvia)";
	  }
      window.external.AddFavorite(url,title);
   }
   else {
      if(navigator.appName == "Netscape") 
      alert ("Press Crtl+D to add to your Bookmarks");
   }
}

// Contact Us (First Step)
function ContactUs(lang){
var subjMsg;
var bodyMsg;

   switch (lang.toLowerCase()){
   case 'es':
	     subjMsg = "Informacion sobre Riga.";
       bodyMsg = "Contact Details"; 
       bodyMsg += "%0D%0A"
	     bodyMsg += "Name: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Email: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Country: "; 
       bodyMsg += "%0D%0A"
	     bodyMsg += "Telephone: ";
       bodyMsg += "%0D%0A"
       bodyMsg += "Comments/Question: ";  
       break;
   case 'it':
       subjMsg = "  .";
       bodyMsg = "Contattaci Details"; 
       bodyMsg += "%0D%0A"
	     bodyMsg += "Name: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Email: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Country: "; 
       bodyMsg += "%0D%0A"
	     bodyMsg += "Telephone: ";
       bodyMsg += "%0D%0A"
       bodyMsg += "Comments/Question: ";  
	  break;
   default:
       subjMsg = "Information request about Riga.";
       bodyMsg = "CONTACT DETAILS"; 
       bodyMsg += "%0D%0A"
       bodyMsg += "Name: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Surname: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Email: ";
       bodyMsg += "%0D%0A"
	     bodyMsg += "Telephone(Country prefix): ";
       bodyMsg += "%0D%0A"
       bodyMsg += "Comments/Question: ";  
   }
   window.location = "mailto:"+"feedbacks"+"@"+"in-riga.com"+"?subject="+subjMsg+"&body="+bodyMsg;
}

// Feedback about Rent Riga page (First Step)
function Feedback(lang){
var subjMsg;
var bodyMsg;

   switch (lang.toLowerCase()){
   case 'es':
      subjMsg = "Sugerencia sobre In-Riga.com";
      bodyMsg = "Por favor, escribe aqui tu sugerencia. Gracias por mejorar este website.";
      break;
   case 'it':
   default:
      subjMsg = "In-Riga.com Feedback";
      bodyMsg  = "Hi, dear visitor!"
      bodyMsg += "In-Riga.com Team will be very happy to hear from your suggestions."
      bodyMsg += "%0D%0A"
      bodyMsg += "Thanks for make this website better.";
      bodyMsg += "%0D%0A"
      bodyMsg += "Please, write below your feedback and/or website improvement suggestion:"
      bodyMsg += "%0D%0A"
   }
   window.location = "mailto:"+"feedbacks"+"@"+"in-riga.com"+"?subject="+subjMsg+"&body="+bodyMsg;
}

// EMAIL LINK TO FRIEND: FIRST STEP
function EmailLink(lang){
var subjMsg;

   switch (lang.toLowerCase()){
   case 'es':
	  subjMsg = "Mira este link con información sobre Riga";
      break;
   case 'it':
   default:
      subjMsg = "I thought this link with information about Riga might interest you.";
   }
   window.location = "mailto:"+"?subject="+ subjMsg + "&body="+ document.title + "%0D%0A  " + window.location;
}

//
function GetHTMLSocialBook(numLinks)
{
   var arrayLinks = [["Del.icio.us", "del.icio.us/post?url="],
                     ["Digg.com",    "digg.com/submit?phase=2&url="],
                     ["Reddit.com",  "reddit.com/submit?url="],
                     ["Furl.net",  "www.furl.net/storeIt.jsp?u="],
                     ["Shadows.com",  "www.shadows.com/features/tcr.htm?url="],
                     ["Y! MyWeb",  "myweb2.search.yahoo.com/myresults/bookmarklet?u="],
                     ["Blinkbits", "www.blinkbits.com/bookmarklets/save.php?v=1&source_url="],
//                     ["Spurl", "ttp://www.spurl.net/spurl.php?url="],
                     ["StumbleUpon",  "www.stumbleupon.com/submit?url="],
                     ["PreFound",  "www.prefound.com/submit?url="],
                     ["Technorati","technorati.com/faves?sub=addfavbtn&amp;add="],
                     ["LinkAGoGo","www.linkagogo.com/go/AddNoPopup?url="]];

   var iLink= Math.floor(Math.random() * arrayLinks.length);
   for (var i=0; i< numLinks; i++)
   {
      document.write("<a href=\"http://" + 
                  arrayLinks[iLink][1] + window.location + 
                  "\" title=\"Submit this site to " + arrayLinks[iLink][0] + "  and let people know about Riga\"" + 
                  "target=\"_blank\">" + arrayLinks[iLink][0] +"</a><br>");
      iLink++;
      if (iLink >= arrayLinks.length) iLink= 0;
   }
}

/////////////////////////////////////////////////////////////
//Floating window scripts
function JSFX_FloatTopLeft(section)
//From http://www.javascript-fx.com
{
  var startX = 0, startY = 120;
  var ns = (navigator.appName.indexOf("Netscape") != -1);
  var d  = document;
  var px = document.layers ? "" : "px";

  function mlLeft(id)
  {
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
		el.x = startX; el.y = startY;
		
		return el;
 }

 window.stayTopLeft=function()
 {
		var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		var dY = (pY > startY) ? pY : startY;
		
		ftlObj.y += (dY - ftlObj.y)/8;
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 40);
 }

 ftlObj = mlLeft(section);
 stayTopLeft();
}

//!!! Does not work
function FloatLeftY(section)
{
    var startY = 120;
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d  = document;
    var px = document.layers ? "" : "px";
    function ml(id)
    {
      var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
      if(d.layers)el.style=el;
      el.sP=function(y){this.style.top=y+px;};
      el.y = startY;
      return el;
    }
    window.stayLeftY=function()
    {
      var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
      var dY = (pY > startY) ? pY : startY;
      ftlObj.y += (dY - ftlObj.y)/8;
      ftlObj.sP(ftlObj.y);
      setTimeout("stayLeftY()", 10);
    }
    ftlObj = ml(section);
    stayLeftY();
}