/*
 * jQuery Easing v1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php
 *
 * Uses the built in easing capabilities added in jQuery 1.1
 * to offer multiple easing options
 *
 * Copyright (c) 2007 George Smith
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
jQuery.easing={easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var a=t-d/2;return-2*c*a*a/(d*d)+2*c*a/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}if(t<d/2)return a*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return a*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-jQuery.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return jQuery.easing['bouncein'](x,t*2,0,c,d)*.5+b;return jQuery.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}};

// Plugin: heartbeat.
(function($) {
	$.fn.heartBeat = function(options){
		// Heart beat plugin
		//
		// build main options before element iteration
		var opts = $.extend({}, $.fn.heartBeat.defaults, options);
		
		// Apply the modification on each item in the selector.
		return this.each(function() {
			var $this = $(this);
			// build element specific options
			var o = opts;
			
		 if (!o.alwaysBeat){
			$this.bind("mouseover", function(){
					// set the interval
					// TODO
				})
				.bind("mouseout", function(){
					// clear the interval
					// TODO
				});
		 }
		 else {
			 var myThis = $(this);
			 $.fn.heartBeat.start($(this), o);
			 var intervalFct = function(){ $.fn.heartBeat.start(myThis, o); }; // Fix for setInterval bug between browser
			 var intervalId = setInterval(intervalFct, o.delayBetweenAnimation + o.delay * 2);
			 $(this).attr("intervalId", intervalId); 
		 }
			
		});
	};
	
	$.fn.heartBeat.start = function(thisItem, options) {
		var opts = $.extend({}, $.fn.heartBeat.defaults, options);

		if (thisItem.css("opacity") == opts.opacityMax){
			thisItem.fadeTo(opts.delay, opts.opacityMin, function(){ thisItem.fadeTo(opts.delay, opts.opacityMax); });
		}
	};
	
	$.fn.heartBeat.stopHeartBeat = function(options){
		// Stop the heart beat.
		return this.each(function() {
			var intervalId = $(this).attr("intervalId");
			clearInterval(intervalId);
			$(this).attr("intervalId", 0);
		});
	}

	$.fn.heartBeat.defaults = {
		opacityMax: "1",
		opacityMin: "0.5",
		delay:"75", // in ms
		delayBetweenAnimation: 1000,
		alwaysBeat: true
	};
	
 })(jQuery);

/**-------------------------------------------------------------------------------
 * LavaLamp - A menu plugin for jQuery with cool hover effects.
 * @requires jQuery v1.1.3.1 or above
 *
 * http://gmarwaha.com/blog/?p=7
----------------------------------------------------------------------------------*/

(function($) {
$.fn.lavaLamp = function(o) {
    o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {});

    return this.each(function() {
        var me = $(this), noop = function(){},
            $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
            $li = $("li", this), curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0];

        $li.not(".back").hover(function() {
            move(this);
        }, noop);

        $(this).hover(noop, function() {
            move(curr);
        });

        $li.click(function(e) {
            setCurr(this);
            return o.click.apply(this, [e, this]);
        });

        setCurr(curr);

        function setCurr(el) {
            $back.css({ "left": el.offsetLeft+"px", "width": "0px" });
            curr = el;
        };

        function move(el) {
            $back.each(function() {
                $(this).dequeue(); }
            ).animate({
                width: el.offsetWidth,
                left: el.offsetLeft
            }, o.speed, o.fx);
        };

    });
};
})(jQuery);


/*---------------------------------------------------------------------------

             Tool Tick 

-----------------------------------------------------------------------------*/

/*
 * JTip
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * JTip is built on top of the very light weight jquery library.
 */

//on page load (as soon as its ready) call JT_init
$(document).ready(JT_init);

function JT_init(){
	       $("a.jTip")
		   .hover(function(){JT_show(this.href,this.id,this.name)},function(){$('#JT').remove()})
           .click(function(){return false});	   
}

