/******************************************************************************* 
 * @(#)js/pageUtils.js
 *  Rev:         C
 *  Created:     Mon. November 20, 2005, 12:00:00
 *  Author:      media-roayal
 *  mailto:      support@media-royal.com
 *
 *  Copyright by "media-royal.com"
 *
 *  The copyright to the computer program(s) herein
 *  is the property of "media-royal.com", Germany.
 *  The program(s) may be used and/or copied only with
 *  the written permissions of "media-royal.com"
 *  or in accordance with the terms and conditions
 *  stipulated  in the agreement/contract under which
 *  the  program(s) have been supplied.
 *
 * CopyrightVersion 1.0
 *
 ********************************************************************************
 *
 * This site represents an the ultimate media-royal solution for pageUtils
 *
 * @author  Daniel Beckert
 * @version 2.0, Sun, 2005-11-20
 * @since   
 *
 *******************************************************************************/

/**************************************** !!! IMPORTANT !!! *******************************************
 *
 * !!! Set some standarte values !!!
 *
 */
 var startPage      = new String("https://www.miditonal.de/");
 var currentPage    = new String(document.URL);
 
 var pageName       = new String("\"miditonal.de\"");
 
 var describtion    = new Object();
 describtion["_de"] = new String("");
 describtion["_de"]+= "";



/*************************************** Balloontips *************************/
 var background_color = "#FFFFAF";
 var color = "#000000";
 var border = " solid black 1px";
 var fontfamily = "arial";
 var fontsize = "11";
 var hidetime = 3000; // time in millis before info fades
 var padding = "12px 12px 12px 12px";
 var live = new Object();
 var nofade = new Object();
 var fastfade = false;
 var moz_opacity = false;
 var ie_opacity = false;
 var nodes = new Object();
 var tempX = 0;
 var tempY = 0;
 var ison = false;
 var IE = document.all?true:false 
 

//----------------------------------------------------------------------------------------------------



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           imageSwap
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This function swaps images to make a rollover effect in html sites
 *
 * @param name 
 * @para src
 *
 */
 function imageSwap (name, src) {
	 document[name].src = eval( src + ".src" );
 }//--> function img_swap



//----------------------------------------------------------------------------------------------------



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           printPage
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This function adds the current page to the favorites
 *
 */
 function printPage(){
	window.print();
 }//--> end printPage()
 
 

//---------------------------------------------------------------------------------------------------- 


 
/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           function printAndClose
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This function prints and closes the window
 *
 */
 function printAndClose(){
	window.print();
	window.close();
 }//--> end printAndClose()
 
 

//---------------------------------------------------------------------------------------------------- 



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           function setFocus
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This sets the focus to the given id of an formfield
 *
 */
 function setFocus(focusObject){
	focusObject.eval(focusObject).focus();
 }//--> end printAndClose()



//---------------------------------------------------------------------------------------------------- 



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           setAsSartpage
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This function opens the popup window 
 *
 * @param objWindowParams:Array
 */
 function setAsSartpage(){
	 
	 var startPageAlert = new Object();
	 
 	 startPageAlert["_de"] = new String("");
	 startPageAlert["_de"] += "Leider können Sie "+pageName+" nur im Internet Explorer automatisch als Startseite einrichten.\n";
 	 startPageAlert["_de"] += "Bitte richten Sie "+pageName+" manuell als Startseite ein.";
	 
	 
	 switch(getBrowserName()){
		  case "msie":
		  	 if(getBrowserVersion()[0]>=4){
				 //this.style.behavior="url(#default#homepage)";
        		 //this.body.sethomepage("https://www.miss-streeted.de);
				 document.body.style.behavior="url(#default#homepage)";
        		 document.body.sethomepage("http://www.miditonal.de");
				 break;
			 }//--> end if
			 else{
				 alert(startPageAlert["_de"]);
				 break;
			 }//--> end else
		  	 break;
		  default:
		  	 alert(startPageAlert["_de"]);
			 break;
	 }//--> end switch
 }//--> end setAsStartpage()
 
 
 
