﻿function openGallery(gallery, name) {
   gallery.find("a").lightBox({ containerBorderSize: 0, containerResizeSpeed: 200,heading: name });
   gallery.find("a:first").click();

}

function openGalleryWithCaption(gallery, name, caption) {
    gallery.find("a").lightBox({ containerBorderSize: 0, containerResizeSpeed: 200, heading: name, caption: caption });
    gallery.find("a:first").click();
}

var timeout = 500;
var closetimer = 20;
var ddmenuitem = 0;
var menuitem = null;

function jsddm_mainmenu_streetwear() {
    jsddm_mainmenu_open($("#streetwearHover"),40);
   ;
}

function jsddm_mainmenu_outerwear() {
    jsddm_mainmenu_open($("#outerwearHover"),126);
}

function jsddm_mainmenu_open (ojb,ol) {

    jsddm_canceltimer();
    ddmenuitem = ojb;

    if (ddmenuitem.find('li').size() > 0) {
        menuitem = $("#ddmenu");
        menuitem.find('*').remove();
        menuitem.css('visibility', 'visible');
        menuitem.append($("<ul></ul>").add(ddmenuitem.html()));
        if ($("body").find("div.fp-upper-row").size() > 0)
            menuitem.css('top', 86);
        else
            menuitem.css('top', 86);
        menuitem.css('left', ($("body").width() / 2) - 440+ol);
    } else {
         jsddm_close();
     }

 }


 function jsddm_auxlinks_open() {

     jsddm_canceltimer();
     ddmenuitem = $(this).find('div');

     if (ddmenuitem.find('*').size() > 0) {
         menuitem = $("#ddmenu");
         menuitem.find('*').remove();
         menuitem.css('visibility', 'visible');
         menuitem.append($("<div></div>").add(ddmenuitem.html()));
         menuitem.css('top', 30);
         menuitem.css('left', ($("body").width() / 2) + ddmenuitem.width() + 16);
     } else {
         jsddm_close();
     }
 }

function mjsddm_box_hover() {

    jsddm_canceltimer();
   
}

function jsddm_close() {

    if (menuitem) menuitem.css('visibility', 'hidden');
   
   
 }

function jsddm_timer()
{ closetimer = window.setTimeout(jsddm_close, timeout); }

function jsddm_canceltimer() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    } 
}

function pageResize()
{
   a = nikgetPageSize()
   if(a[3] > $("#content-wrapper").height()+ 128)
   {
     $("#bottom-fix").css("height",a[3]-$("#content-wrapper").height()-128)  
     $("#bottom-fix").show();
   }else
   {
        $("#bottom-fix").hide();
   }
}

$(document).ready(function() {
    pageResize();
    $('#mainmenu > li.streetwear').hover(jsddm_mainmenu_streetwear, jsddm_timer);
    $('#mainmenu > li.outerwear').hover(jsddm_mainmenu_outerwear, jsddm_timer);
    $('#auxlinks > li').hover(jsddm_auxlinks_open, jsddm_timer);
    $('#ddmenu').hover(mjsddm_box_hover, jsddm_timer);
    
    $(window).resize(function() {
            // Get page sizes
            pageResize();
    });

});


	     var flirInitUrl = 'http://text.nikitaclothing.com/';


	     $(function() {
	    /*     var iesix = (typeof document.body.style.maxHeight == 'undefined')
	         
	         var fs = new FLIRStyle({ cFont:'egypt' });
	         FLIR.init({ path: flirInitUrl });
	         FLIR.replace('span.videoheading', new FLIRStyle({cFont: 'egypt', mode: 'wrap' }));
	         FLIR.replace('div.flir',fs);
	         FLIR.replace('h1.flir',fs);
	         FLIR.replace('h3.flir',fs);
	         FLIR.replace('h2.flir',fs);
	         FLIR.replace('p.category',fs);
	         FLIR.replace('.photogallery .item span',fs);


	         if (!iesix) {
	             FLIR.replace('a.flir',fs);


	         } else {
	             $('a.flir').css('text-indent', '0px');
	         }*/
	     });


document.onclick = jsddm_close;

function nikgetPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    return arrayPageSize;
};



