﻿/* copyright 2003-2006 RomanticRoad e.K. all rights reserved.  Title:  JS For The Homepage  */

// the greetings functions must be modified to account for the languages used

// effective screen size and font size 
var scrw = 1024 ; // normal home page width in pixels,  reset to match  viewers actual, effective screen size in the Main Program Code section below   
var pfont = 15; // normal font size for displaying text,  reset to match viewers actual, effective screen size in the Main Program Code section below 

// popup window variables
var topPos =  0;
var options = ",menubar=no,resizeable=no,scrollbars=yes,status=no\"";
var winTwo = null;
var dxwin = 620;  // default popup window width, reset in Main Program Code below
var dwinex  =  800;  // default popup window width for displaying external websites, reset in Main Program Code below
var leftPos = 187; // default popup window left position, reset in Main Program Code below

// objects given visibility attributes
var greetbgObj;
var greetenObj;	
var greetdeObj; 	
var greetitObj;
var greetjaObj; 	
var greetzhObj;
var partnersObj;


/*  Manage with Style   */

function adaptBG(tagdotclass,imgpath)
{
	// adapt home page's background image to screen size 
	// example call:  adaptBG("body.home","images/bghome")
	// note with + scrw +   the images folder must contain the 4 images:  bghome800.jpg, bghome1024.jpg, bghome1152.jpg, bghome1280.jpg
	
	// var imgbg =  imgpath + ".jpg";
	var imgbg =  imgpath + scrw + ".jpg";
	document.write("<style type='text/css'>" + tagdotclass + "  {background-image:url(" + imgbg + ");}</style>");    
	document.write("<style type='text/css'>" + tagdotclass + "  {background-repeat: no-repeat;}</style>");    
}

function adaptTxtTag(tagdotclass,txtwidth,dfontsz)
{
	//  Sets container width and relative font size for a class of containers.
	//  example call:  adaptTxtTag("p.home",300,-2)   
   	//  in the example,  the container is p,  the paragraph tag,  and home is its class. (i.e.,  <p class="home"> .... text .... </p>  )
	//  dfontsz is  the difference in pixels between the standard font size (pfont) and the desired font size for the text in p.home 
	//  if the screen size is 1024, the example call results in p.home having a width of 300 pixels and a font size of  13 pixels (15 -2).. 
	
	var paraw =  Math.floor(txtwidth * scrw / 1024);
	var fontsz = pfont + dfontsz;
	document.write("<style type='text/css'>" + tagdotclass +  "{font-size:" + fontsz + "px;}</style>");  
	document.write("<style type='text/css'>" + tagdotclass +  "{width:" + paraw + "px;}</style>");      
}

function chgstyleID(idname,xpos, ypos)
{
	// sets the absolute 2-D position of a container with id = "idname".
	// example call: chgstyleID("pgtitle", 350,10)

	var posx =  Math.floor(xpos * scrw / 1024);
	var posy =  Math.floor(ypos * scrw / 1024);
	document.write("<style type='text/css'>#" + idname + " {position: absolute; top:" + posy + "px;  left:" + posx + "px;}</style>");  
} 

function chgstyleIDz(idname,xpos, ypos,zpos)
{
	var posx =  Math.floor(xpos * scrw / 1024);
	var posy =  Math.floor(ypos * scrw / 1024);
	document.write("<style type='text/css'>#" + idname + " {position: absolute; top:" + posy + "px;  left:" + posx + "px;  z-index:" + zpos + ";}</style>");  
} 

function adaptWidth(tagdotclass,tagwidth)
{
	var tagw = Math.floor(tagwidth  * scrw / 1024);
	document.write("<style type='text/css'>" + tagdotclass +  "{width:" + tagw + "px;}</style>");    
}

function adaptSize(tagdotclass,tagwidth,tagheight)
{
	var tagw = Math.floor(tagwidth  * scrw / 1024);
	var tagh = Math.floor(tagheight  * scrw / 1024);
	document.write("<style type='text/css'>" + tagdotclass +  "{width:" + tagw + "px;}</style>");    
	document.write("<style type='text/css'>" + tagdotclass +  "{height:" + tagh + "px;}</style>");    
}

function adaptTxtSize(tagdotclass,dfontsz)
{
	var fontsz = pfont + dfontsz;
	document.write("<style type='text/css'>" + tagdotclass +  "{font-size:" + fontsz + "px;}</style>");  
}


/*  Manage Images with Javascript   */