//---------------------------------------------------------------------------------------------------- 



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           addToFavorites
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This function adds the current page to the favorites
 *
 */
 function addToFavorites(){
	 
	 var addToFavoritesAlert = new Object();
	 
 	 addToFavoritesAlert["_de"] = new String("");
	 addToFavoritesAlert["_de"] += "Leider können Sie \""+currentPage+"\" nur im Internet Explorer automatisch den Favoriten hinzufügen.\n";
	 
	 switch(getBrowserName().toLowerCase()){
		 
		 case "msie":
		 	 if(getBrowserVersion()[0]>=4 && runtimeMode !="system"){
				 window.external.AddFavorite(currentPage,"miditonal.de");
			 }//--> end if
			 else{
				 addToFavoritesAlert["_de"] += "Bitte fügen Sie "+currentPage+" manuell den Favoriten hinzu.";
			 	 alert(addToFavoritesAlert["_de"]);
			 }//--> end else
		 	 break;
			 
		 case ("firefox" || "netscape"):
		 	 addToFavoritesAlert["_de"] += "Bitte fügen Sie "+currentPage+" manuell als den Favoriten hinzu, indem Sie auf Ihrer Tastatur \"STRG+D\" drücken.";
			 alert(addToFavoritesAlert["_de"]);
		 	 break;
			 
		 default:
		 	 addToFavoritesAlert["_de"] += "Bitte fügen Sie "+currentPage+" manuell den Favoriten hinzu.";
			 alert(addToFavoritesAlert["_de"]);
		 	 break; 
	 }//--> end switch
	 
 }//--> end addToFavorites
 
 
 
//---------------------------------------------------------------------------------------------------- 



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           tellAFriend
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This function adds the current page to the favorites
 *
 */
 function tellAFriend(){ 
	 var objTAFParams     = new Object();	
	 // Setup how the helpcenter opens 
	 objTAFParams["url"]            = new String(getTopPath()+"tellAFriend/index.php?sendPage="+currentPage);
	 objTAFParams["id"]             = new String("popTellAFriend");
	 objTAFParams["width"]          = new Number(640);
	 objTAFParams["height"]         = new Number(540);
	 objTAFParams["xPos"]           = new Number(null);
	 objTAFParams["yPos"]           = new Number(null);
	 objTAFParams["isResizeable"]   = new String("no");
	 objTAFParams["hasScrollbar"]   = new String("no");
	 objTAFParams["hasAdressline"]  = new String("no");
	 objTAFParams["hasMenubar"]     = new String("no");
	 objTAFParams["hasToolbar"]     = new String("no");
	 objTAFParams["hasStatusline"]  = new String("no");
	 objTAFParams["canUseHotkeys"]  = new String("no");
	 objTAFParams["isDependent"]    = new String("yes");
	 objTAFParams["hasDirectories"] = new String("no");
	 openWinCentered(objTAFParams);
 }//--> end tellAFriend()
 
 

//---------------------------------------------------------------------------------------------------- 



/*
 *-----------------------------------------------------------------------------------------------------
 *
 *           Balloontips
 *
 * ----------------------------------------------------------------------------------------------------
 *
 * This makes the balloontips
 *
 */

 // If NS -- that is, !IE -- then set up for mouse capture
 if (!IE) document.captureEvents(Event.MOUSEMOVE)

 // Set-up to use getMouseXY function onMouseMove
 document.onmousemove = getMouseXY;



//----------------------------------------------------------------------------------------------------



 function setOff(balloonID) {
	 //alert(balloonID);
	 var nodeInst = nodes[balloonID];
	 nodeInst['on'] = false;
	 ison = false;
 }//--> end setOff



//----------------------------------------------------------------------------------------------------



 function showBalloon(node, balloonID, width, closebox) {
	 var status = true;
	 var nodeInst = nodes[balloonID];
	
	 if(nodeInst && nodeInst['on'] == true) status = false;

	 if(browserDetect() && status) {
		 var nodeInst = new Object();
		 nodeInst['balloonID'] = balloonID;
		 nodeInst['width'] = width;
		 nodeInst['closebox'] = closebox;
		 nodeInst['on'] = true;
		 nodes[balloonID] = nodeInst;		
		 node.onmouseout = function offit() { setOff(balloonID); };
		 setTimeout("run('" + balloonID + "')", 0);	
	 }//--> end if
 }//--> end showBalloon()
 
 
 
