﻿
$(document).ready(function() {
	
	/*$('#navigation ul li.menu').each(function(index) {
    	getLinkWidth($(this));
  	});*/
	//alert($('#navigation ul li.menu a.bloglink').width());
	
	// navigation tabs
	$("#navigation ul li.start").hover(
	  function () {
		$(this).find('img').attr('src','img/navigation/tab2.png');
		// add the 'act' string to class
		$(this).find('p').attr('class', $(this).find('p').attr('class') + 'act');
	  }, 
	  function () {
		var curclass = $(this).find('p').attr('class');
		// remove the 'act' string from class
		var newclass = curclass.replace('act','');
		$(this).find('img').attr('src','img/navigation/tab1.png');
		$(this).find('p').attr('class',newclass);
	  }
	);

//navigation dropdown

function mainmenu() {
    $(" #navigation ul li ul").css({ display: "none" }); // Opera Fix
    $(" #navigation ul li").hover(function () {
        $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(0);
    }, function () {
        $(this).find('ul:first').css({ visibility: "hidden" });
    });
}



$(document).ready(function () {
    mainmenu();
});

	// navigation 'p' tag click
	/*$('#navigation ul li p').click(function() {
		var url = $(this).find('a').attr('href');
		document.location.href = url;
	});*/


	if ($('#dftbody').length) {
		
		$('#dftbody').width($(window).width());
		
	    //introImgWidth('#dftbody img','header');
	

    }
	
	//results
    if ($('#relmdlcont').length) {
	    scrollerWidth('wn','scrollbar','track','relmdlcont', 'loader');
    }
	
	//details
    if ($('#dtlmdlcont').length) {
	    scrollerWidth('wn','scrollbar','track','dtlmdlcont');
    }
	
	//results thumbnail hover
	$("#t1 ul li div.imgcontainer").hover(
	  function () {
		$(this).find('div.modelname').attr('class','modelname2');
	  }, 
	  function () {
		$(this).find('div.modelname2').attr('class','modelname');
	  }
	);

	//center model names
	/*$('#relmdlcont ul li div.modelname a.mdllink').each(function(index) {
    	var linkWidth, linkHeight, marginWidth, marginHeight;
		linkWidth = $(this).width();
		//linkHeight = $(this).height();
	
		marginWidth = linkWidth/2;
		marginHeight = 6;
		//alert(linkWidth);
		$(this).css('margin-top', '-' + marginHeight + 'px');
		$(this).css('margin-left', '-' + marginWidth + 'px');
		//alert(linkWidth + " " + linkHeight);
  	});*/

	// portfolio/details.aspx fancy box
    if ($('#dtlmdlcont').length) {
	
	    /* Apply fancybox to multiple items */
	
	    $("a[rel=group1]").fancybox({
		    'transitionIn'	:	'elastic',
		    'transitionOut'	:	'elastic',
		    'width'			:	'auto',
		    'height'		:	950,
		    'speedIn'		:	600, 
		    'speedOut'		:	200, 
		    'overlayShow'	:	false
	    });
    }
});

$(window).load(function() {  
    $('#relmdlcont ul li div.imgcontainer 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 <= 344) {//narrow portrait
            //alert("1");
            $(this).css('width', 162 + 'px');
        } else if (width > height) {//landscape
            //alert("2");
            $(this).css('height', 212 + 'px');
        } else if (width <= height && width > 344) { //square
            //alert("3");
            $(this).css('height', 212 + 'px');
        } else {
            //alert("4");
            $(this).css('height', 212 + 'px');
        }
    });
    $('#loader').css('display', 'none');
});
$(window).resize(function() {
    if ($('#dftbody').length) {
		
  	    $('#dftbody').width($(window).width());
		
    }
	
	//results
    if ($('#relmdlcont').length) {
        scrollerWidth('wn', 'scrollbar', 'track', 'relmdlcont', 'loader');
    }
	
	//details
    if ($('#dtlmdlcont').length) {
	    scrollerWidth('wn','scrollbar','track','dtlmdlcont');
    }
});



