var ratio = 1697/1129;
var slideWidth = 0;
var slideHeight = 0;
var w;
var h;
var r;

function setSize() {
	w = jQuery(window).width();
	h = jQuery(window).height();
	
	jQuery('#bgImage').css("width",10*w+'px'); // made the width of bgImage bigger than it should be.
	if (h>600) { jQuery('#black-bg').css("height",h+'px'); }

	//console.log(w+','+h);
	
	r = w/h;
	if (r > ratio) {
		slideWidth = w;
		slideHeight = w/ratio;
	} else {
		slideHeight = h;
		slideWidth = h*ratio;
	}
		
	jQuery("#container img").attr("width",slideWidth);
	jQuery("#container img").attr("height",slideHeight);
		
	jQuery('#container').css("margin-left",-slideWidth/2);
	jQuery('#container').css("margin-top",-slideHeight/2);
		
	jQuery('#bgImage').css("margin-left",-(page-1)*slideWidth);
	
}

// menu section
function activeMenu(id) {
	$('#main-nav .rollover').show();
	$('#main-nav .active').hide();
	$(id+" .active").show();
	$(id+" .rollover").hide();
}

function activeSubNav() {
	$(".subnav li a").bind("click", function(){
		$(".subnav").find("span").remove();
		if(BrowserDetect.browser=="Explorer" && BrowserDetect.version=="6"){
			$(this).append('<span><img src="images/dot.gif" width="5" height="7" /></span>');
		} else {
			$(this).append('<span><img src="images/dot-li.png" width="5" height="7" /></span>');
		}
	});
	$(".subnav li a").hover(
		function () { $(this).addClass('hover'); },
		function () { $(this).removeClass('hover'); }
	);
}

// load contents of sub category
function show(ref) {
	$("#content .hidden").hide();
	$(ref).show();
}

// contact page
function contactReady() {
	$('.pop').prepend('<div class="btn-close"><img src="themes/greenlight/images/close.gif" width="12" height="12" /></div>');
	$('.btn-close').hover(
		function () { $('.btn-close img').attr('src','themes/greenlight/images/close_ro.gif'); },
		function () { $('.btn-close img').attr('src','themes/greenlight/images/close.gif'); }
	);
	$('.btn-close').bind('click', function () {
		$("#content .hidden").hide();
	});
	$('.profile').hover(
		function () { $(this).css('color', '#00ffd6'); },
		function () { $(this).css('color', '#dbdcdd'); }
	);
}

// on ready, on change...
$(document).ready(function() {
	setSize();
	//setLinks();
});

$(window).resize(function(){
	setSize();
});