//----------------------------------------------------------------------------------------------------



 function run(balloonID) {
	 var nodeInst = nodes[balloonID];
	 if(nodeInst['on'] == true) balloon(nodeInst['balloonID'], nodeInst['width'], nodeInst['closebox']);
 }//--> end run()
 
 

//----------------------------------------------------------------------------------------------------



 function hideBalloon(balloonID) {
	 fadeit(balloonID, 10);
 }//--> end hideBalloon()
 
 

//----------------------------------------------------------------------------------------------------



 function balloon(balloonID, width, closebox) {
	
	 nid = balloonID + '-balloon';	
	 try {				
		 if(live[nid]) {
			 return;
		 }//--> end if 
		 else {
			 live[nid] = true;
		 }//--> end else
		
		 leftx = tempX;
		 bottomy = tempY;	
		
		 var span = document.getElementById(balloonID).getElementsByTagName("span")[0];
		 var newDiv = document.createElement("DIV");
			
		 newDiv.setAttribute("id", nid);
		 newDiv.style.position = "absolute";
		 newDiv.style.visibility = "hidden"
		 newDiv.style.overflow = "hidden";
		 newDiv.style.top =  bottomy + "px";
		 newDiv.style.left = leftx + "px";
		 newDiv.style.border = border;
		 newDiv.style.width = width + "px";
		 newDiv.style.padding = padding;
		 newDiv.style.fontFamily = fontfamily;
		 newDiv.style.fontSize = fontsize + "px";
		 newDiv.style.paddingRight = "0px";
		 newDiv.style.paddingBottom = "12px";
		 newDiv.style.backgroundColor = background_color;
				
		 var newSpan = document.createElement("SPAN");
		 newSpan = span.cloneNode(true);
		 newDiv.appendChild(newSpan);		
		
		 var newP = buildInfoP();
		 var newA = buildInfoAhref();
					
		 if(closebox) {
			 closeBox(newA, balloonID);
		 }//--> end if
		 else {
			 newA.href="javascript:dontFade('" + balloonID + "');";			
			 var xlink = document.createTextNode("don't hide info box");
			 newA.appendChild(xlink);		
			 newA.style.border = "0px";
			 newA.style.backgroundColor = background_color;
			 newA.style.textDecoration = "underline";
		 }//--> end else
		 
		 newP.appendChild(newA);
		 newSpan.appendChild(newP);
		
		 var body = document.getElementsByTagName("body")[0];	
		 body.appendChild(newDiv);					
		 newDiv.style.visibility = 'visible';
		
		 if(! closebox) setTimeout('fadeit("' + balloonID + '", 10)', hidetime);
		
	 }//--> end try()
	 catch(err) {	
		alert(err);
	 }//--> end catch()
 }//--> balloon



//----------------------------------------------------------------------------------------------------



 function fadeit(balloonID, op) {
	
	 nid = balloonID + '-balloon';
	 var node = document.getElementById(nid);		
	 if(nofade[nid] == true) {
		 node.style.opacity = "1";
		 nofade[nid] = false;
		 return;
	 }//--> end if
	
	 if(op > 0 && fastfade == false) {
		 op = op - 1;
		 
		 if(ie_opacity) {
			 var ieop = op * 10;		
			 node.style.filter = "alpha(opacity="+ ieop + ")";
		 }//--> end if
		 else if (moz_opacity) {
			 //alert('mozo');
			 var mozop = op * 10;
			 node.style.MozOpacity= mozop + "/100";
		 }//--> end else if
		 else {
			 node.style.opacity = "." + op;
		 }//--> end else
		 
		 fadefunct = 'fadeit("' + balloonID + '", ' + op + ')';
		 setTimeout(fadefunct, 30);

	 }//--> end if 
	 else {
		 var node = document.getElementById(nid);
		 node.style.visibility = 'hidden';			
		 var body = document.getElementsByTagName("body")[0];
		 body.removeChild( node );	
		 live[nid] = false;
	 }//--> end else
 }//end fadeit()



