/*************************************************************************************/  
/**
 * insao-hive-iwm 
 * @copyright 		(c) 2007-2008 PR23 Limited. All Rights Reserved
 * @author 			PAUL WINTERHALDER :: PR23
 * 
 * @category 		INSAO HIVE 6.0.0.1
 * @category 		/domain/
 * @subcategory		Default javascript functions
 *
 * ----------------------------------------------------------------
 *
 * @final			DO NOT EDIT THIS FILE
 *
 *					18.02.2008  PRW
 *
 /*************************************************************************************/
        

     /*************************************************************************************/  
     /**
     *
     **/
        function buildURL() {
           var   url='/swan-hellenic-cruises/ajaxIndex.php?final=true'
           return url 
        }
        
     /*************************************************************************************/  
     /**
     *
     **/
     whiteload = new Image(30,30);
     whiteload.src = '/swan-hellenic-cruises/-/view/img/swan/loading/gif/'; 

     blueload = new Image(30,30);
     blueload.src = '/swan-hellenic-cruises/-/view/img/swan/loading-blue/gif/'; 

        
        /*************************************************************************************/  
        /**
        *
        **/
        function pathToXsl(_type,_file,_dir) {
   	       var _dir = 	typeof(_dir) != 'undefined' 	? 	_dir 	: 	''	
            var url  = '/swan-hellenic-cruises/resources/xsl/default.php?type='+_type+'&file='+_file+'&dir='+_dir+''	
            return url 
        }
         
     /*************************************************************************************/  
     /**
     *
     **/
     function getImagePath(_path) {
   	    var _path = 	typeof(_path) != 'undefined' 	? 	_path 	: 	'loading-blue'	
         var url  = '/swan-hellenic-cruises/-/view/img/swan/'+_path+'/gif/'	
         return url 
     }
 

	var _InsaoWWWDebug 	 		= 		false;
	var _InsaoWWWSupress	 	= 		false;
	var _www_coat_ui			=		"www_coat_ui"
	var _www_popbox_ui			=		"www_popbox_ui";
	var _www_popbox_ui			=		'www_popbox_ui'	
	var _www_popinner			=		'www_popinner';
	var _www_pophead			=		'www_pophead';
	var _www_popheadlft			=		'www_popheadlft';
	var _www_popheadrgt			=		'www_popheadrgt';
	var _www_popheadh1			=		'www_popheadh1';
	var _www_pophead_clear		=		'www_pophead_clear';
	var _www_popisingle_txt		=		"www_popinner_single_text";
	var _www_popbottom_txt		=		"www_popinner_single_btm_text";
	var _www_popinner_single	=		"www_popinner_single";
	var popupSafe				=		[];	
	
	/*******************************************************************************************************/
	/**
	*	XMLHTTP call
	**/
	function GetXmlHttpObject(){
		var objXMLHttp=null
	
		if (window.XMLHttpRequest) {
			objXMLHttp=new XMLHttpRequest();
			
		} else if (window.ActiveXObject) {
			objXMLHttp=new ActiveXObject('Microsoft.XMLHTTP');
		}
		return objXMLHttp
	} 

	/*******************************************************************************************************/
	/**
	*	Paint the browser window 
	**/
	function paintCanvas(setStyle) {
		var setStyle 		= 	typeof(setStyle) != 'undefined' 	? 	setStyle 	: 	_www_coat_ui;
		var bdp 			= 	document.createElement("div");
		bdp.id 				= 	setStyle;
		bdp.style.height 	= 	parseInt(document.documentElement.clientHeight) + 1000 +'px';
		
		document.body.appendChild(bdp);
	}
	
	/*******************************************************************************************************/
	/**
	*	
	**/
	function recalpaintedcanvas(setStyle) {
		var setStyle 		= typeof(setStyle) 	!= 	'undefined' 	? 	setStyle 	: 	_www_coat_ui;
		
		if(document.getElementById(setStyle) != null) {
			document.getElementById(setStyle).style.height = parseInt(document.documentElement.clientHeight) + 1000 +'px';
		}
	}
	
	/*******************************************************************************************************/
	/**
	*	
	*
	**/
	function clearPopuphazrads() {
		
		// clear the embed tags
		var countembeds = document.getElementsByTagName("embed");
			
		for(i=0; i<countembeds.length;i++) {
			popupSafe.push(countembeds[i]);
 			countembeds[i].style.visibility="hidden";
		}
		
		// clear all the select tags
		var countselects	= document.getElementsByTagName("select");
		for(b=0; b<countselects.length;b++) {
			popupSafe.push(countselects[b]);
 			countselects[b].style.visibility="hidden";
		}
		
	}
	
	/*******************************************************************************************************/
	/**
	*	
	*
	**/
	function reinitPopuphazrads() {

		for(i=0; i<popupSafe.length;i++) {
			if(popupSafe[i].style.visibility == 'hidden') {
 				popupSafe[i].style.visibility="visible";
			}
		}
	}
	

	
	/*******************************************************************************************************/
	/**
	*	
	**/
	function wwwPopup(paintui, style, canvasstyle) {
		
		clearPopuphazrads();
		
		var paintui 		=	typeof(paintui) 	!= 'undefined' 		? 	paintui 	: 	'true';
		var style 			= 	typeof(style) 		!= 'undefined' 		? 	style 		: 	_www_popbox_ui;
		var canvasstyle 	= 	typeof(canvasstyle) != 'undefined'	 	? 	canvasstyle : 	_www_coat_ui;
		
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		if(paintui == 'true') {
			paintCanvas(canvasstyle);
		}
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// now create the popup
		var popup 			= 	document.createElement("div");
		popup.id 			= 	style;
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// create inner pad
		var popupi 			= 	document.createElement("div");
		popupi.id			= 	_www_popinner
		//:::::::::::::::::::::::::::::::::::::::::::::::::	
		// add the header bar
		var popuph 			= 	document.createElement("div");
		popuph.id 			= 	_www_pophead;
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// header left
		var popuphlft 		= 	document.createElement("div");
		popuphlft.id 		= 	_www_popheadlft;
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// add title
		var popuph1 		= 	document.createElement("h1");
		popuph1.id			=	_www_popheadh1
		
		popuphlft.appendChild(popuph1);
		popuph.appendChild(popuphlft);
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// header right
		var popuphrgt 		= 	document.createElement("div");
		popuphrgt.id 		= 	_www_popheadrgt
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// add close link
		var popclose 		= 	document.createElement("a");
		popclose.href		=	'#';
		popclose.onclick 	= 	new Function("return wwwPopClose('"+style+"','"+canvasstyle+"'); return false;");  
		var newClose 		= 	document.createTextNode("x");
		
		popclose.appendChild(newClose);
		popuphrgt.appendChild(popclose);
		popuph.appendChild(popuphrgt);
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// clear
		var popuphclr = document.createElement("div");
		popuphclr.id = _www_pophead_clear;
		popuph.appendChild(popuphclr);
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		popupi.appendChild(popuph);
		popup.appendChild(popupi);	
		document.body.appendChild(popup);

	}
	
	
	/*******************************************************************************************************/
	/**
	*	Add the loading status bar
	**/
	function wwwAddLoadingStatusBar() {
		
		//--------------------------------------------------------
		 var eul = document.createElement("div");
		 	//:::::::::::::::::::::::::::::::::::::::::::::::::
			// add loading img
			var popupimg 				= 	document.createElement("img");
			popupimg.src				=	getImagePath('loading');
			popupimg.height				=	"30";
			popupimg.width				=	"30";
			popupimg.style.marginTop 	=	"10px";
			popupimg.style.marginRight 	=	"10px";
			eul.appendChild(popupimg);

		 return eul;
		 	 
	}
	
	/*******************************************************************************************************/
	/**
	*	
	**/
	function wwwSwapPopupToLoading(settitle, paintui, style, canvasstyle) {
		
		var paintui 		=	typeof(paintui) 	!= 'undefined' 		? 	paintui 	: 	'false';
		var style 			= 	typeof(style) 		!= 'undefined' 		? 	style 		: 	_www_popbox_ui;
		var canvasstyle 	= 	typeof(canvasstyle) != 'undefined'	 	? 	canvasstyle : 	_www_coat_ui;
		var settitle		=	typeof(settitle) 	!= 'undefined'	 	? 	settitle 	: 	"loading";
		
		wwwPopClose(false,false,true);
		wwwPopupLoading(settitle, paintui, style, canvasstyle);
		
	}
	
	
	/*******************************************************************************************************/
	/**
	*	
	**/
	function wwwPopupLoading(settitle, paintui, style, canvasstyle) {
		
		clearPopuphazrads();
		
		var paintui 		=	typeof(paintui) 	!= 'undefined' 		? 	paintui 	: 	'true';
		var style 			= 	typeof(style) 		!= 'undefined' 		? 	style 		: 	_www_popbox_ui;
		var canvasstyle 	= 	typeof(canvasstyle) != 'undefined'	 	? 	canvasstyle : 	_www_coat_ui;
		var settitle		=	typeof(settitle) 	!= 'undefined'	 	? 	settitle 	: 	"loading";
		
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		if(paintui == 'true' && (document.getElementById(canvasstyle) == null)) {
			paintCanvas(canvasstyle);
		}
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// now create the popup
		var popup 			= 	document.createElement("div");
		popup.id 			= 	style;
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// create inner pad
		var popupi 			= 	document.createElement("div");
		popupi.id			= 	_www_popinner
		//:::::::::::::::::::::::::::::::::::::::::::::::::	
		// add the header bar
		var popuph 			= 	document.createElement("div");
		popuph.id 			= 	_www_pophead;
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// header left
		var popuphlft 		= 	document.createElement("div");
		popuphlft.id 		= 	_www_popheadlft;
		
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// add loading img
		var popupimg 				= 	document.createElement("img");
		popupimg.src				=	getImagePath();
		popupimg.height				=	"30";
		popupimg.width				=	"30";
		popupimg.alt				=	settitle;
		popupimg.title				=	settitle;
		popupimg.style.marginTop 	=	"10px";
		popupimg.style.marginRight 	=	"10px";
		popuphlft.appendChild(popupimg);
		
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// add title
		var popuph1 				= 	document.createElement("h1");
		popuph1.id					=	_www_popheadh1
		popuph1.style.position		=	"relative";
		popuph1.style.top		  	=	"-10px";
		
		popuphlft.appendChild(popuph1);
		popuph.appendChild(popuphlft);
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// header right
		var popuphrgt 		= 	document.createElement("div");
		popuphrgt.id 		= 	_www_popheadrgt
		
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		// clear
		var popuphclr = document.createElement("div");
		popuphclr.id = _www_pophead_clear;
		popuph.appendChild(popuphclr);
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		popupi.appendChild(popuph);
		popup.appendChild(popupi);	
		document.body.appendChild(popup);
		//:::::::::::::::::::::::::::::::::::::::::::::::::
		populatePopTitle(settitle+'...');
		positionPopup();
	}
	
	/*******************************************************************************************************/
	/**
	*	
    *
	**/
	function positionPopup(setpos) {
		var setpos 				= 	typeof(setpos) 	!= 	'undefined' 	? 	setpos 	: 	_www_popbox_ui;
		window.location.hash	=	setpos;
		
	}
	
	/*******************************************************************************************************/
	/**
	*	
    *
	**/
	function populatePopTitle(istr) {
		if(document.getElementById(_www_popheadh1) != null) {
			var newTitle 	= 	document.createTextNode(istr);
			document.getElementById(_www_popheadh1).appendChild(newTitle);
		}		
	}

	/*******************************************************************************************************/
	/**
	*	
	*
	*
	**/
	function populatePopSingleCell(iStr) {
		var iStr 		= 	typeof(iStr) 	!= 	'undefined' 	? 	iStr 	: 	null;
		var popinner 	= 	document.getElementById(_www_popinner);
		
		if(popinner != null) {
			
			//:::::::::::::::::::::::::::::::::::::::::::::::::::
			var popInnerSingle 		= 	document.createElement("div");
			popInnerSingle.id 		= 	_www_popinner_single;
			//:::::::::::::::::::::::::::::::::::::::::::::::::::
			var popInnerText 		= 	document.createElement("div");
			popInnerText.id 		= 	_www_popisingle_txt;
			//:::::::::::::::::::::::::::::::::::::::::::::::::::
			if(iStr	!= null) {
				var pinnerTxt 			=	 document.createTextNode(iStr);
				popInnerText.appendChild(pinnerTxt);
			}	
			//:::::::::::::::::::::::::::::::::::::::::::::::::::
			var popBottomText 		= 	document.createElement("div");
			popBottomText.id 		= 	_www_popbottom_txt;
			
			
			popInnerSingle.appendChild(popInnerText);
			popInnerSingle.appendChild(popBottomText);
			popinner.appendChild(popInnerSingle);
		}
	}
	
	
	/*******************************************************************************************************/
	/**
	*	Close the popup box
	**/
	function wwwPopClose(a,b,c,d) {
		var a 		= 	(	(typeof(a) 	!= 'undefined')  && (a != false))	? 		a	 :	_www_popbox_ui;
		var b 		= 	(	(typeof(b) 	!= 'undefined')  && (b != false))	? 		b	 :	_www_coat_ui;
		var c 		= 	(	(typeof(c) 	!= 'undefined')  && (c != false))	? 		c	 :	false;
		var d 		= 	(	(typeof(d) 	!= 'undefined')  && (d != false)) 	? 		d	 :	false;
		
		var pop		= 	document.getElementById(a); 
		var canv 	=  	document.getElementById(b);
		
		if((canv != null) &&  (c != true) ) { 
			document.body.removeChild(canv); 
			reinitPopuphazrads();
		}
		
		if((pop != null) && (d != true) )  { 
			document.body.removeChild(pop); 
		}
		
		return false;
	}
		
	/*******************************************************************************************************/
	/**
	*	
	*
	*
	**/
	function loadXMLDoc(fname) {
		
		var xmlDoc;
		
		if (window.ActiveXObject){
	 		 xmlDoc 	= new ActiveXObject("Microsoft.XMLDOM");
			
		} else if (document.implementation && document.implementation.createDocument) {
 			 xmlDoc		=	document.implementation.createDocument("","", null);
		
		} else  {
  			alert('Your browser cannot correctly load this script');
		}
		
		xmlDoc.async			=	false;
		xmlDoc.validateOnParse 	= 	false;
		xmlDoc.resolveExternals = 	false;
		xmlDoc.load(fname);
		return(xmlDoc);
	}
	
	/*******************************************************************************************************/
	/**
	*	
	*
	*
	**/
	function serveXslt(theXML, theXSL) {

		xml 			= 	theXML;
		xsl				=	loadXMLDoc(theXSL);
		
		if (window.ActiveXObject) {
	  		resultDocument		=	xml.transformNode(xsl);
	  		
	  	} else if (document.implementation && document.implementation.createDocument) {
		  xsltProcessor		=	new XSLTProcessor();
		  xsltProcessor.importStylesheet(xsl);
		  resultDocument 	= 	xsltProcessor.transformToFragment(xml,document);
	  	}

	  	return resultDocument;
	}
	  	
	
	/*******************************************************************************************************/
	/**
	*	
	*
	*
	**/
	function prepare_ajax_cmd(id,instance,cmdCall,cmd,appendposts,mode) {
		var	mode 			= 	 typeof(mode) 			!= 'undefined' 		? 	mode 			: 	'null';
		var id	 			=	 typeof(id) 			!= 'undefined' 		? 	id 				: 	'null';
		var instance	 	=	 typeof(instance)		!= 'undefined' 		? 	instance 		: 	'null';
		var	cmdCall			=	 typeof(cmdCall)		!= 'undefined' 		? 	cmdCall 		: 	'null';
		var	cmd				=	 typeof(cmd)			!= 'undefined' 		? 	cmd 			: 	'null';
		var	appendposts		=	 typeof(appendposts)	!= 'undefined' 		? 	appendposts 	: 	'';
		var xmlDocument		=	 null;
		
		xmlHttp=GetXmlHttpObject()
		url=buildURL()
		
		if ( xmlHttp==null ) {
			alert ('Browser does not support HTTP Request')
			return
		} 
		
		xmlHttp.open( 'POST', url, true )
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8')
		xmlHttp.send('mode='+mode+'&cmdcall='+cmdCall+'&cmd='+cmd+'&id='+id+'&instance='+instance+''+appendposts)
		return xmlHttp;
	}
	
	
	/*******************************************************************************************************/
	/**
	* FIND && SORT ERRORS
	* We only return the first error - we do not want to overload the user with errors 
	**/
	function checkForAjaxErrors(xmlDocument) {
		
		try {
			var numoferrors 	= 	xmlDocument.getElementsByTagName('error').length
			
			if(numoferrors >= 1) {
				var seterrorStatus 		= 	xmlDocument.getElementsByTagName('error')[0].childNodes[0].childNodes[0].nodeValue
				var seterrorText 		= 	xmlDocument.getElementsByTagName('error')[0].childNodes[2].childNodes[0].nodeValue
				return {set:true, status:seterrorStatus, etext:seterrorText};
				
			} else {
				return {set:false, status:false, etext:false};
			}
		} catch(e) {
			return {set:true, status:'Warning', etext:e};
		}
	}
	
	/*******************************************************************************************************/
	/**
	* Alert any error
	**/
	function alertError(status,msg) {
		var	status 			= 	 ((typeof(status) 	!= 'undefined')	 	&&		(status != ''))		? 	status 			: 	'Warning';
		var msg	 			=	 typeof(msg) 		!= 'undefined' 									? 	msg 			: 	'Unknown error';
		
		
		wwwPopClose();
		alert(status + '\r\n' + msg);
		
	}
	
	/*******************************************************************************************************/
	/**
	* Catch exception error
	*  @param 	(str)	msg
	*  @return array
	**/
	function catchError(msg) {
		if(_InsaoWWWDebug == true) {
			var msg	 			=	 typeof(msg) 		!= 'undefined' 		? 	msg 			: 	'Unknown error';
			wwwPopClose();
			alert(msg);
		}
		
	}
	
	/*******************************************************************************************************/
	/**
	*  
	**/
	function displayErrorBox(xmlDocumentErrors) {
		alert(xmlDocumentErrors.status + '\r\n' + xmlDocumentErrors.etext)
	}
	
	/*******************************************************************************************************/
	/**
	* INSAO Debug Mode
	**/
	function insaoDebugMethod() {
		if(_InsaoWWWDebug == true) {
			alert(xmlHttp.responseText);
		}
	}
	
	/*****************************************************************************************************************************************************************************/
	/**
	* SPECIFIC
	*/ 
	function CenteredPopup(mypage, myname, w, h, scroll) {
		 var winl = (screen.width - w) / 2;
		 var wint = (screen.height - h) / 2;
		 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
		 win = window.open(mypage, myname, winprops)
		 if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}

	var defaultrandomnumber	= 1;
	
	
	function defaultStopRotator(abool, pid,sid) {
		
		stoprotator		=	abool
		
			if(document.getElementById('plet_siteDefaultRotator_a_'+sid) != null) {
				var aalink					=	document.getElementById('plet_siteDefaultRotator_a_'+sid)
				aalink.href					=	surlsArray[pid];
				aalink.title				=	sminititle[pid].replace(/----/ig,"&");
				
				aalink.childNodes[0].src 	=	"/-/shared/img/shared/" + ssrcsArray[pid]; 
				aalink.childNodes[0].alt 	=	sminititle[pid].replace(/----/ig,"&");
				
				
				if(document.getElementById('cruise_line_microsites_ul') != null) {
					for(x=0; x<document.getElementById('cruise_line_microsites_ul').childNodes.length; x++) {
						document.getElementById('cruise_line_microsites_ul').childNodes[x].childNodes[0].childNodes[0].style.border = "2px solid #fff";
					}
					
					var minilogo				=	sminiurlsArray[pid];
					document.getElementById(minilogo).style.border = "2px outset"
					
					// -----------------------------------------------------
					// set the title
					currenttnode	=	document.getElementById('cruise_line_microsites_title').childNodes[0];
					replacemynode	=	document.createTextNode(sminititle[pid].replace(/----/ig,"&"))
					document.getElementById('cruise_line_microsites_title').replaceChild(replacemynode,currenttnode)
				}
			
			}
	}
	
	
	
	function defaultRotator(sid) {
		var stoprotator	 			=	 typeof(stoprotator) 		!= 'undefined' 		? 	stoprotator 			: 	false;
		if(stoprotator != true) {
			setTimeout("defaultRotatorRun()",1500)
		}
	}
	
	
	
	function defaultRotatorRun()  {
		var stoprotator	 			=	 typeof(stoprotator) 		!= 'undefined' 		? 	stoprotator 			: 	false;
		try {		
			if(stoprotator != true) {
				var lenArray		=	sminiurlsArray.length;
				// change the logo border
				if(document.getElementById('cruise_line_microsites_ul') != null) {
					for(x=0; x<document.getElementById('cruise_line_microsites_ul').childNodes.length; x++) {
						document.getElementById('cruise_line_microsites_ul').childNodes[x].childNodes[0].childNodes[0].style.border = "2px solid #fff";
					}
					
					var minilogo				=	sminiurlsArray[defaultrandomnumber];
					document.getElementById(minilogo).style.border = "2px outset"
					
					// -----------------------------------------------------
					// set the title
					currenttnode	=	document.getElementById('cruise_line_microsites_title').childNodes[0];
					replacemynode	=	document.createTextNode(sminititle[defaultrandomnumber].replace(/----/ig,"&"))
					document.getElementById('cruise_line_microsites_title').replaceChild(replacemynode,currenttnode)
				}
				
				
				if(defaultrandomnumber == (lenArray-1)) {
					defaultrandomnumber			=	0;
				} else {
					defaultrandomnumber			=	defaultrandomnumber + 1;
				}
				
				defaultRotator() ;
			}
		} catch(e) {
			alert(e);
		}
	}

