function myInit() {
	
	//$("a[href^='http:']").not("[href*='domain.com']").attr('target','_blank');	
	
	$('#navigation li.shop a').attr('href','https://www.thegrandsocial.com.au/handsom').attr('target','_blank');	
	$('#footer a').attr('target','_blank');	
	
	setTimeout(function(){ $("h1#collectionTitle").fadeOut('slow') }, 4000);
	
	$('#archive > li > a').click( function() {		
		$(this).parent().find("ul:first").toggleClass("closed"); 
		return false;
		});
	$('#archive > li > ul > li > a').click( function() {		
		$(this).parent().find("ul:first").toggleClass("closed"); 
		return false;
		});
	
	$("#commentForm").submit(function() {		
		$('#commentForm').attr('method','post');
		errors = '';	
		if (!$('#cf_comment').val()) {
			errors += "Comment\n";
			}
		if (!$('#cf_name').val()) {
			errors += "Name\n";
			}
		if (!$('#cf_email').val()) {
			errors += "Email\n";
			}
		if (errors) {			
			alert("The following fields are required:\n\n"+errors);
			return false;
			} 	
		});

	$("#mailinglistForm").submit(function() {				
		errors = '';	
		if (!$('#ml_name').val()) {
			errors += "Name\n";
			}
		if (!$('#ml_email').val()) {
			errors += "Email\n";
			}
		if (errors) {			
			alert("The following fields are required:\n\n"+errors);
			return false;
			} 	
		else {
			$.ajax({
				type: "POST",
				url: "/ml.php",
				data: "ml_name="+$('#ml_name').val()+"&ml_email="+$('#ml_email').val(),
				success: function(returned){
					$('#ml_name').val('')
					$('#ml_email').val('')
					alert("Thank you for signing up");									
					}
				});			
			}	
			return false;
		});
	
	$('#left').click( function() {
		galleryScrollLeft();
		return false;
		});
	
	$('#right').click( function() {
		galleryScrollRight();
		return false;
		});
	
	$('#scroller img').click( function() {
		$('#mainImage img').fadeTo(200, 0.7);
		imageId = this.id;
		imageId = imageId.replace('thumb_','');
		loadImage(imageId);		
		return false;
		});
	$('#mainImage img').click( function() {		
		imageId = this.id;
		if (!imageId){
			return false;
			}		
		$('#mainImage img').fadeTo(200, 0.7);
		imageId = imageId.replace('image_','');
		loadImage(imageId);		
		return false;
		});
	$('#scroller img,.scroller img').hover(
		function () {
			$(this).fadeTo(100, 0.8);			
			}, 
		function () {
			$(this).fadeTo(100, 1);
			}
		);/*
	$('#mainImage img:not(.selected)').hover(
		function () {
			$(this).fadeTo(100, 1);			
			}, 
		function () {
			$(this).fadeTo(100, 0.8);
			}
		);*/
	
	
	$('#mainImage').disableSelection(); 
	$('#scroller').disableSelection(); 
	
	$('#carouselWrapper').hover(
		function () {
			$('#carouselWrapper').fadeTo(200, 1);			
			}, 
		function () {
			$('#carouselWrapper').fadeTo(200, 0);
			}
		);
	
	
	$('div.man .left').click( function() {
		MgalleryScrollLeft();
		return false;
		});	
	$('div.man .right').click( function() {
		MgalleryScrollRight();
		return false;
		});	
	$('div.man .scroller img').click( function() {
		$('div.man .mainImage img').fadeTo(200, 0.7);
		imageId = this.id;
		imageId = imageId.replace('thumb_','');
		MloadImage(imageId);		
		return false;
		});	
	$('div.man .mainImage').disableSelection(); 
	$('div.man .scroller').disableSelection(); 	
	$('div.man .carouselWrapper').hover(
		function () {
			$('div.man .carouselWrapper').fadeTo(200, 1);			
			}, 
		function () {
			$('div.man .carouselWrapper').fadeTo(200, 0);
			}
		);

	$('div.woman .left').click( function() {
		WgalleryScrollLeft();
		return false;
		});	
	$('div.woman .right').click( function() {
		WgalleryScrollRight();
		return false;
		});	
	$('div.woman .scroller img').click( function() {
		$('div.woman .mainImage img').fadeTo(200, 0.7);
		imageId = this.id;
		imageId = imageId.replace('thumb_','');
		WloadImage(imageId);		
		return false;
		});	
	$('div.woman .mainImage').disableSelection(); 
	$('div.woman .scroller').disableSelection(); 	
	$('div.woman .carouselWrapper').hover(
		function () {
			$('div.woman .carouselWrapper').fadeTo(200, 1);			
			}, 
		function () {
			$('div.woman .carouselWrapper').fadeTo(200, 0);
			}
		);
	
	$('.mainImage img').hover(
		function () {
			$(this).fadeTo(100, 0.8);			
			}, 
		function () {
			$(this).fadeTo(100, 1);
			}
		);
	

	}
	
function loadImage(imageId) {	
	if (!imageId) {
		return;
		}
	coords = $('#image_'+imageId).position();
	dest =  '#image_'+imageId;	
	$('#mainImage img').removeClass('selected');
	$('#mainImage').scrollTo( dest, 500, {axis:'x',offset:{left:-244, top:0 },onAfter:function(){  } } );
	$(dest).fadeTo(500, 1).addClass('selected');
	
	}
	

	

function galleryScrollLeft() {		
	if (scrollToInt > 0) {
		scrollToInt = parseInt(scrollToInt) - parseInt(scrollIncrement);
		scrollThumbnails(scrollToInt);
		}
	}