//----------------------------------------------------------------------------------------------------



function dontFade(balloonID) {
	 nid = balloonID + '-balloon';
	 nofade[nid] = true;
	
	 var span = document.getElementById(balloonID).getElementsByTagName("span")[0];
	 infoDiv = document.getElementById(nid);
	 var newSpan = document.createElement("SPAN");
	 newSpan = span.cloneNode(true);
	 var oldspan = infoDiv.getElementsByTagName("span")[0];
	 var pnid = nid + 'pid';
	 infoDiv.removeChild(oldspan);
	
	 var ahref = buildInfoAhref(); 
	 closeBox(ahref, balloonID);
	 var newP = buildInfoP();
	 newP.appendChild(ahref);
	 newSpan.appendChild(newP);
		
	 infoDiv.appendChild(newSpan);
 }//--> end dontFade()
 
 

//----------------------------------------------------------------------------------------------------



 function buildInfoAhref() {
	 var newA = document.createElement("A");
	 newA.style.color = "#ffffff";
	 newA.style.textDecoration = "none";
	 newA.style.fontSize = "10px";
	 newA.style.border = "dotted black 1px";
	 newA.style.padding = "0px 5px 1px 5px";
	 newA.style.backgroundColor = "#d20a23";
	 return newA;								
 }//--> end buildInfoAhref()



//----------------------------------------------------------------------------------------------------



 function closeBox(ahref, balloonID) {
	 ahref.href="javascript:hideBalloon('" + balloonID + "');";			
	 var xlink = document.createTextNode("X");
	 ahref.appendChild(xlink);
 }//--> end closeBox()
 
 

//----------------------------------------------------------------------------------------------------



 function buildInfoP() {
	 var newP = document.createElement("P");
	 newP.style.textAlign = "right";
	 newP.style.margin = "0px 0px 0px 0px";
	 return newP;
}//--> end buildInfoP()



//----------------------------------------------------------------------------------------------------



 function browserDetect() {
	 var isgood = false;
	 var agt=navigator.userAgent.toLowerCase();
	 var is_major = parseInt(navigator.appVersion);	
	 if(agt.indexOf('safari')!=-1) {
		 isgood = true;
	 }//--> end if
	 else if((agt.indexOf('mozilla')!=-1) && (agt.indexOf('gecko')!=-1)) {
		
		 var rvindex = agt.indexOf("rv:");
		 var rv2end = agt.substring(rvindex + 3, agt.length);
		 var parenIndex = rv2end.indexOf(")");
		 var rev = rv2end.substring(0, parenIndex); 
		
		 if(rev < 1.7) {
			 fastfade = true;
			 //alert(	moz_opacity );
		 }//--> end if
		
		isgood = true;
		
	 }//--> end else if 
	 else if(agt.indexOf('opera')!=-1) {
		 fastfade = true;
		 isgood = true;
		 //moz_opacity = true;
	 }//--> end else if
	 else if(agt.indexOf('msie')!=-1) {
		 if(agt.indexOf('mac')!=-1) {	
			 ie_opacity = false;
			 fastfade = true;
		 }//--> end if
		 else {
			 ie_opacity = true;
		 }//--> end else
		 isgood = true;
	 }//--> end else if
	 
	 return isgood;
 }//--> browserDetect()



//----------------------------------------------------------------------------------------------------



 function getMouseXY(e) {
	 if (IE) { // grab the x-y pos.s if browser is IE
	 	 tempX = event.clientX + document.body.scrollLeft
    	 tempY = event.clientY + document.body.scrollTop
  	 }//--> end if
	 else {  // grab the x-y pos.s if browser is NS
    	 tempX = e.pageX
    	 tempY = e.pageY
  	 }//--> end else
 }//--> getMouseXY()



//----------------------------------------------------------------------------------------------------



/********************************************************************************
 * EOF
 *******************************************************************************/