function adaptImg(pathname,imgwidth,imgheight,classname)
{
	// match image size to screen size
	// example call:  adaptImg("images/photo1.jpg",250,188,"photos")
	// the 250 and 188 are the image's width and height corresponding to a screen size  width of 1024 pixels

	var imgw = Math.floor(imgwidth * scrw / 1024)
	var imgh = Math.floor(imgheight * scrw / 1024)
	document.write("<img src='" + pathname + "'  width='" + imgw + "' height='" + imgh + "' border='0'  class='" + classname + "' />");
}

function imggif(filepath,imgwidth,imgheight,classname)
{
	// match gif image and size to screen size 
	// (one of 4 depending on the value of scrw: filepath800.gif, filepath1024.gif, filepath1152.gif, filepath1280.gif )
	// example call:  imggif("images/graphic1",200,150,"logos")

	var imgw = Math.floor(imgwidth * scrw / 1024)
	var imgh = Math.floor(imgheight * scrw / 1024)
	var gifname = filepath + scrw + ".gif";
	document.write("<img src='" + gifname + "'    width='" + imgw + "'    height='" + imgh + "'  border='0'   class='" + classname + "' />");
}

function imgglass(imgwidth,imgheight)
{
	var gifname = "images/glass.gif";
	var imgw = Math.floor(imgwidth * scrw / 1024)
	var imgh = Math.floor(imgheight * scrw / 1024)
	document.write("<img src='" + gifname + "'  width='" + imgw + "' height='" + imgh + "' border='0'  />");
}


/*    Give Greeting Containers Visiblity Attributes      */

function initGreeting()
{
	if (document.getElementById)
	{
		greetbgObj =  document.getElementById("greetbg").style;
		greetenObj =  document.getElementById("greeten").style;
		greetdeObj =  document.getElementById("greetde").style;
		// greetitObj =  document.getElementById("greetit").style;
		// greetjaObj =  document.getElementById("greetja").style;
		// greetzhObj =  document.getElementById("greetzh").style;
	}
	else
	{
		greetbgObj = document.greetbg;
		greetenObj = document.greeten;
		greetdeObj = document.greetde;
		// greetitObj = document.greetit;
		// greetjaObj = document.greetja;
		// greetzhObj = document.greetzh;
	}
	greethide();
}	

function greethide()
{
	greetbgObj .visibility = "hidden";
	greetenObj .visibility = "hidden";
	greetdeObj .visibility = "hidden";
	// greetitObj .visibility = "hidden";
	// greetjaObj .visibility = "hidden";
	// greetzhObj .visibility = "hidden";
}


/*        Navigation Buttons          */

function dyntxtbn(visibletxt,ankclass,linkhref,greetingid)
{
	// TEXT navigation buttons that popup greeting containers
	// example call: dyntxtnav("english","nav","english/hotel.htm","greeten")

	var onbnover2 = "greetbgObj.visibility=\"visible\"";  
	var onbnover3 = greetingid + "Obj.visibility=\"visible\"";  
		
	document.write("<a href='" + linkhref + "' " +
	" onMouseOver='javascript:greethide();" + onbnover2 + ";" + onbnover3 + ";' " + 
	" onMouseOut='javascript:greethide()'  class='" + ankclass + "' >" + visibletxt + "</a>"); 
}

/*
function dynroll(bnObj,bnhObj,tagname,bnwidth,bnheight,bnclass,linkhref,greetingid,alttxt)
{
	// IMAGE navigation rollover buttons that popup greeting containers
	// example call: dynroll(english,englishh,"tag2",enw, enh,"nav","english/hotel.htm","greeten")
	// navigation button sizes,  set in file   config/custdatahome.js
	// "'   onMouseOut='" + onbnout + ";javascript:greethide()' > "  +
	// "'   onMouseOut='" + onbnout + ";' > "  +
	var bnw = Math.floor(bnwidth * scrw / 1024);
	var bnh = Math.floor(bnheight * scrw / 1024);
	var onbnover = "document." + tagname + ".src=\"" + bnhObj.src +  "\""; 
	// var onbnover2 = "greetbgObj.visibility=\"visible\"";  
	var onbnover3 = greetingid + "Obj.visibility=\"visible\"";  
	var onbnout  = "document." + tagname + ".src=\"" + bnObj.src   +  "\""; 

}
*/


