<!--
var loadingHTML = '<div align="center" style="height:100%; width:100%; vertical-align:middle;"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><img align="middle" alt="loading" src="/themes/default/images/ajax-loader.gif" /></div>'; 
var dragables = [];                         
   

/****************TABLE FUNCTIONS**********************/ 

function initDataTable() { myDataTable = new DataTable(); }  
Event.observe(window, 'load', initDataTable, false);

var DataTable = { Version: '1.0' };

var DataTable = Class.create();

DataTable.prototype = {
                             
    // initialize()  
    
    initialize: function() 
    {     
       this.setupRopHover();        
    },
    
    setupRopHover: function()
    {
        var objBody = document.getElementsByTagName("body").item(0)
        var row = new Array();    
        row1 = objBody.getElementsByClassName('row1');  
        row2 = objBody.getElementsByClassName('row2');
        for(i=0;i<row1.length;i++)
        {                            
            row[i] = row1[i]; 
        } 
        for(i=0;i<row2.length;i++)
        {                            
            row[row.length+i] = row2[i]; 
        }
        row = row.compact();
        for(i=0;i<row.length;i++)
        {   
            this.eventMouseOver   = this.showHighlight.bindAsEventListener(this);  
            this.eventMouseOut    = this.hideHighlight.bindAsEventListener(this);
            this.eventClick       = this.editEvent.bindAsEventListener(this);
            row[i].observe('mouseover', this.eventMouseOver);  
            row[i].observe('mouseout', this.eventMouseOut); 
            if(row[i].title.length > 0)
            {
                row[i].observe('click', this.eventClick); 
            }                                                                                           
        }         
    },
    
    editEvent:  function(el)
    {  
        if(Event.element(el).up().match('tr'))
        {   
            redirectTo(Event.element(el).up().title);            
        }        
    },
    
    showHighlight: function(el)
    {
        if(Event.element(el).up().match('tr'))
        {
            Event.element(el).up().addClassName('row_highlight'); 
        }
    },
    
    hideHighlight: function(el)
    {
        if(Event.element(el).up().match('tr'))
        {
            Event.element(el).up().removeClassName('row_highlight');
        }
    }
    
}
                            




function redirectTo(place)
{
    window.location.href = place;
}   
   
function loadNodeMenu()
{
    width = f_clientWidth();
    scrollh = f_scrollTop();
    Element.update('layerPnlInner',loadingHTML);        
    Element.setTop('layerPnl',scrollh+100);
    Element.setLeft('layerPnl',width/2 -480);     
    Element.show('layerPnl');
    resizeWindow('layerPnl', 130, 400); 
    new Ajax.Updater('layerPnlInner', '/ajax/nodemenu/', {method: 'get'}); 
}   

function makeDragable(layerid, revert, drop)
{                                      
    if(revert)
    {
        dragables[layerid] = new Draggable(layerid, { revert: true, scroll: window});
    }else
    {
        dragables[layerid] = new Draggable(layerid, { scroll: window});
    }
    if(drop)
    {               
        for(i=1;i<11;i++)
        {          
            Droppables.add(
                 'nodezone'+i,
                 {
                    hoverclass: 'hoverActive',
                    onDrop: moveItem
                 }
            ); 
        }    
    }      
} 

function moveItem(draggable,droparea)
{ 
    var mySplitResult = droparea.title.split("/");
 
   zone = mySplitResult[0];
   page = mySplitResult[1];
   type = draggable.title; 
   new Ajax.Updater('nodezoneinner'+zone, '/ajax/addNode/'+zone+'/'+type+'/'+page , {method: 'get'});
}

function deleteNode(node, zone, page)
{
    new Ajax.Updater('nodezoneinner'+zone, '/ajax/deleteNode/'+node+'/'+zone+'/'+page , {method: 'get'});     
}

