var rootdomain="http://www.halongboats.com"+window.location.hostname

function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}

function load( url, id )
{
  return function( event )
  {
    if( !event.button ) // only on left mousebutton or keyboard event
    {
      event.stopPropagation();
      event.preventDefault();
      var img = document.getElementById( id );
      if( img.className == 'loading' ) return;
      img.className = 'loading';
      img.parentNode.title = 'Loading; please wait.';
      pulsate( img );
      var what = plugins[id], method = what.method||'GET', data = '';
      var request = { url:url, method:method, onload:function( http )
		      { img.parentNode.title = 'Completed OK.';
			img.className = 'ok'; }, onerror:function( http )
		      { img.parentNode.title = 'Failed!';
			img.className = 'die'; } };
      if( method == 'POST' )
      {
	url = /^([^?]+)\??(.*)/.exec( url );
	request.url = url[1];
	request.data = url[2];
	if( what.extra_data )
	  request.data = request.data +'&'+ what.extra_data;
	request.headers = {'Content-Type':'application/x-www-form-urlencoded'};
      }
      GM_xmlhttpRequest( request );
    }
  };
}

function addonclick( link, url, id )
{
  //GM_log( 'onclick '+id+': '+link );
  link.href = url;
  if( id )
  {
    link.addEventListener( 'click', load( url, id ), false );
    link.addEventListener( 'keypress', load( url, id ), false );
  }
}
var Url = {

    // public method for url encoding
    encode: function(string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode: function(string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode: function(string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },


    // private method for UTF-8 decoding
    _utf8_decode: function(utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while (i < utftext.length) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}
function preload() {
	for (var ctr = 0,imgs = Array(); ctr < arguments.length; ctr++) {
		imgs[ctr] = document.createElement('img');
		imgs[ctr].src = arguments[ctr];
	}
}
function formatTime( t )
{
  var date = [t.getFullYear(), pad( t.getMonth()+1 ), pad( t.getDate() )];
  var time = [pad( t.getHours() ), pad( t.getMinutes() )];
  return date.join( '-' ) +' '+ time.join( ':' );
}

function trap( node, event, handler )
{
/*  var original = node.getAttribute( 'on'+event );
  if( original )
  {
    original = original.replace( /;\s*$/, '' ).split( ';' );
    var last = original.pop();
    var next = 'setTimeout("'+ original.join(';') +'",100);' + last;
    node.setAttribute( 'on'+event, next );
  }
*/
  node.addEventListener( event, handler, false );
}

function accesskey( node, key, keys, color )
{
  var reserved = keys || { 'd':1, 'o':1, '.':1 };
  var accesskey = 'Alt+'; // browsers have different ideas about accesskeys
  if( navigator.userAgent.match( /opera/i ) )
    accesskey = 'Shift+Esc followed by ';
  else if( navigator.userAgent.match( /macintosh/i ) )
    accesskey = 'Control+';

  if( !key )
  {
    var letters = node.textContent.replace( /\W/g, '' ), i; // first word char
    for( i=0; i<letters.length; i++ )
    {
      key = letters.charAt( i ); // will this letter do?
      if( !reserved[key.toLowerCase()] ) break; // found the first free letter
      key = null; // try, try again!
    }
    if( !key ) return reserved; // too bad; don't do anything at all.
  }
  underline( node, key );
  reserved[key.toLowerCase()] = 1; // taken!
  node.title = 'Hotkey: '+ accesskey + key.toLowerCase(); // usability hint
  node.accessKey = key.toUpperCase();
  if( color ) node.style.color = color; // colorize the link as applicable
  return reserved;
}

function underline( node, key )
{
  if( !node ) return;
  var character = new RegExp( '^(<[^>]*>)*([^<'+ key +']*)*('+ key +')', 'i' );
  var hasOne = getStyle( node, 'textDecoration' ).match( 'underline' );
  var style = hasOne ? 'border-bottom:1px solid' : 'text-decoration:underline';
  var underlined = '$1$2<span style="'+ style +';">$3</span>';
  node.innerHTML = node.innerHTML.replace( character, underlined );
}

function getStyle( node, style )
{
  if( node.currentStyle )
    return node.currentStyle[ style ];
  if( window.getComputedStyle )
    return getComputedStyle( node, null )[ style ];
  return '';
}
// special_functions.js
// functions for master header home page include
var pollCancel = false; 

    function validateOnlinePollForm(form) {                                                                   
        if (pollCancel) 
      return true; 
        else 
       return validateRequired(form); 
   } 

    function required () { 
     this.aa = new Array("answerId", "An answer to the Online Poll is required.", new Function ("varName", " return this[varName];"));
    } 

//<!-- FLASH w/AUDIO CONTROL BEGIN v1.0-->

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//Cookie function on home page
function setCookie(name, value, expires, path, domain, secure) {
   var curCookie = name + "=" + escape(value) +
       ((expires) ? "; expires=" + expires : "") +
       ((path) ? "; path=" + path : "") +
       ((domain) ? "; domain=" + domain : "") +
       ((secure) ? "; secure" : "");
   document.cookie = curCookie;
}
function getCookie(name) {
   var dc = document.cookie;
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);
   if (begin == -1) {
     begin = dc.indexOf(prefix);
     if (begin != 0) return null;
   } else
     begin += 2;
   var end = document.cookie.indexOf(";", begin);
   if (end == -1)
     end = dc.length;
   return unescape(dc.substring(begin + prefix.length, end)); } function fixDate(date) {
   var base = new Date(0);
   var skew = base.getTime();
   if (skew > 0)
     date.setTime(date.getTime() - skew); } // --> </SCRIPT>


function processCookie()
{
var now = new Date();
fixDate(now);

//now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); 

//Set timeout to 30 minutes since the last visit
now.setMinutes(now.getMinutes() + 30);

homeVisits = getCookie("counter"); 
if (!homeVisits) {
   homeVisits = 1;
   document.write("<!-- -->");
} 
else {
   homeVisits = parseInt(homeVisits) + 1;
   document.write("<!--  -->"); 
}

setCookie("counter", homeVisits, now.toGMTString());
}
/// FUNCTION CHECK COOKIE ///
function cookie(name,value)
{ this.name = name;
this.value = value;
this.attributes = new Array();
this.expiresIn = function (days)
{ expiration = new Date();
expiration.setTime(expiration.getTime() + (days*86400000));
this.attributes["expires"] = expiration.toGMTString();
};
this.set = function ()
{ var cookiestr = this.name + "=" + escape(this.value);
for(attr in this.attributes)
{ cookiestr += "; " + attr
if(this.attributes[attr].length > 0)
cookiestr += "=" + this.attributes[attr];
}
document.cookie=cookiestr;
};
this.erase = function()
{ this.expiresIn(-1);
this.set();
delete cookies[this.name];
};
}

function cookieContainer()
{ this.add=function (name,value)
{ this[name]=new cookie(name,value);
};
this.get=function (name)
{ for(o in this)
if(o == name)
return this[o];
return null;
}
var cstr=document.cookie;
var spaces=/s/gi;
cstr=cstr.replace(spaces,'');
while(cstr.length>0)
{ cequal=cstr.indexOf("=");
if(cequal==-1) cequal=cstr.length;
var name=cstr.substring(0,cequal);
cstr=cstr.substring(cequal+1,cstr.length);
cend=cstr.indexOf(";");
if(cend==-1) cend=cstr.length;
var value=unescape(cstr.substring(0,cend));
cstr=cstr.substring(cend+1,cstr.length);
this.add(name,value);
}
}
var cookies = new cookieContainer();

///////////////////////////////////////////
var URIHalongboats = 
{ 
        /** 
         * Dump the contents of the URI hash into an associative array. If the hash is invalid, the method returns 
         * undefined. 
         */ 
        dump : function() 
        { 
                var halongboats = document.location.halongboats; 
                var dump = new Array(); 
 
                if(halongboats.length == 0) return dump; 
 
                halongboats = halongboats.substring(1).split('&'); 
 
                for(var key in halongboats) 
                { 
                        var pair = halongboats[key].split('='); 
 
                        if(pair.length != 2 || pair[0] in dump) 
                                return undefined; 
 
                        // escape for storage 
                        dump[unescape(pair[0])] = unescape(pair[1]); 
                } 
 
                return dump; 
        }, 
 
        /** 
         * Takes an associative array and stores it in the URI as a hash after the # prefix, replacing any pre- 
         * existing halongboats. 
         */ 
        load : function(array) 
        { 
                var first = true; 
                var halongboats = ''; 
 
                for(var key in array) 
                { 
                        if(!first) halongboats += '&'; 
                        halongboats += escape(key) + '=' + escape(array[key]); 
                } 
 
                document.location.halongboats = halongboats; 
        }, 
 
        /** 
         * Get the value of a key from the halongboats.  If the halongboats does not contain the key or the hash is invalid, 
         * the function returns undefined. 
         */ 
        get : function(key) 
        { 
                return this.dump()[key]; 
        }, 
 
        /** 
         * Set the value of a key in the hash.  If the key does not exist, the key/value pair is added. 
         */ 
        set : function(key,value) 
        { 
                var dump = this.dump(); 
                dump[key] = value; 
 
                var halongboats = new Array(); 
 
                for(var key in dump) 
                        halongboats.push(escape(key) + '=' + escape(dump[key])); 
 
                document.location.halongboats = halongboats.join('&'); 
        } 
} 

var ids = document.getElementsByTagName('id');
for(i=0;i<ids.length;i++){
    alert('position: ' + i + ', ID:' + ids[i].textContent);
}
var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}
function isIE6() {
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
	}
	return (version && (version < 7));
}
// Functions that are specific to single pages (mainly include jsp files) are moved here to facilitate the Java script move to external file
function openPopupExtraParams(name, url, height, width, menubar, location, toolbar, scrollbars, status, resizable){
	var tmpPopup; var strProperties = "menubar=" + menubar + ",location=" + location + ",toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",status=" + status + ",resizable=" + resizable + ",width=" + width + ",height=" + height + ",left=0, top=0";
	tmpPopup = window.open(url, name, strProperties); tmpPopup.focus();
}

