Current File : /home/aventura/public_html/js/gallery.js |
$(window).ready(function(){
//$(".gallery > .galleryInner").addClass(".galleryInner");
var ua = navigator.userAgent.toLowerCase(),
positionItem = 0,
allPositionItem = ($(".gallery").find(".galleryInner").find(".galleryItem").length/$(".gallery").length)/3,
selectImage = 0,
allImages;
addbutonEvent();
function addbutonEvent(){
$(".upGallery").click(nextClickHandler);
$(".upGallery").hover(overHandler, outHandler);
$(".downGallery").click(prevClickHandler);
$(".downGallery").hover(overHandler, outHandler);
$(".zoom").click(zoomClickHandler);
$(".zoom").hover(overImgHandler, outImgHandler);
$(".link").hover(overImgHandler2, outImgHandler2);
$(".close").click(clothClickHandler);
$(".close").hover(overClothHandler, outClothHandler);
$(".previewPrev").click(clickPrevHandler);
$(".previewPrev").hover(overPreviewHandler, outPreviewHandler);
$(".previewNext").click(clickNextHandler);
$(".previewNext").hover(overPreviewHandler, outPreviewHandler);
$(window).bind("hashchange", changeHashGall);
function changeHashGall(){
$(".galleryPreview").css({"z-index":5}).delay(500).animate({"bottom":"-800px"})
}
function overHandler(){
var item = $(this);
if (ua.indexOf("msie") == -1) {
item.stop().animate({"backgroundColor":"#8b2786"},300,"easeOutCubic");
}else{
//-----IE------
item.css({"backgroundColor":"#8b2786"});
//-----!IE-----
}
}
function outHandler(){
var item = $(this);
if (ua.indexOf("msie") == -1) {
item.stop().animate({"backgroundColor":"#ff599f"},300,"easeOutCubic");
}else{
//-----IE------
item.css({"backgroundColor":"#ff599f"});
//-----!IE-----
}
}
function nextClickHandler(){
if(positionItem!=0){
positionItem--;
$(this).parent().index();
changeItem($(this));
}
return false;
}
function prevClickHandler(){
if(positionItem!=allPositionItem-2){
positionItem++;
$(this).parent().index();
changeItem($(this));
}
return false;
}
function overImgHandler(){
var item = $(this);
item.parent().data("over", true);
item.stop().animate({"left":"245px"},300,"easeInOutCubic");
$(this).parent().css({"z-index":2});
}
function outImgHandler(){
var item = $(this);
item.parent().data("over", false);
item.stop().animate({"left":"122px"},300,"easeInOutCubic", function(){
if(item.parent().data("over")==false){
item.parent().css({"z-index":1});
}
});
}
function overImgHandler2(){
var item = $(this);
item.parent().parent().data("over", true);
item.parent().stop().animate({"left":"123px"},300,"easeInOutCubic");
$(this).parent().parent().css({"z-index":2});
}
function outImgHandler2(){
var item = $(this);
item.parent().parent().data("over", false);
item.parent().stop().animate({"left":"0px"},300,"easeInOutCubic", function(){
if(item.parent().parent().data("over")==false){
item.parent().parent().css({"z-index":1});
}
});
}
function zoomClickHandler(){
var item = $(this);
selectImage = item.parent().index();
item.parent().data("over", false);
item.stop().animate({"left":"122px"},300,"easeInOutCubic", function(){
if(item.parent().data("over")==false){
item.parent().css({"z-index":1});
}
});
$(".galleryPreview").css({"z-index":5, "bottom":"-800px"});
$(this).parent().parent().parent().parent().find(".galleryPreview").css({"z-index":5}).stop().animate({"bottom":"-14px"}, 500, "easeOutCubic")
changePreview(selectImage, $(this).parent().parent().parent().parent().find(".galleryPreview").find(".innerPreview"), 0);
$(this).parent().parent().parent().parent().find(".galleryPreview").find(".previewPrev").css({"visibility":"visible"});
$(this).parent().parent().parent().parent().find(".galleryPreview").find(".previewNext").css({"visibility":"visible"});
if(selectImage==0){
$(this).parent().parent().parent().parent().find(".galleryPreview").find(".previewPrev").css({"visibility":"hidden"})
}
if(selectImage==allImages-1){
$(this).parent().parent().parent().parent().find(".galleryPreview").find(".previewNext").css({"visibility":"hidden"})
}
return false;
}
function clothClickHandler(){
$(this).parent().parent().parent().parent().find(".galleryPreview").css({"z-index":5}).stop().animate({"bottom":"-800px"}, 500, "easeInCubic")
}
function overClothHandler(){
var item = $(this);
if (ua.indexOf("msie") == -1) {
item.stop().animate({"backgroundColor":"#ff599f"},300,"easeInOutCubic");
}else{
//-----IE------
item.css({"backgroundColor":"#ff599f"});
//-----!IE-----
}
}
function outClothHandler(){
var item = $(this);
if (ua.indexOf("msie") == -1) {
item.stop().animate({"backgroundColor":"#fff"},300,"easeInOutCubic")
}else{
//-----IE------
item.css({"backgroundColor":"#fff"});
//-----!IE-----
}
}
function overPreviewHandler(){
var item = $(this);
if (ua.indexOf("msie") == -1) {
item.stop().animate({"backgroundColor":"#ff599f"},300,"easeInOutCubic");
}else{
//-----IE------
item.css({"backgroundColor":"#ff599f"});
//-----!IE-----
}
}
function outPreviewHandler(){
var item = $(this);
if (ua.indexOf("msie") == -1) {
item.stop().animate({"backgroundColor":"#8b2786"},300,"easeInOutCubic")
}else{
//-----IE------
item.css({"backgroundColor":"#8b2786"});
//-----!IE-----
}
}
function clickPrevHandler(){
allImages = $(this).parent().find(".innerPreview").find(".galleryPreviewItem").length;
if(selectImage>0){
selectImage--;
changePreview(selectImage, $(this).parent().find(".innerPreview"));
}
$(this).parent().find(".previewNext").css({"visibility":"visible"})
if(selectImage==0){
$(this).css({"visibility":"hidden"})
}
}
function clickNextHandler(){
allImages = $(this).parent().find(".innerPreview").find(".galleryPreviewItem").length;
if(selectImage<allImages-1){
selectImage++;
changePreview(selectImage, $(this).parent().find(".innerPreview"), 500);
}
$(this).parent().find(".previewPrev").css({"visibility":"visible"})
if(selectImage==allImages-1){
$(this).css({"visibility":"hidden"})
}
}
}
function changePreview(previewNum, galleryNum, animationTime){
galleryNum.animate({"left":-(912*previewNum)}, animationTime, "easeInOutCubic");
}
function changeItem(buttonClick){
buttonClick.parent().find(".gallery .galleryInner").animate({"top":(-135*positionItem)}, 500, "easeInOutCubic");
}
})