
/*--------------------------------Disable Image Right Click----------------------*/



		
	var isNS = (navigator.appName == "Netscape") ? 1 : 0;
	
	if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
	
	function mischandler(){
	  return false;
	}
	
	function mousehandler(e){
		var myevent = (isNS) ? e : event;
		var eventbutton = (isNS) ? myevent.which : myevent.button;
	   if((eventbutton==2)||(eventbutton==3)) return false;
	}
	
	//image = document.getTagById("img");
	
	//document.image.oncontextmenu = mischandler;
	//document.image.onmousedown = mousehandler;
	//document.image.onmouseup = mousehandler;


	
	//document.getTagById("img").oncontextmenu = return false;

	
	
	
		document.images.oncontextmenu = mischandler;
		document.images.onmousedown = mousehandler;
		document.images.onmouseup = mousehandler;

		

	
	
	
	/*
	document.oncontextmenu = mischandler;
	document.onmousedown = mousehandler;
	document.onmouseup = mousehandler;
	*/
	







/*--------------------------------Cookies----------------------*/



	 function goto_setcookie( name, value, expires, path, domain, secure ) 
	  {
		var today = new Date();
		today.setTime( today.getTime() );
		
	
		if ( expires )
		{
			expires = expires * 1000 * 60 * 60;
		}
		
		var expires_date = new Date( today.getTime() + (expires) );
		
		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	  }



