var creditTimer;
var slideTimer;


$(document).ready(function(){
	bindCredits();
	$('#gallery img').click(function(){
		getPics(this);
	});

});

	function gotoPage(inclass,inThis){
			$('#menu a').removeClass('selected');
			$(inThis).addClass('selected');
			document.title=$(inThis).text()+' - Lynne Dallas Flower Design';
		$('.wrap').stop().scrollTo('.'+inclass,700);
	}
	

function submitForm(){
	$('#formtarget').prepend('<div id="progress">Sending...</div>');
	var comlist = new Object();
	comlist['name']=$('#name').val();
	comlist['email']=$('#email').val();
	comlist['telephone']=$('#telephone').val();
	comlist['comment']=$('#comment').val();
	comlist['howdidyouhear']=$('#howdidyouhear').val();
	
	$('#formtarget').load('../sections/_contactmail.php',comlist);
	return false;
}


function startSlide(){
	oneSlide();
	
}

function oneSlide(){
	morePics("weddingspanel","wedding");
	clearTimeout(slideTimer);
	slideTimer=setTimeout('oneSlide()',5000);
}



function bindCredits(){
	$('img').mouseover(function(){
		clearTimeout(creditTimer);
		$('.credits').remove();
		title=$(this).attr('title');
		if(title.length>2){
			$(this).before('<div class="credits">'+decodeCredit(title)+'</div>');
			$('.credits').mouseover(function(){
				clearTimeout(creditTimer);
			});					
		}

	});
	
	$('img').mouseout(function(){
		creditTimer=setTimeout('hideCredits()',100);
	});  
}

	function hideCredits(){
		$('.credits').remove();
	}

	function slideBackground(inLeft,inDown){
		offset=(inLeft-600)+'px '+(inDown-600)+'px';
		$('#debug').text(offset);
		$('body').animate({backgroundPosition:offset},1000);
	}



var leftOff=500;

var bgleft=0;

function decodeCredit(inCredit){
	retVal='';
	cc=inCredit.split('|');
	retVal='<a target="_blank" href="http://'+cc[1]+'">'+cc[0]+'</a>';
	return retVal;	
}

function movePanel(inClass,offset){
	leftOff=leftOff+offset;
	$(inClass).css({marginLeft:leftOff});
	
}

function backgroundPos(xoff){
	bgleft=bgleft+xoff;
	bgpos=bgleft+'px 0px';
	$('body').css({backgroundPosition:bgpos});
}


function morePics(inDiv,inDir){
	$('#'+inDiv).prepend('<div style="position:absolute;background:#f0f0f0;color:black;padding:3px;border:1px solid #e0e0e0;">Loading...</div>');
	$('#'+inDiv).fadeTo('fast',0.8);
	var comlist = new Object();
	comlist['indir']=inDir;
	$('#picload').load('../sections/_morepics.php',comlist,function(){
		$('#'+inDiv).html($('#picload').html());
		$('#'+inDiv).fadeTo('fast',1,function(){bindCredits()});
	});
}

function getPics(inThis){
	
	f1=getFileName($(inThis).prev().attr('src'));
	f2=getFileName($(inThis).attr('src'));
	f3=getFileName($(inThis).next().attr('src'));
	alert(f1+' '+f2+' '+f3);
	comlist = new Object();
	comlist['image1']=f1;
	comlist['image2']=f2;
	comlist['image3']=f3;
	
	$('#weddingspanel').load('../sections/galleryview.php',comlist);
}

function getFileName(inPath){
	alert(inPath);
	if(inPath!=undefined){
		dd=inPath.split('/');
		return dd[dd.length-1];		
	}else{
		return '';
	}

}




