﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
var currentTab = 1;
//loading popup with jQuery magic!
function loadPopup(call) {
    //loads popup only if it is disabled
    if (popupStatus == 0) {
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        if (call == 0)
            $("#popupdiv").fadeIn("slow");
        else if (call == 1)
            $("#popupima").fadeIn("slow");
        else if (call == 3)
            $("#popupprd").fadeIn("slow");
        else if (call == 4)
            $("#LongDesc").fadeIn("slow");
        else if (call == 5)
            $("#popupdiv1").fadeIn("slow");
        popupStatus = 1;
    }
}

//disabling popup with jQuery magic!
function disablePopup(call) {
    //disables popup only if it is enabled
    if (popupStatus == 1) {
        $("#backgroundPopup").fadeOut("slow");
        if (call == 0)
            $("#popupdiv").fadeOut("slow");
        else if (call == 1)
            $("#popupima").fadeOut("slow");
        else if (call == 3)
            $("#popupprd").fadeOut("slow");
        else if (call == 4)
            $("#LongDesc").fadeOut("slow");
        else if (call == 5)
            $("#popupdiv1").fadeOut("slow");
        popupStatus = 0;
    }
}

//centering popup
function centerPopup(call, tab) {

    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = null;
    var popupWidth = null;
    if (call == 0) {
        currentTab = tab;
        var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");

        popupHeight = $("#popupdiv").height();
        popupWidth = $("#popupdiv").width();
        //centering
        $("#popupdiv").css({
            "position": "absolute",
            "top": windowHeight / 2 - popupHeight / 2,
            "left": windowWidth / 2 - popupWidth / 2
            
        });
    }
    else if (call == 1) {
    var o = document.getElementById('mysitelogo');
   
        popupHeight = $("#popupima").height();
        popupWidth = $("#popupima").width();
        //centering
        $("#popupima").css({
            "position": "fixed",
            "top":  o.offsetTop - 140,
            "left": windowWidth / 2 - popupWidth / 2
        });
    }
    else if (call == 3) {
        popupWidth = $("#popupprd").width();
        //centering
        $("#popupprd").css({
            "position": "absolute",
            "top": "0",
            "left": (windowWidth / 2 - popupWidth / 2) / 2
        });
    }
    else if (call == 4) {
        popupWidth = $("#LongDesc").width();
        //centering
        $("#LongDesc").css({
            "position": "absolute",
            "top": "0",
            "left": (windowWidth / 2 - popupWidth / 2) / 2
        });
    }
    else if (call == 5) {
        popupWidth = $("#popupdiv1").width();
        //centering
        $("#popupdiv1").css({
            "position": "absolute",
            "top": "0",
            "left": (windowWidth / 2 - popupWidth / 2)
        });
    }

    //only need force for IE6

    $("#backgroundPopup").css({
        "height": windowHeight
    });

}
//top menu hover
function change_color(menuclrid, divcnt, visbool) {
    menuclr = $(menuclrid);
    if (visbool == 1) {
        document.getElementById(divcnt).style.display = "block";
        var o = document.getElementById('logobar');
        document.getElementById(divcnt).style.top = "109px";
        document.getElementById(divcnt).style.left = o.offsetLeft + "px";

    }
    else {
        document.getElementById(divcnt).style.display = "none";
    }
}