function galleryScrollRight() {	
	if (scrollToInt < (maxWidth-paneWidth)) {
		scrollToInt = parseInt(scrollToInt) + parseInt(scrollIncrement);
		scrollThumbnails(scrollToInt);
		} 
	}	
function scrollThumbnails(scrollPixel) {		
	if (scrollPixel < 0) {
		scrollPixel = 0;
		}		
	$('#carousel').scrollTo(  scrollPixel, { axis:'x', duration:500 } );	
	scrollToInt = parseInt(scrollPixel);	
	if (scrollPixel >= (maxWidth-paneWidth)) {
		$('#right').addClass('disabled');
		$('#right').fadeTo(200,0);
		}
	if (scrollPixel > 0) {
		//$('#scrollUp').fadeIn('normal');
		$('#left').removeClass('disabled');
		$('#left').fadeTo(200,1);
		}
	if (scrollPixel < (maxWidth-paneWidth)) {
		//$('#scrollDown').fadeIn('normal');
		$('#right').removeClass('disabled');
		$('#right').fadeTo(200,1);
		}
	if (scrollPixel == 0) {
		//$('#scrollUp').fadeOut('normal');
		$('#left').addClass('disabled');
		$('#left').fadeTo(200,0);
		}
	}









function MgalleryScrollLeft() {		
	if (MscrollToInt > 0) {
		MscrollToInt = parseInt(MscrollToInt) - parseInt(MscrollIncrement);
		MscrollThumbnails(MscrollToInt);
		}
	}
function MgalleryScrollRight() {	
	if (MscrollToInt < (MmaxWidth-MpaneWidth)) {
		MscrollToInt = parseInt(MscrollToInt) + parseInt(MscrollIncrement);
		MscrollThumbnails(MscrollToInt);
		} 
	}	
function MscrollThumbnails(MscrollPixel) {		
	if (MscrollPixel < 0) {
		MscrollPixel = 0;
		}		
	$('div.man .carousel').scrollTo(  MscrollPixel, { axis:'x', duration:500 } );	
	MscrollToInt = parseInt(MscrollPixel);	
	if (MscrollPixel >= (MmaxWidth-MpaneWidth)) {
		$('div.man .right').addClass('disabled');
		$('div.man .right').fadeTo(200,0);
		}
	if (MscrollPixel > 0) {
		$('div.man .left').removeClass('disabled');
		$('div.man .left').fadeTo(200,1);
		}
	if (MscrollPixel < (MmaxWidth-MpaneWidth)) {
		$('div.man .right').removeClass('disabled');
		$('div.man .right').fadeTo(200,1);
		}
	if (MscrollPixel == 0) {
		$('div.man .left').addClass('disabled');
		$('div.man .left').fadeTo(200,0);
		}
	}
function MloadImage(imageId) {	
	if (!imageId) {
		return;
		}
	coords = $('#image_'+imageId).position();
	dest =  '#image_'+imageId;	
	$('div.man .mainImage').scrollTo( dest, 500, {axis:'x',offset:{left:0, top:0 },onAfter:function(){  } } );
	$(dest).fadeTo(500, 1)
	}
	
	
	
	

function WgalleryScrollLeft() {		
	if (WscrollToInt > 0) {
		WscrollToInt = parseInt(WscrollToInt) - parseInt(WscrollIncrement);
		WscrollThumbnails(WscrollToInt);
		}
	}
function WgalleryScrollRight() {	
	if (WscrollToInt < (WmaxWidth-WpaneWidth)) {
		WscrollToInt = parseInt(WscrollToInt) + parseInt(WscrollIncrement);
		WscrollThumbnails(WscrollToInt);
		} 
	}	
function WscrollThumbnails(WscrollPixel) {		
	if (WscrollPixel < 0) {
		WscrollPixel = 0;
		}		
	$('div.woman .carousel').scrollTo(  WscrollPixel, { axis:'x', duration:500 } );	
	WscrollToInt = parseInt(WscrollPixel);	
	if (WscrollPixel >= (WmaxWidth-WpaneWidth)) {
		$('div.woman .right').addClass('disabled');
		$('div.woman .left').fadeTo(200,0);
		}
	if (WscrollPixel > 0) {
		$('div.woman .left').removeClass('disabled');
		$('div.woman .left').fadeTo(200,1);
		}
	if (WscrollPixel < (WmaxWidth-WpaneWidth)) {
		$('div.woman .right').removeClass('disabled');
		$('div.woman .left').fadeTo(200,1);
		}
	if (WscrollPixel == 0) {
		$('div.woman .left').addClass('disabled');
		$('div.woman .left').fadeTo(200,0);
		}
	}
function WloadImage(imageId) {	
	if (!imageId) {
		return;
		}
	coords = $('#image_'+imageId).position();
	dest =  '#image_'+imageId;	
	$('div.woman .mainImage').scrollTo( dest, 500, {axis:'x',offset:{left:0, top:0 },onAfter:function(){  } } );
	$(dest).fadeTo(500, 1)
	}
	
		
	
	
	
	
	
function goback() {
	history.back();
	}


jQuery.fn.extend({ 
        disableSelection : function() { 
                return this.each(function() { 
                        this.onselectstart = function() { return false; }; 
                        this.unselectable = "on"; 
                        jQuery(this).css('user-select', 'none'); 
                        jQuery(this).css('-o-user-select', 'none'); 
                        jQuery(this).css('-moz-user-select', 'none'); 
                        jQuery(this).css('-khtml-user-select', 'none'); 
                        jQuery(this).css('-webkit-user-select', 'none'); 
                }); 
        } 
}); 