/*--------------------------------Slideshow----------------------*/


	function startGallery() 
	{
		myGallery = new gallery($('myGallery'), {
		timed: true,
		//delay: 1000, //enable to speed up
		showArrows: true,
		showCarousel: false,
		showArrows: false,
		embedLinks: false,
		showInfopane: false
		
		});
	
	}
	
		var	 domain = "http://www.martinphillipsweddings.com/";
		var gal_path = "imgages/gallery/";
		var thumb_path = "images/gallery/thumbs/";
		
		var img_playpause = document.getElementById("playpause");
		
		//var img_playpause_src_o = img_playpause.src;
		//var img_playpause_src = img_playpause_src_o.replace("http://www.martinphillipsweddings.com/", "");
		
		var img_play_up = domain + "images/control-play-up.jpg";
		var img_pause_up = domain + "images/control-pause-up.jpg";
		var img_play_over = domain + "images/control-play-over.jpg";
		var img_pause_over = domain + "images/control-pause-over.jpg";
		
		
	
	
	
	/*Test*/
	function hidegal ()
	{
		document.getElementById("myGallery").style.display = "none";
		document.getElementById("myGallery").style.zIndex = -99;
		document.getElementById("content_gallery").style.display = "block";
		myGallery.goTo(0);
		myGallery.clearTimer();	
		
	}
		
	function showgal ()
	{
		document.getElementById("myGallery").style.display = "block";
		document.getElementById("content_gallery").style.display = "none";
		document.getElementById("content_gallery").style.zIndex = -99
		
		myGallery.clearTimer();	
	}	
	
	
	
	
	/*Test*/
	function hideimg ()
	{
		document.getElementById("myGallery").style.display = "none";
		document.getElementById("content_gallery").style.display = "block";
		
		myGallery.clearTimer();	
		
	}
		
	function showimg (img)
	{
		document.getElementById("myGallery").style.display = "block";
		document.getElementById("content_gallery").style.display = "none";
		document.getElementById("content_gallery").style.zIndex = -99;
		
		myGallery.goTo(img); //Test
		myGallery.clearTimer();
	}	
	
	
	
	
	
	
	function playpause_click()
	{
		
		if(img_playpause.src == img_pause_over)
		{
			img_playpause.src = img_play_up;
			//alert(img_playpause.src);
			myGallery.clearTimer();	
		}
		else if(img_playpause.src == img_play_over)
		{
			img_playpause.src = img_pause_up;	
			//alert(img_playpause.src);
			myGallery.prepareTimer();
		}
	}
	
	
		
	function playpause_over()
	{
		if(img_playpause.src == img_pause_up)
		{
			img_playpause.src = img_pause_over;
		}
		else if (img_playpause.src == img_play_up)
		{
			img_playpause.src = img_play_over;
		}
		
	}
	
	function playpause_out()
	{
		
		if(img_playpause.src == img_pause_over)
		{
			img_playpause.src = img_pause_up;
		}
		else if (img_playpause.src == img_play_over)
		{
			img_playpause.src = img_play_up;
		}
		
		
	}
	
	
	
	
	
	
	
	function prev_click()
	{
		//alert(window.img_playpause_src);
		myGallery.prevItem();
		myGallery.clearTimer();	
	}
	
	
	function next_click()
	{
		myGallery.nextItem();
		myGallery.clearTimer();
	}
	

	
	
	
	function control_over(img)
	{
		document.getElementById(img).src = "images/control-" + img + "-over.jpg";
	}
	
	function control_out(img)
	{
		document.getElementById(img).src = "images/control-" + img + "-up.jpg";
	}
	
	
	
	
	
	
	
	
	
	
	
	
	/*-----------------------Gallery Cookie Parsing-----------------------*/
				
	
					
					
		
	function goto_getcookie( check_name ) {
		var a_all_cookies = document.cookie.split( ';' );
		var a_temp_cookie = '';
		var cookie_name = '';
		var cookie_value = '';
		var b_cookie_found = false;
		
		for ( i = 0; i < a_all_cookies.length; i++ )
		{
			a_temp_cookie = a_all_cookies[i].split( '=' );
			
			cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		
			if ( cookie_name == check_name )
			{
				b_cookie_found = true;
				if ( a_temp_cookie.length > 1 )
				{
					cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
				}
				return cookie_value;
				break;
			}
			a_temp_cookie = null;
			cookie_name = '';
		}
		if ( !b_cookie_found )
		{
			return null;
		}
	}				
	


					function goto_getcookie( name ) {
	
					var start = document.cookie.indexOf( name + "=" );
					var len = start + name.length + 1;
					if ( ( !start ) &&
					( name != document.cookie.substring( 0, name.length ) ) )
					{
					return null;
					}
					if ( start == -1 ) return null;
					var end = document.cookie.indexOf( ";", len );
					if ( end == -1 ) end = document.cookie.length;
					return unescape( document.cookie.substring( len, end ) );
					}							
					
					
					
					function goto_delcookie( name, path, domain ) {
						
					if ( goto_getcookie( name ) ) document.cookie = name + "=" +
					( ( path ) ? ";path=" + path : "") +
					( ( domain ) ? ";domain=" + domain : "" ) +
					";expires=Thu, 01-Jan-1970 00:00:01 GMT";
					}
										
					
					
					/*Check cookie action*/
					/*
					if ( goto_getcookie( 'goto' )  )
					{
						//alert( goto_getcookie('goto'));
						myGallery.goTo('goto');
						//myGallery.clearTimer();
					}
					*/
					
					/*
					goto_delcookie('goto', '/', '');
					( goto_getcookie( 'goto' ) ) ? alert( goto_getcookie('goto')) : 
					alert( 'it is gone');
					*/

	
	
	
	
	
	

	function galleryimg()
	{
		document.getElementById("myGallery").style.display = "none";
		myGallery.clearTimer();	
		
		//myGallery.goTo(1); //Skip Blank on Start
		
		
		
		//alert( goto_getcookie('goto'));
		
		//myGallery.goTo(4); //Working
		
		/*
		if ( goto_getcookie( 'goto' ) ) 
		{
			
			myGallery.clearTimer();
			
			
			alert( goto_getcookie('goto'));
			
			
			img_no_string = goto_getcookie('goto');
			img_no = +img_no_string; //convert to number
			
			//delete cookie
			goto_delcookie('goto', '/', '');
			( goto_getcookie( 'goto' ) );
			
			
			
			myGallery.goTo(img_no);
			
			
		
		
		}
		else
		{
			alert("no cookie");
			//myGallery.prepareTimer();
			
		}
		*/
		
	}
	
	
	
	
	//window.onDomReady(startGallery);
	
	window.addEvent('domready', startGallery);
	
	
	
	
	
	
					
	