// JavaScript Document
var wineId,wineURLup,wineURLov,wineDESC,wineTitle,wineLink,arrayOfWine, allWineID, vinSRC

//main funtion that will call the right function 
function getWineDesc(position){
	arrayPosition= position;
	ovWine(arrayPosition);
}


//load the wine for the galerie
function startLoadingWine(position){
	arrayPosition= position;
	ovWine(arrayPosition);
}


//this function will call the upStat for the wine bottle

function upWine(who){
	jQuery("#vinSRC-"+who).attr('src', wineURLup );
	jQuery("#titleDesc").html(wineTitle);
	jQuery("#txtDesc").html(wineDESC);
	jQuery("#LinkToFiche").attr('href', wineLink );
	
}

//this function will call the ovStat for the wine bottle
function ovWine(position){
	arrayPosition = position
	
	
	//Start by getting the total amount of bottle to show the description
	allWineID = jQuery("#allWineID").val();
	arrayOfWine =  allWineID.split(";")
	numberOFbottle = arrayOfWine.length ;
	
	//put in upStat the old bottle 
	upWine(wineId);
	
	wineURLup = jQuery("#urlUP-"+arrayOfWine[arrayPosition]).val();
	wineURLov = jQuery("#urlOV-"+arrayOfWine[arrayPosition]).val();
	wineDESC = jQuery("#descVin-"+arrayOfWine[arrayPosition]).val();
	wineTitle = jQuery("#TitleVin-"+arrayOfWine[arrayPosition]).val();
	wineLink = jQuery("#linkVin-"+arrayOfWine[arrayPosition]).val();
	wineId   = arrayOfWine[arrayPosition];
	//on change la source de image
	jQuery("#vinSRC-"+arrayOfWine[arrayPosition]).attr('src', wineURLov );
	jQuery("#titleDesc").html(wineTitle);
	jQuery("#txtDesc").html(wineDESC);
	jQuery("#LinkToFiche").attr('href', wineLink );
}




jQuery(function()
{
	jQuery('.scroll-pane').jScrollPane(
	{
		verticalDragMinHeight: 24,
		verticalDragMaxHeight: 24
	}
	); 
	
	jQuery('.scroll-pane2').jScrollPane(
	{
		verticalDragMinHeight: 24,
		verticalDragMaxHeight: 24
	}
	); 
});







function bottleCenter(){
	var NbrBottle, widthWineHolder, arrayNbrBottle , bottleCount
   	NbrBottle = jQuery("#allWineID").val();
	arrayNbrBottle =  NbrBottle.split(";")
	bottleCount = arrayNbrBottle.length ;
   
   widthWineHolder = 134 * bottleCount
   widthWineHolder = widthWineHolder +"px"
   jQuery("#bottleHolder").css("width", widthWineHolder);
}



function menuWineBtn(Who,Action){
	var who,action
	
	who = Who
	action = Action
	
	//over
	if(action == 1){
		jQuery("#link-"+who).removeClass("navGalerie-OV");
	}
	
	//up
	if(action == 2){
		jQuery("#link-"+who).addClass("navGalerie-OV");
	}
	
}

//--------------------------------------
jQuery(function() {   
		
			var theWindow        = jQuery(window),
			    $bg              = jQuery("#bg"),
			    aspectRatio      = $bg.width() / $bg.height();
			    			    		
			function resizeBg() {
				
				if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
				    $bg
				    	.removeClass()
				    	.addClass('bgheight');
				} else {
				    $bg
				    	.removeClass()
				    	.addClass('bgwidth');
				}
							
			}
			                   			
			theWindow.resize(function() {
				resizeBg();
			}).trigger("resize");
		
		});
		
		
		
		
		