function loadGalleryDetails(galleryid)
{
    windowSize = getPageSizeWithScroll(); 
    scrollh = f_scrollTop();    
    Element.update('layerPnlInner',loadingHTML);        
    Element.setTop('layerPnl',scrollh + windowSize[1]/2 - 250);
    Element.setLeft('layerPnl',windowSize[0]/2 -400);
    Element.setHeight('PopupOverlay',windowSize[1]);     
    showpopup('layerPnl');
    resizeWindow('layerPnl', 800, 500);
    new Ajax.Updater('layerPnlInner', '/ajax/galleryDetails/'+galleryid, {method: 'get'});
}

function editNode(node,pageid)
{                                                       
    windowSize = getPageSizeWithScroll(); 
    scrollh = f_scrollTop();    
    Element.update('layerPnlInner',loadingHTML);        
    Element.setTop('layerPnl',scrollh + windowSize[1]/2 - 250);
    Element.setLeft('layerPnl',windowSize[0]/2 -400);
    Element.setHeight('PopupOverlay',windowSize[1]);     
    showpopup('layerPnl');
    resizeWindow('layerPnl', 800, 500);
    new Ajax.Updater('layerPnlInner', '/ajax/nodeDetails/'+node+'/'+pageid, {method: 'get'});
}

function showElementMenu(layer)
{
    Element.show(layer);
}

function hideElementMenu(layer)
{
    Element.hide(layer);
}


function stopDraggable(layerid)
{
    dragables[layerid].destroy();
}

function loadDetails(pageid)
{                                                    
    windowSize = getPageSizeWithScroll(); 
    scrollh = f_scrollTop();
    Element.update('layerPnlInner',loadingHTML);        
    Element.setTop('layerPnl',scrollh + windowSize[1]/2 - 200);
    Element.setLeft('layerPnl',windowSize[0]/2 -300);
    Element.setHeight('PopupOverlay',windowSize[1]);     
    showpopup('layerPnl');
    resizeWindow('layerPnl', 600, 400);
    new Ajax.Updater('layerPnlInner', '/ajax/pageDetails/'+pageid, {method: 'get'});
}

function loadTab(tab, tabbtn)
{                                        
    var tabs = $('editorTabs').childElements();               
    var tabboxes = $('tabBoxes').childElements();    
    for(i=0;i<tabboxes.length;i++)
    {                       
        tabboxes[i].hide();
    }
    for(z=0;z<tabs.length;z++)
    {                                            
        tabs[z].removeClassName('editortabactive');
    }
    Element.show(tab);
    Element.addClassName(tabbtn,'editortabactive');
}

function submitForm(formname, type)
{
    var form = document.getElementById(formname);
    var formtype = document.getElementById('savetype');
    formtype.value = type;
    form.submit(); 
}

function checkPageName(pagename, pageid)
{
    var urllink = document.getElementById('url');
    var title = document.getElementById('title');  
    if(title.value.length < 1)
    {
        title.value = pagename.value;                 
    }
    if(urllink.value.length < 1)
    {
        Element.show('linkerror');
        new Ajax.Request('/ajax/checkUrlLink/'+pagename.value+'/'+pageid, {
        method: 'get',
        onSuccess: function(transport){
            var msg = $('linkerror');             
            if(transport.responseText.match(/yes/))    {
                msg.update('Sorry this url link has been taken.');
                url.value = ""; 
            }
            else{
                urllink.value = pagename.value;
                msg.update('<img alt="checking..." src="/themes/default/images/ajax-loader_sml.gif" align="middle"/>');
                Element.hide('linkerror');           
            }
        }

        });       
    }
}

function checkPageUrl(url, pageid)
{   
    Element.show('linkerror');
    new Ajax.Request('/ajax/checkUrlLink/'+url.value+'/'+pageid, {
    method: 'get',
    onSuccess: function(transport){
        var msg = $('linkerror');             
        if(transport.responseText.match(/yes/))    {
            msg.update('Sorry this url link has been taken.');
            url.value = ""; 
        }
        else{
            msg.update('<img alt="checking..." src="/themes/default/images/ajax-loader_sml.gif" align="middle"/>');
            Element.hide('linkerror');           
        }
    }  
    }); 
}