function JT_show(url,linkId,title){
	if(title == false)title="&nbsp;";
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(linkId);
	var clickElementy = getAbsoluteTop(linkId) - 3; //set y position
	
	var queryString = url.replace(/^[^\?]+\??/,'');
	var params = parseQuery( queryString );
	if(params['width'] === undefined){params['width'] = 250};
	if(params['link'] !== undefined){
	$('#' + linkId).bind('click',function(){window.location = params['link']});
	$('#' + linkId).css('cursor','pointer');
	}
	
	if(hasArea>((params['width']*1)+75)){
		$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_left'></div><div id='JT_close_left'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//right side
		var arrowOffset = getElementWidth(linkId) + 11;
		var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
	}else{
		$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_right' style='left:"+((params['width']*1)+1)+"px'></div><div id='JT_close_right'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//left side
		var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position
	}
	
	$('#JT').css({left: clickElementx+"px", top: clickElementy+"px"});
	$('#JT').show();
	$('#JT_copy').load(url);

}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
}

function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function blockEvents(evt) {
              if(evt.target){
              evt.preventDefault();
              }else{
              evt.returnValue = false;
              }
}




//---------------------------------------------------------------------------------
//             Auto Image Scrolling, With Fade effect 
//
//---------------------------------------------------------------------------------

//** DD Drop Down Panel- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Dec 7th, 08'- Script created (Requires jquery 1.2.x)

var simpleGallery_navpanel={
	panel: {height:'45px', opacity:0.5, paddingTop:'5px', fontStyle:'bold 11px Verdana'}, //customize nav panel container
	images: [ 'left.gif', 'play.gif', 'right.gif', 'pause.gif'], //nav panel images (in that order)
	imageSpacing: {offsetTop:[-4, 0, -4], spacing:10}, //top offset of left, play, and right images, PLUS spacing between the 3 images
	slideduration: 500 //duration of slide up animation to reveal panel
}

var simpleGallery_messagepanel={
	panel: {height:'40px', opacity:0.5, paddingTop:'5px', fontStyle:'bold 11px Verdana'}, //customize nav panel container
	slideduration: 500 //duration of slide up animation to reveal panel
}

