//**********************************
window.location.querystring = (function() {
    var collection = {};
    var querystring = window.location.search;
    var pairs = querystring.split("&");
 
    if (!querystring) {
        return { toString: function() { return ""; } };
    }
    querystring = decodeURI(querystring.substring(1));
    for (var i = 0; i < pairs.length; i++) {
        if (!pairs[i]) {
           continue;
        }
        var seperatorPosition = pairs[i].indexOf("=");
        if (seperatorPosition == -1) {
          collection[pairs[i]] = "";
        }
        else {
            collection[pairs[i].substring(0, seperatorPosition)] 
                = pairs[i].substr(seperatorPosition + 1);
        }
    } 
    collection.toString = function() {
        return "?" + querystring;
    }; 
    return collection;
})();

var querystring = window.location.querystring;
//**************************************

//***************************************
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}
//************************************

function rollOver(cellId){
 cellId.style.color="#ff0000"
}
function rollOut(cellId){
  cellId.style.color="#0000ff"
}
function goto(destination){
  window.location.href = destination
}
function newWindow(url)
{
	myWindow = window.open(url,"myWin","width=800,height=630,status=no,scrollbars=yes");	
	myWindow.focus();
}
function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function highlight(cellId){
 cellId.style.background="#66FFCC";
 cellId.style.border="solid #ff6699";
}
function unhighlight(cellId){
  cellId.style.background="#FFFFFF";
	cellId.style.border="solid white";
}
function newWindow(url)
{
	myWindow = window.open(url,"myWin","width=800,height=630,status=no,scrollbars=yes");	
	myWindow.focus();
}
/******playing Sounds************/
function auPreload() {
if (!ver4) return;
 if (NS) auEmb = new Layer(0,window);
 else {
  Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
   document.body.insertAdjacentHTML("BeforeEnd",Str);
 }
 var Str = '';
 for (i=0;i<aySound.length;i++)
  Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
 if (IE) auEmb.innerHTML = Str;
 else {
  auEmb.document.open();
  auEmb.document.write(Str);
  auEmb.document.close();
 }
 auCon = IE? document.all.soundfiles:auEmb;
 auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
 if (IE) this.src = play? aySound[whSound]:'';
 else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }



var travel = "<a target='_blank' href='http://www.djsislandtravel.com/' ><img src='/images/djstravel.gif' width='120' height='145' alt='DJ\'s Island Travel Logo'  border='0'/></a>"

/**************Drag Object******************/

var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="drag"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}

dragobject.initialize()


//------banner Rotator-----//////////

var settings = {'force_size':1,'img_width':460,'img_height':125, 'refresh_time':6000,	'refresh_max':100,	'duplicate_banners':0, 'location_prefix':'adLocation-', 'location_class':'swb',	'window':'_self',	'default_ad_loc':		'default'}
var used=0;var location_counter=0;var refresh_counter=1;var map=new Array();function banner(a,b,c,d,e){this.name=a;this.url=b;this.image=c;this.date=d;this.active=1;this.oid=0;if(e!=''){this.loc=e}else{this.loc=settings.default_ad_loc}}function show_banners(a){location_counter=location_counter+1;if(a!=''&&a!=undefined){map[location_counter]=a}else{map[location_counter]=settings.default_ad_loc}var b='<div id="'+settings.location_prefix+location_counter+'" class="'+settings.location_class+'"></div>';document.write(b);display_banners(location_counter)}function display_banners(a){var b=new Array();if(a==''||!a||a<0){return}var c=banners.length;if((c==used)&&settings.duplicate_banners==0){return}for(i=0;i<(banners.length);i++){banners[i].oid=i;if((banners[i].loc==map[a])&&(banners[i].active==1)){b.push(banners[i])}}var d=Math.floor(Math.random()*b.length);var e=b[d];var f=(settings.force_size==1)?' width="'+settings.img_width+'" height="'+settings.img_height+'"':'';var g='<a target="_blank" href="'+e.url+'" title="'+e.name+'" target="'+settings.window+'"><img border="0" src="'+e.image+'"'+f+' alt="'+e.name+'" /></a>';var h=new Date();var j=e.date;j=j.split('/',3);var k=new Date();k.setFullYear(parseInt(j[2]),parseInt(j[1])-1,parseInt(j[0]));if((h<k)&&e.active==1){var l=document.getElementById(settings.location_prefix+a);if(l==null){alert('spyka Webmaster banner rotator\nError: adLocation doesn\'t exist!')}else{l.innerHTML=g;if(settings.duplicate_banners==0){banners[e.oid].active=0;used++}return}}else{display_banners(a)}return}function refresh_banners(){if((refresh_counter==settings.refresh_max)||settings.refresh_time<1){clearInterval(banner_refresh)}used=0;for(j=0;j<(banners.length);j++){banners[j].active=1}for(j=1;j<(location_counter+1);j++){display_banners(j)}refresh_counter++}var banner_refresh=window.setInterval(refresh_banners,settings.refresh_time);

var banners = [
	new banner('Exotic Lifestyle Caribean Cruise',			'https://secureregistrationonline.com/freedom_nov_2012/decks.php?affiliateId=1626', 			'/images/cruise2012.jpg', 	'01/11/2012',	'header'),
	new banner('HedonismFest',			'http://www.djsislandtravel.com/?page_id=lvfest', 			'/images/lovevoodoofest.jpg', 	'07/11/2010',	'header')
]
/////////////////////////

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
function banner(alt,url,image){
 this.alt=alt;
 this.url=url;
 this.image=image;
}

function slideShow(speed) {
	$('ul.slideshow li').css({opacity: 0.0});
	$('ul.slideshow li:first').css({opacity: 1.0});
	var timer = setInterval('gallery()',speed);
	
	$('ul.slideshow').hover(
		function () {
			clearInterval(timer);	
		}, 	
		function () {
			timer = setInterval('gallery()',speed);			
		}
	);
	
}

function gallery() {
	var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));
	var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000).removeClass('show');

}

$(document).ready(function() {
     slideShow(5000);
});