//sub functions

function resizeWindow(name, newWidth, newHeight)
{
    // get curren width and height
    this.widthCurrent = Element.getWidth(name);
    this.heightCurrent = Element.getHeight(name);

    // scalars based on change from old to new
    this.xScale = ( newWidth / this.widthCurrent) * 100;
    this.yScale = ( newHeight / this.heightCurrent) * 100;

    // calculate size difference between new and old image, and resize if necessary
    wDiff = this.widthCurrent - newWidth;
    hDiff = this.heightCurrent - newHeight;

    if(!( hDiff == 0)){ new Effect.Scale(name, this.yScale, {scaleX: false, duration: 0.6, queue: 'front'}); }
    if(!( wDiff == 0)){ new Effect.Scale(name, this.xScale, {scaleY: false, delay: 0.6, duration: 0.6}); }

}

function showpopup(id)
{    
    setOpacity("PopupOverlay");
    Element.show('PopupOverlay');
    Element.show(id);
}

function closePopup(name, inner)
{
    Element.hide('PopupOverlay');
    Element.hide(name);
    if(inner != "")
    {
        Element.update(inner,loadingHTML);    
    }
    //resetWindow('enquirePnl');
}

function setOpacity(name)
{
    if (navigator.appVersion.indexOf("MSIE")!=-1)
    {
        Element.setFilter(name,'alpha(opacity=50)');
    }
    else
    {
        Element.setOpacity(name,'0.5');
    }
}

function f_clientWidth() {
    return f_filterResults (
        window.innerWidth ? window.innerWidth : 0,
        document.documentElement ? document.documentElement.clientWidth : 0,
        document.body ? document.body.clientWidth : 0
    );
}
function f_clientHeight() {
    return f_filterResults (
        window.innerHeight ? window.innerHeight : 0,
        document.documentElement ? document.documentElement.clientHeight : 0,
        document.body ? document.body.clientHeight : 0
    );
}
function f_scrollLeft() {
    return f_filterResults (
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    );
}
function f_scrollTop() {
    return f_filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}