function simpleGallery(settingarg){
	this.setting=settingarg
	settingarg=null
	var setting=this.setting
	
	/*
	if(setting.imagearray==1){
	    setting.imagearray = [
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/1.jpg", "http://rupalionline.co.uk/virtualcatalog/vol24/", "","Explore the essence of a woman in you with our designer sarees"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/2.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=01","","Make the latest fashion statement with our chudidar collection"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/3.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=02","","Latest fashion kurties in rich fabrics"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/4.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=06&ScCode=06002","","Be on the style charts with our Kaftans"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/5.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=07","","Uplift your spirits with our latest Kids Wear"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/6.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=01&ScCode=01005","","Be-dazzle yourself with the latest Jewellery Collection"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/7.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=03","","Shop now for lastest in Footwear"]
	    ]
	*/
	
	
	if(setting.imagearray==1){
	    setting.imagearray = [
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/1.jpg", "http://rupalionline.co.uk/virtualcatalog/vol24/", "","Explore the essence of a woman in you with our designer sarees"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/2.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=01","","Make the latest fashion statement with our chudidar collection"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/3.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=02","","Latest fashion kurties in rich fabrics"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/4.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=06&ScCode=06002","","Be on the style charts with our Kaftans"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/5.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=07","","Uplift your spirits with our latest Kids Wear"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/6.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=01&ScCode=01005","","Be-dazzle yourself with the latest Jewellery Collection"],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/Header/7.jpg", "http://www.rupalionline.com/Index.aspx?Pos=C&CCode=03","","Shop now for lastest in Footwear"]
	    ]


    }

	if(setting.imagearray==2){
	    setting.imagearray = [
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerOne/1.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=03&ScCode=03001", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerOne/2.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=03&ScCode=03014", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerOne/3.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=03&ScCode=03002", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerOne/4.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=03&ScCode=03002", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerOne/5.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=03&ScCode=03004", "",""]
	    ]
    }

	if(setting.imagearray==3){
	    setting.imagearray = [
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerTwo/1.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=08&ScCode=08001", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerTwo/2.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=08&ScCode=08001", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerTwo/3.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=08&ScCode=08001", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerTwo/4.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=08&ScCode=08001", "",""],
		    ["http://www.rupalionline.co.uk/RupaliUkProductImages/HomePage/BannerTwo/5.jpg", "http://www.rupalionline.com/Index.aspx?Pos=SC&CCode=08&ScCode=08001", "",""]
	    ]
    }
    	
    
	setting.pause=parseInt(setting.pause)
	setting.fadeduration=parseInt(setting.fadeduration)
	setting.curimage=(setting.persist)? simpleGallery.routines.getCookie("gallery-"+setting.wrapperid) : 0
	setting.curimage=setting.curimage || 0 //account for curimage being null if cookie is empty
	setting.ispaused=!setting.autoplay //ispaused reflects current state of gallery, autoplay indicates whether gallery is set to auto play
	setting.fglayer=0, setting.bglayer=1 //index of active and background layer (switches after each change of slide)
	setting.oninit=setting.oninit || function(){}
	setting.onslide=setting.onslide || function(){}
	setting.showmessage=setting.showmessage || false //To Show Popup Message
	setting.shownavigpanel=setting.shownavigpanel || false //To Show Play, Prev, Next buttons
	var preloadimages=[] //temp array to preload images
	for (var i=0; i<setting.imagearray.length; i++){
		preloadimages[i]=new Image()
		preloadimages[i].src=setting.imagearray[i][0]
	}
	var slideshow=this
	jQuery(document).ready(function($){
		var setting=slideshow.setting
		setting.$wrapperdiv=$('#'+setting.wrapperid).css({position:'relative', visibility:'visible', background:'black', overflow:'hidden', width:setting.dimensions[0], height:setting.dimensions[1]}).empty() //main gallery DIV
		if (setting.$wrapperdiv.length==0){ //if no wrapper DIV found
			//alert("Error: DIV with ID \""+setting.wrapperid+"\" not found on page.")
			return false
		}
		setting.$gallerylayers=$('<div class="gallerylayer"></div><div class="gallerylayer"></div>') //two stacked DIVs to display the actual slide 
			.css({position:'absolute', left:0, top:0})
			.appendTo(setting.$wrapperdiv)
		setting.gallerylayers=setting.$gallerylayers.get() //cache stacked DIVs as DOM objects
		setting.navbuttons= simpleGallery.routines.addnavpanel(setting) //get 4 nav buttons DIVs as DOM objects
		setting.gallerymessage= simpleGallery.routines.addmessagepanel(setting) //Declare Message Panel
		$(setting.navbuttons).filter('img.navimages').css({opacity:0.8})
			.bind('mouseover mouseout', function(e){
				$(this).css({opacity:(e.type=="mouseover")? 1 : 0.8})
			})
			.bind('click', function(e){
				var keyword=e.target.title.toLowerCase()
				slideshow.navigate(keyword) //assign behavior to nav images
			})
		setting.$wrapperdiv.bind('mouseenter', function(){slideshow.showhidenavpanel('show')})
		setting.$wrapperdiv.bind('mouseleave', function(){slideshow.showhidenavpanel('hide')})
		slideshow.showslide(setting.curimage) //show initial slide
		setting.oninit() //trigger oninit() event
		$(window).bind('unload', function(){ //clean up and persist
			$(slideshow.setting.navbuttons).unbind()
			if (slideshow.setting.persist) //remember last shown image's index
				simpleGallery.routines.setCookie("gallery-"+setting.wrapperid, setting.curimage)
			jQuery.each(slideshow.setting, function(k){
				if (slideshow.setting[k] instanceof Array){
					for (var i=0; i<slideshow.setting[k].length; i++){
						if (slideshow.setting[k][i].tagName=="DIV")
							slideshow.setting[k][i].innerHTML=null
						slideshow.setting[k][i]=null
					}
				}
				slideshow.setting[k]=null
			})
			slideshow=slideshow.setting=null
		})
	})
}