//CONTROLLING EVENTS IN jQuery
try
{
$(document).ready(function() {

    //LOADING POPUP
    //Click the button event!
    //$("#button").click(function() { centerPopup(0, 6); loadPopup(0); });
    //$("#button1").click(function() { centerPopup(0, 5); loadPopup(0); });
    //$("#button2").click(function() { centerPopup(0, 4); loadPopup(0); });
    //$("#button3").click(function() { centerPopup(0, 1); loadPopup(0); });
    //$("#btnEmail").click(function() { centerPopup(0, 1); loadPopup(0); });
    //$("#abebo").click(function() { centerPopup(0, 6); loadPopup(0); });
    $("#atweet").click(function() { centerPopup(0, 5); loadPopup(0); });
    $("#aface").click(function() { centerPopup(0, 4); loadPopup(0); });
    $("#btnTestimonial").click(function() { centerPopup(0, 7); loadPopup(0); });
    $("#pmail1").click(function() { centerPopup(0, 1); loadPopup(0); });
    $("#pemail1").click(function() { centerPopup(0, 1); loadPopup(0); });
    $("#pbebo1").click(function() { centerPopup(0, 4); loadPopup(0); });
    $("#ptwit1").click(function() { centerPopup(0, 5); loadPopup(0); });
    $("#pface1").click(function() { centerPopup(0, 6); loadPopup(0); });
    $("#pplus").click(function() { centerPopup(3, 0); loadPopup(3); });
    $("#proDesc").click(function() { centerPopup(4, 0); loadPopup(4); });

    $("#review").click(function() { centerPopup(5, 0); loadPopup(5); });

    //CLOSING POPUP
    //Click the x event!
    $("#popupContactClose").click(function() {
        disablePopup(0);
    });
    $("#popupContactDisClose").click(function() {
        disablePopup(1);
    });
    $("#closebt").click(function() {
        disablePopup(3);
    });
    $("#closeDesc").click(function() {
        disablePopup(4);
    });
    $("#closepopstn").click(function() {
        disablePopup(5); window.location.reload();
    });
    ////Click out event!
    //$("#backgroundPopup").click(function() {
    //    disablePopup(0);
    //});
    //Press Escape event!
    $(document).keypress(function(e) {
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopup(0);
        }
    });
    //for topbar menu
    $("#CatLadies").mouseover(function() {
        change_color('CatLadies', 'dropdownLadies', 1);
    }).mouseout(function() {
        change_color('CatLadies', 'dropdownLadies', 0);
    });

    $("#dropdownLadies").mouseover(function() {
        change_color('dropdownLadies', 'dropdownLadies', 1);
    }).mouseout(function() {
        change_color('dropdownLadies', 'dropdownLadies', 0);
    });

    $("#CatMens").mouseover(function() {
        change_color('CatMens', 'dropdownMens', 1);
    }).mouseout(function() {
        change_color('CatMens', 'dropdownMens', 0);
    });

    $("#dropdownMens").mouseover(function() {
        change_color('dropdownMens', 'dropdownMens', 1);
    }).mouseout(function() {
        change_color('dropdownMens', 'dropdownMens', 0);
    });

    $("#hlkrev").click(function() {
        var dvLongRev = document.getElementById('longreview');
        var dvShortRev = document.getElementById('shortreview');
        var lnk = document.getElementById('hlkrev');
        if (dvLongRev.style.display == 'none') {
            $('#longreview').toggle('slow');
            $('#shortreview').toggle('slow');
            lnk.innerHTML = '( Hide all reviews )';
        } else {
            $('#shortreview').toggle('slow');
            $('#longreview').toggle('slow');
            lnk.innerHTML = '( See all reviews )';
        }
    });

    $("#area1").click(function()
    { popupVideo('BlueSoft.flv'); });
    $("#area2").click(function()
    { popupVideo('BeneFici.flv'); });
    $("#area3").click(function()
    { popupVideo('CatPads.flv'); });
    popupVideo('BlueSoft.flv');


      
   

});
}
catch(err)
{
}

function popupVideo(vfile) {
    
    $("#videodiv").innerHTML = '';
var video="<object  type='application/x-shockwave-flash' data='/includes/video/player_flv_1.1.4.swf' width='428' height='241' wmode='transparent' >" +
                "<param name='movie' value='/includes/video/player_flv_1.1.4.swf'/> " +
                "<param name='allowFullScreen' value='true' /> " +
                "<param name='FlashVars' value='flv=/includes/video/" + vfile + "&amp;width=428&amp;height=241&amp;showstop=1&amp;showvolume=1&amp;showtime=1&amp;startimage=/medias/startimage_en.jpg&amp;showfullscreen=1&amp;bgcolor1=04223C&amp;bgcolor2=04223C&amp;playercolor=04223C' /></object>";
document.getElementById("videodiv").innerHTML = video;


}


 function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ($active.length == 0) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order

    // var $sibs = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
.addClass('active')
.animate({ opacity: 1.0 }, 3000, function() {
    $active.removeClass('active last-active');
});
}



try
  {
             $(function() 
            {
                setInterval("slideSwitch()", 5000);
            }
            );
  }
catch(err)
  {
  
  }