function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function getPageSizeWithScroll()
{
    var scnWid,scnHei;
    if (self.innerHeight) // all except Explorer
    {
        scnWid = self.innerWidth;
        scnHei = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
        // Explorer 6 Strict Mode
    {
        scnWid = document.documentElement.clientWidth;
        scnHei = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        scnWid = document.body.clientWidth;
        scnHei = document.body.clientHeight;
    }
	

    arrayPageSizeWithScroll = new Array(scnWid,scnHei);
    //alert( 'The height is ' + scnHei + ' and the width is ' + scnWid );
    return arrayPageSizeWithScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//OLD scripts delete if not used


	
	function submitSearch(e, btnid)
	{
		var characterCode;
		var btn = document.getElementById(btnid);

		if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which; //character code is contained in NN4's which property
		}
		else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		//alert(characterCode);
		
		if(characterCode == 13){ 
			btn.click();
			return false;
		}else
		{
			return false;
		}
	}
	
	
function ShowHideLayer(id, todo)
{
	if(todo == 'show')
	{
		Element.show(id);
	}else
	{
		Element.hide(id);
	}
}



function showThanks()
{
	width = f_clientWidth();
	scrollh = f_scrollTop();
	
	Element.setTop('enquirePnl',scrollh+100);
	Element.setLeft('enquirePnl',width/2 -250);
		
	showpopup('enquirePnl');
	//resizeWindow('enquirePnl', 500, 485);
	new Ajax.Updater('enquirePnlInner', 'lib/thanks.php', {method: 'get'});
}

function showDetail(thepage)
{
	overlay=document.getElementById('PopupOverlay');
	page = document.getElementById('body');
	if(overlay)
	{		
		height = page.offsetHeight;		
		Element.setHeight('PopupOverlay',  height + 300);
		newh = height + 500;
	}
	width = f_clientWidth();
	scrollh = f_scrollTop();
	
	Element.setTop('enquirePnl',scrollh+100);
	Element.setLeft('enquirePnl',width/2 -250);
		
	showpopup('enquirePnl');
	//resizeWindow('enquirePnl', 500, 485);
	new Ajax.Updater('enquirePnlInner', thepage+'.html', {method: 'get'});	
}

function loadEnquire(vesselName)
{
	pagesize = getPageSize();
    scrollh = f_scrollTop();
    Element.update('enquirePnlInner',loadingHTML);        
    Element.setTop('enquirePnl',scrollh + pagesize[3]/2 - 300);
    Element.setLeft('enquirePnl',pagesize[0]/2 -300);
    Element.setHeight('PopupOverlay',pagesize[1]);     
    showpopup('enquirePnl');
    resizeWindow('enquirePnl', 600, 550);     
	new Ajax.Updater('enquirePnlInner', 'vessel-info/'+vesselName+'.html', {method: 'get'});
}

function loadGroups(groupInfo)
{
    pagesize = getPageSize();
    scrollh = f_scrollTop();
    Element.update('enquirePnlInner',loadingHTML);        
    Element.setTop('enquirePnl',scrollh + pagesize[3]/2 - 300);
    Element.setLeft('enquirePnl',pagesize[0]/2 -300);
    Element.setHeight('PopupOverlay',pagesize[1]);     
    showpopup('enquirePnl');
    resizeWindow('enquirePnl', 600, 550);     
    new Ajax.Updater('enquirePnlInner', 'groups-info/'+groupInfo+'.html', {method: 'get'});
}

function loadBox(value)
{
	page = document.getElementById('body');
	
	width = f_clientWidth();
	scrollh = f_scrollTop();	
	height = page.offsetHeight;
	
	Element.setTop('enquirePnl',scrollh+150);
	Element.setLeft('enquirePnl',width/2 -250);	
	Element.setHeight('PopupOverlay',height+20);
		
	showpopup('enquirePnl');
	//resizeWindow('enquirePnl', 500, 485);
	new Ajax.Updater('enquirePnlInner', 'lib/map_entry.php?entry='+value, {method: 'get'});
}


function userValidate(form) { // OPEN FUNCTION  userValidate
	
	var email = form.hfs_email.value; // email value
	var checkEmail = /^([a-zA-Z0-9-_\.]+)@([a-zA-Z0-9-\.]+)\.[a-z]{2,4}$/; // email value check	
	
	if(form.hfs_fname.value.length <1) { form.hfs_fname.select(); // selects field if less than 1
												 alert("Please enter your First Name");									  	   	 
												 return false; } // alerts msg & then quits function if less than 1
	if(form.hfs_sname.value.length <1) { form.hfs_sname.select(); // selects field if less than 1
												 alert("Please enter your Last Name");	
												 return false; } // alerts msg & then quits function if less than 1		
	
	else if(!(checkEmail.test(email))) { form.hfs_email.select();
												 alert("Please enter a valid e-mail address");									  	   	 
												 return false; }
	else if(form.captcha.value.length <4) { form.captcha.select(); // selects field if less than 1
												 alert("Please enter the 4 letter code");	
												 return false; } // alerts msg & then quits function if less than 1
	
		
	else { return true; }// submits form results
			
						
						} // CLOSE FUNCTION SUBBUTT
						
	function validateCODE() { // OPEN FUNCTION  userValidate
	
	if(form.captcha.value.length <4) {form.captcha.select(); // selects field if less than 1
												 alert("Please enter the 4 letter code");												
												 return false; } // alerts msg & then quits function if less than 1		
	
			
						
						} // CLOSE FUNCTION SUBBUTT
// JavaScript Document      s

-->