function dynroll(bnObj,bnhObj,tagname,bnwidth,bnheight,bnclass,linkhref,greetingid,alttxt)
{
	// IMAGE navigation rollover buttons that popup greeting containers
	// example call: dynroll(english,englishh,"tag2",enw, enh,"nav","english/hotel.htm","greeten")
	// navigation button sizes,  set in file   config/custdatahome.js

	var bnw = Math.floor(bnwidth * scrw / 1024);
	var bnh = Math.floor(bnheight * scrw / 1024);
	var onbnover = "document." + tagname + ".src=\"" + bnhObj.src +  "\""; 
	var onbnover2 = "greetbgObj.visibility=\"visible\"";  
	var onbnover3 = greetingid + "Obj.visibility=\"visible\"";  
	var onbnout  = "document." + tagname + ".src=\"" + bnObj.src   +  "\""; 
	var onbnout2 = "greetbgObj.visibility=\"hidden\"";  
		
	document.write("<a href='" + linkhref +  "'  onMouseOver='javascript:greethide();" + onbnover + ";" + onbnover2 + ";" + onbnover3 + ";" + 
	// "'   onMouseOut='" + onbnout + ";' > "  +
	"'   onMouseOut='" + onbnout + ";javascript:greethide()' > "  +
	// "'   onMouseOut='" + onbnout + ";" + onbnout2 + "' > "  +
	"<img src='" + bnObj.src + "'  width='" + bnw + "' height='" + bnh + "'  border='0'  name='" + tagname + "'  class='" + bnclass + "'  alt='" + alttxt+"' /></a>"); 
}

/*  Manage romanticroad.eu and external links: rrlink() and rrlinkex() [plus partners]  */

function rrlink(classname)
{
	// used when no partner websites are planned 
	// var custadurl set in config folder  
	// var custadtxt set in config folder  
	// copyrturl  set in config folder  
	// copyrttxt = set in config folder  

	document.write("<p class='" + classname + "'><a href='" + custadurl +  "'>" + custadtxt +  "</a><br /></p>");
	document.write("<p class='" + classname + "'><a href='javascript:popWin(\"" + copyrturl + "\")'>" + copyrttxt + "</a></p>");
}

function rrlinkex(classname)
{
	// with partner websites text button
	// var custadurl set in config folder  
	// var custadtxt set in config folder  
	// copyrturl  set in config folder  
	// copyrttxt = set in config folder  

	document.write("<table class='" + classname + "'  border='0'  cellpadding='0'  cellspacing='0'><tr>"); 
	document.write("<td align='center'  valign='top'><p class='" + classname + "'><a href='javascript:exlinksHide()'  " +
	"onMouseOver='javascript:exlinksShow()' >ON LINE BOOKING</a></p></td>");
	document.write("<td align='center' valign='top'><p class='" + classname + "'><a href='" + custadurl +  "'>" + custadtxt +  "</a></p></td>");
	document.write("<td align='center' valign='top'><p class='" + classname + "'><a href='javascript:popWin(\"" + copyrturl + "\")'>" + copyrttxt +  
	"</a></p></td></tr></table>");
}

function initrrlinks()
{
	if (document.getElementById)
	 {
		partnersObj = document.getElementById("partners").style;
	}
	else 
	{
		partnersObj = document.partners;
	}
	partnersObj.visibility = "hidden";
}

function exlinksShow() 
{ 
	partnersObj.visibility="visible";
} 

function exlinksHide() 
{ 
	partnersObj.visibility="hidden";
}

function popWin(url)
{
	//  popup window to display external website pages 
	closeTwo();
	winTwo = window.open(url,"Menu","width=" + dxwinex + ",height=" + dywin + ",left=" + leftPos + ",top=" + topPos + options); 
}

function closeTwo()
{
	if ((winTwo) && (!winTwo.closed))
	{
		winTwo.close();
	}
}


/*  Main Program Code  */ 

//  This program determines the display width (scrw) of the home page, the basic font size (pfont) used for displaying text
//  and the width of the basic popup page (dxwin).
//  All image dimensions,  text sizes, and popup page size and position are determined by scrw and pfont.  

var dxscreen = screen.width;
var dyscreen = screen.height;
var dywin = dyscreen - 55;

	if ( dxscreen < 950 )
	{
		scrw = 800;
		pfont = 11;
		dxwin = 484; 
	}
	else
	{
		if ( dxscreen <  1100 )
		{
			scrw = 1024;
			pfont = 15;
			dxwin = 620; 
		}
		else
		{	
			if ( dxscreen < 1250 )
			{
				scrw = 1152;
				pfont = 17;
				dxwin = 698; 
			}
			else
			{
				scrw = 1280;
				pfont = 18;
				dxwin = 775; 
				if (dyscreen < 950)
				{
					scrw = 1152;
					pfont = 17;
					dxwin = 698; 
				}
				if (dyscreen < 850)
				{
					scrw = 1024;
					pfont = 15;
					dxwin = 620; 
				}
			}
		}
	}

dxwinex = Math.floor( 1.3 * dxwin);
leftPos =  (scrw / 2) - (dxwinex / 2 + 15) + (dxscreen -scrw);

/*  end main  */