simpleGallery.prototype={

	navigate:function(keyword){
		clearTimeout(this.setting.playtimer)
		if (!isNaN(parseInt(keyword))){
			this.showslide(parseInt(keyword))
		}
		else if (/(prev)|(next)/i.test(keyword)){
			this.showslide(keyword.toLowerCase())
		}
		else{ //if play|pause button
			var slideshow=this
			var $playbutton=$(this.setting.navbuttons).eq(1)
			if (!this.setting.ispaused){ //if pause Gallery
				this.setting.autoplay=false
				//$playbutton.attr({title:'Play', src:simpleGallery_navpanel.images[1]})
			}
			else if (this.setting.ispaused){ //if play Gallery
				this.setting.autoplay=true
				this.setting.playtimer=setTimeout(function(){slideshow.showslide('next')}, this.setting.pause)
				//$playbutton.attr({title:'Pause', src:simpleGallery_navpanel.images[3]})
			}
			slideshow.setting.ispaused=!slideshow.setting.ispaused
		}
	},

	showslide:function(keyword){
		var slideshow=this
		var setting=slideshow.setting
		var totalimages=setting.imagearray.length
		var imgindex=(keyword=="next")? (setting.curimage<totalimages-1? setting.curimage+1 : 0)
			: (keyword=="prev")? (setting.curimage>0? setting.curimage-1 : totalimages-1)
			: Math.min(keyword, totalimages-1)
			
        if (setting.showmessage){	
		    slideshow.showhidemessagepanel('hide','')
        }               
			
		setting.gallerylayers[setting.bglayer].innerHTML=simpleGallery.routines.getSlideHTML(setting.imagearray[imgindex])
		setting.$gallerylayers.eq(setting.bglayer).css({zIndex:1000, opacity:0}) //background layer becomes foreground
			.stop().css({opacity:0}).animate({opacity:1}, setting.fadeduration, function(){ //Callback function after fade animation is complete:
				clearTimeout(setting.playtimer)
				setting.gallerylayers[setting.bglayer].innerHTML=null  //empty bglayer (previously fglayer before setting.fglayer=setting.bglayer was set below)
				try{
					setting.onslide(setting.gallerylayers[setting.fglayer], setting.curimage)
				
				    if (setting.showmessage){	
					    slideshow.showhidemessagepanel('show',setting.imagearray[setting.curimage][3])
                    }               
				}catch(e){
					alert("Simple Controls Gallery: An error has occured somwhere in your code attached to the \"onslide\" event: "+e)
				}
				if (setting.autoplay){
					setting.playtimer=setTimeout(function(){slideshow.showslide('next')}, setting.pause)
				}
			})
		setting.gallerylayers[setting.fglayer].style.zIndex=999 //foreground layer becomes background
		setting.fglayer=setting.bglayer
		setting.bglayer=(setting.bglayer==0)? 1 : 0
		setting.curimage=imgindex
		setting.navbuttons[3].innerHTML=(setting.curimage+1) + '/' + setting.imagearray.length
	},

	showhidenavpanel:function(state){
		if (this.setting.shownavigpanel){	
    		var setting=this.setting
	    	var endpoint=(state=="show")? setting.dimensions[1]-parseInt(simpleGallery_navpanel.panel.height) : this.setting.dimensions[1]
		    setting.$navpanel.stop().animate({top:endpoint}, simpleGallery_navpanel.slideduration)
	    }
	},
	
	showhidemessagepanel:function(state,message){
		var setting=this.setting
    	var endpoint=(state=="show")? setting.dimensions[1]-parseInt(simpleGallery_messagepanel.panel.height) : this.setting.dimensions[1]
	    setting.$messagepanel.stop().animate({top:endpoint}, simpleGallery_messagepanel.slideduration)
			document.getElementById('gallerymessage' + setting.imagearray).innerHTML=message
	}

}