function openPopup(name, url, height, width, menubar, location, toolbar, scrollbars, status, resizable){
	var tmpPopup; var strProperties = "menubar=" + menubar + ",location=" + location + ",toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",status=" + status + ",resizable=" + resizable + ",width=" + width + ",height=" + height + ",left=0, top=0";
	tmpPopup = window.open(url, name, strProperties); tmpPopup.focus();
}
function openWindow(url, name, width, height) {popupWin = window.open(url, name, "resizable=no,location=no,scrollbars=yes,width="+width+",height="+height); 
}

if (self.location.href != top.location.href) {
			top.location.href = self.location.href;
		}

		//if (document.createElementNS && window.DOMParser) document.createElement = function(elName) {
		//	document.createElementNS("http://www.w3.org/1999/xhtml", elName); }

		var savedhighlighttagid = '';

		var W3CDOM = (document.createElement && document.getElementsByTagName && document.getElementById);

		function trim (text) {
			text = text.replace(/^\s*|\s*$/g,"");
			return text;
		}

		function highlight(tagid) {
			if (!W3CDOM) return;
			var listid = tagid.substring(3);
			document.getElementById('list' + listid).className = 'activelist';
		}

		function savehighlight(tagid) {
			if (!W3CDOM) return;
			var listid = tagid.substring(3);
			if (document.getElementById('list' + savedhighlighttagid)) {
				document.getElementById('list' + savedhighlighttagid).className = 'inactivelist';
			}
			if (savedhighlighttagid == listid) {
				savedhighlighttagid = '';
				document.getElementById('list' + listid).className = 'activelist';
			} else {
				savedhighlighttagid = listid;
				document.getElementById('list' + listid).className = 'savedactivelist';
			}
		}

		function dehighlight(tagid) {
			if (!W3CDOM) return;
			var listid = tagid.substring(3);
			if (savedhighlighttagid == listid) {
				document.getElementById('list' + listid).className = 'savedactivelist';
			} else {
				document.getElementById('list' + listid).className = 'inactivelist';
			}
		}

		/* 
			By Simon Willison
			http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/
		*/
		function addLoadEvent(func) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
					window.onload = func;
				} else {
					window.onload = function() {
					if (oldonload) {
						oldonload();
					}
					func();
				}
			}
		}

		/* 
			Based on code by Simon Willison
			http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/
		*/
		function addClickEvent(func) {
			var oldonclick = window.onclick;
			if (typeof window.onclick != 'function') {
					window.onclick = func;
				} else {
					window.onclick = function() {
					if (oldonclick) {
						oldonclick();
					}
					func();
				}
			}
		}

		/* 
			Based on code by Simon Willison
			http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/
		*/
		function addScrollEvent(func) {
			var oldonscroll = window.onscroll;
			if (typeof window.onscroll != 'function') {
					window.onscroll = func;
				} else {
					window.onscroll = function() {
					if (oldonscroll) {
						oldonscroll();
					}
					func();
				}
			}
		}

        /*
            Developed by Robert Nyman, http://www.robertnyman.com
            Code/licensing: http://code.google.com/p/getelementsbyclassname/
        */
        var getElementsByClassName = function (className, tag, elm){
            if (document.getElementsByClassName) {
                getElementsByClassName = function (className, tag, elm) {
                    elm = elm || document;
                    var elements = elm.getElementsByClassName(className),
                        nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
                        returnElements = [],
                        current;
                    for(var i=0, il=elements.length; i<il; i+=1){
                        current = elements[i];
                        if(!nodeName || nodeName.test(current.nodeName)) {
                            returnElements.push(current);
                        }
                    }
                    return returnElements;
                };
            }
            else if (document.evaluate) {
                getElementsByClassName = function (className, tag, elm) {
                    tag = tag || "*";
                    elm = elm || document;
                    var classes = className.split(" "),
                        classesToCheck = "",
                        xhtmlNamespace = "http://www.w3.org/1999/xhtml",
                        namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
                        returnElements = [],
                        elements,
                        node;
                    for(var j=0, jl=classes.length; jjl; j+=1){
                        classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
                    }
                    try	{
                        elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
                    }
                    catch (e) {
                        elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
                    }
                    while ((node = elements.iterateNext())) {
                        returnElements.push(node);
                    }
                    return returnElements;
                };
            }
            else {
                getElementsByClassName = function (className, tag, elm) {
                    tag = tag || "*";
                    elm = elm || document;
                    var classes = className.split(" "),
                        classesToCheck = [],
                        elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
                        current,
                        returnElements = [],
                        match;
                    for(var k=0, kl=classes.length; k<kl; k+=1){
                        classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
                    }
                    for(var l=0, ll=elements.length; lll; l+=1){
                        current = elements[l];
                        match = false;
                        for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
                            match = classesToCheck[m].test(current.className);
                            if (!match) {
                                break;
                            }
                        }
                        if (match) {
                            returnElements.push(current);
                        }
                    }
                    return returnElements;
                };
            }
            return getElementsByClassName(className, tag, elm);
        };

        eval(function(p,a,c,k,e,r){e=function(c){return c.toString(36)};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'\\w'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3.5=r;3.7=[];3.6=4(){1(d.9.8){n}d.9.8=u;1(5){q(5)}f a;for(i in 7){1(typeof(a=7[i])=="4"){a.g(2)}}};4 onDOMLoad(a){7.push(a);1(d.9.8){n}d.9.8=u;1(2.k){2.k("DOMContentLoaded",6,r)}else 1(2.all&&!3.opera){2.write(\'j type="text/t" id="s" l="l" src="t:void(0);"><\\/j>\');f b=2.getElementById("s");b.onreadystatechange=4(){1(this.o=="m"){6.g(2)}}}1(/Safari/i.p(navigator.userAgent)){5=setInterval(4(){1(/loaded|m/.p(2.o)){q(5);6.g(2)}},10)}f c=(3.h)?3.h:4(){};3.h=4(e){c(e);6()}}',[],31,'|if|document|window|function|sFT|callDLFs|onDLFs|done|callee||||arguments||var|apply|onload||script|addEventListener|defer|complete|return|readyState|test|clearInterval|false|contentloadtag|javascript|true'.split('|'),0,{}))