/* 	5 scripts Javascript are included in this one */
/*
/*	-script.js
/*	-scroll.js
/*	-tooltip.js
/*	-favoris.js
/*	-changeselect.js
/*
/* 	Target : optimizing HTTP requests
/* 	Modified by Sirius-Lab

/* SCRIPT.JS */

$(document).ready(function(){	

/*gestion fancybox*/

 $("a.fancybox").fancybox();
		
		$('#s7').cycle({ 
	    fx:     'scrollUp', 
    timeout: 13000, 
    delay:  -2000 
		});
	
	
	
/* galerie images de usbdetail*/

 var big = $("#bigimg");
 var thumbs=$("#thumb").find("a");
 
 
 thumbs.eq(0).click(function(e){ 
    e.preventDefault();
  var $this = $(this),   
  target = $this.children("img").attr("src");
  lien=target.replace(/mini/i, "big" );  
  if (big.attr("src") == lien) return; 
  big.attr("src",lien);
  });
  

 thumbs.eq(1).click(function(e){ 
    e.preventDefault();
  var $this = $(this), 
  target = $this.children("img").attr("src");
  lien=target.replace(/mini/i, "big" );  
  if (big.attr("src") == lien) return; 
  big.attr("src",lien); 
  });
  

  thumbs.eq(2).click(function(e){ 
    e.preventDefault();
  var $this = $(this),
  target = $this.children("img").attr("src");
  lien=target.replace( /mini/i, "big" );  
  if (big.attr("src") == lien) return; 
  big.attr("src",lien); 
  });

  
  thumbs.eq(3).click(function(e){ 
    e.preventDefault();
  var $this = $(this),  
  target = $this.children("img").attr("src");
  lien=target.replace( /mini/i, "big" );  
  if (big.attr("src") == lien) return; 
  big.attr("src",lien); 
  });
  
 
//devis gestion images select

pagedevis=$('#devis').attr("id");
if(pagedevis=='devis'){
$(window).load(function(){
  selected=$('#model option:selected').attr("value");
  photo=selected.split('-----');
  $("#selectimg").children("img").attr("src","images/usb/mid/"+photo[0]);
  selected2=$('#2ndModel option:selected').attr("value");
  photo2=selected2.split('-----');
  $("#selectimg2").children("img").attr("src","images/usb/mid/"+photo2[0]);
});
}

$('#model').change(function(){
selected=$('#model option:selected').attr("value");
photo=selected.split('-----');
$("#selectimg").children("img").attr("src","images/usb/mid/"+photo[0]);
});

$('#2ndModel').change(function(){
selected=$('#2ndModel option:selected').attr("value");
photo=selected.split('-----');
$("#selectimg2").children("img").attr("src","images/usb/mid/"+photo[0]);
});

//gestion images png
  
 $(function(){$(document).pngFix();});
 
	
});


/* SCROLL.JS */

$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();
		
		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;
		
		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];
		
		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;
		
		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
});

/* TOOLTIP.JS */


/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 70;
		yOffset = 20;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});


/* FAVORIS.JS */


function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("USBFACTORY - Clés Usb & Accessoires - Switzerland","http://www.usbfactory.ch/",""); }
else { window.external.AddFavorite("http://www.usbfactory.ch/","USBFACTORY - Clés Usb & Accessoires - Switzerland"); } }


/* CHANGESELECT.JS */

function change(what) {
	document.getElementById("show").src = what.value;
}
function change2(what) {
  document.getElementById("show2").src = what.value;
}
