// JavaScript Document for Empire Japan

// Image pre-loader
var eImg=new Array()
function preloadimages()
{
	for (i=0;i<preloadimages.arguments.length;i++)
	{
		eImg[i]=new Image()
		eImg[i].src=preloadimages.arguments[i]
	}
}
preloadimages("images/bg.jpg","images/logo.jpg","images/btn_home2.gif","images/btn_home.gif","images/btn_women2.gif","images/btn_women.gif","images/btn_mainboard2.gif","images/btn_mainboard.gif","images/BTN_DIRECT2.GIF","images/BTN_DIRECT.GIF","images/btn_men2.gif","images/btn_men.gif","images/BTN_CONTACT2.GIF","images/BTN_CONTACT.GIF","images/btn_become2.gif","images/btn_become.gif","images/ajax-loader2.gif")

//Image rollover
function roll(img_name1, img_src1)
{
   
   document[img_name1].src = img_src1;
   
}

// dropdown navigation
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;

// Results page css mouseover and mouseout style switch
function hoveron(id)  { document.getElementById(id).className="image-hold-hover"; }
function hoveroff(id) { document.getElementById(id).className="image-hold"; }

//function hoveronlast(id)  { document.getElementById(id).className="image-hold-last-hover"; }
//function hoverofflast(id) { document.getElementById(id).className="image-hold-last"; }

$(window).load(function () {

    /*RESULTS THUMBNAIL RESIZE*/
    $('.img img').each(function (index) {
        //set width and height of thumbnail if original width of image is less than container div
        var width, height
        width = $(this).width();
        height = 450; //large image

        if (width <= 348) {
            //alert("1");
            $(this).css('width', 175 + 'px');
        } else if (width > height) {//landscape
            //alert("2");
            $(this).css('height', 226 + 'px');
        } else if (width <= height && width > 348) { //square
            //alert("3");
            $(this).css('height', 226 + 'px');
        } else {
            //alert("4");
            $(this).css('height', 226 + 'px');
        }
    });
    $('.loader').css('display', 'none');

});