simpleGallery.routines={

	getSlideHTML:function(imgelement){
		var layerHTML=(imgelement[1])? '<a href="'+imgelement[1]+'" target="'+imgelement[2]+'">\n' : '' //hyperlink slide?
		layerHTML+='<img src="'+imgelement[0]+'" style="border-width:0" />'
		layerHTML+=(imgelement[1])? '</a>' : ''
		return layerHTML //return HTML for this layer
	},

	addnavpanel:function(setting){
	
		var interfaceHTML=''
		
		for (var i=0; i<3; i++){		
			var imgstyle='position:relative; border:0; cursor:hand; cursor:pointer; top:'+simpleGallery_navpanel.imageSpacing.offsetTop[i]+'px; margin-right:'+(i!=2? simpleGallery_navpanel.imageSpacing.spacing+'px' : 0)
			var title=(i==0? 'Prev' : (i==1)? (setting.ispaused? 'Play' : 'Pause') : 'Next')
			var imagesrc= '' //(i==1)? simpleGallery_navpanel.images[(setting.ispaused)? 1 : 3] : simpleGallery_navpanel.images[i]
			interfaceHTML+='<img class="navimages" title="' + title + '" src="'+ imagesrc +'" style="'+imgstyle+'" /> '			
		}
		
		interfaceHTML+='<div class="gallerystatus" style="margin-top:1px">' + (setting.curimage+1) + '/' + setting.imagearray.length + '</div>'
		setting.$navpanel=$('<div class="navpanellayer"></div>')
			.css({position:'absolute', width:'100%', height:simpleGallery_navpanel.panel.height, left:0, top:setting.dimensions[1], font:simpleGallery_navpanel.panel.fontStyle, zIndex:'1005'})
			.appendTo(setting.$wrapperdiv)
		$('<div class="navpanellayerbg"></div><div class="navpanellayerfg"></div>')
			.css({position:'absolute', left:0, top:0, width:'100%', height:'100%'})
			.eq(0).css({background:'black', opacity:simpleGallery_navpanel.panel.opacity}) //"navpanellayerbg" div
			.end().eq(1).css({paddingTop:simpleGallery_navpanel.panel.paddingTop, textAlign:'center', color:'white'}).html(interfaceHTML) //"navpanellayerfg" div
			.end().appendTo(setting.$navpanel)
			
		return setting.$navpanel.find('img.navimages, div.gallerystatus').get() ////return 4 nav buttons DIVs as DOM objects
	},

	addmessagepanel:function(setting){
		var interfaceHTML=''	
	
		interfaceHTML+='<div ID="gallerymessage' + setting.imagearray +'" class="gallerymessage" ></div>'
		setting.$messagepanel=$('<div class="msgpanellayer"></div>')
			.css({position:'absolute', width:'100%', height:simpleGallery_messagepanel.panel.height, left:0, top:setting.dimensions[1], font:simpleGallery_messagepanel.panel.fontStyle, zIndex:'1000'})
			.appendTo(setting.$wrapperdiv)
		$('<div class="msgpanellayerbg"></div><div class="msgpanellayerfg"></div>')
			.css({position:'absolute', left:0, top:0, width:'100%', height:'100%'})
			.eq(0).css({background:'black', opacity:simpleGallery_messagepanel.panel.opacity}) //"navpanellayerbg" div
			.end().eq(1).css({paddingTop:simpleGallery_messagepanel.panel.paddingTop, textAlign:'center', color:'white'}).html(interfaceHTML) //"navpanellayerfg" div
			.end().appendTo(setting.$messagepanel)
        return setting.$messagepanel.find('.myMessage').get()			
	},


	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its valueal
	    else
		    return false
	},

	setCookie:function(name, value){
		document.cookie = name+"=" + value + ";path=/"
	}
}