// JavaScript Document

function launchTutorials(){

	$("#dimScreen").fadeIn('normal', function(){

								frames['tutorialFrame'].location.href = 'http://admin.bigblackbag.net/client_admin/tutorials/tutorial_intro.html';

								centerElement('tutorialPos');

								$('#tutorialPos,#closeOverlay').show();

								resizeOverlay();

								}

							

							);

}



function resizeOverlay(){

	w = $(window).width();

	//h = $('#content').height();

	h = $(document).height();

	$("#dimScreen").css({height:parseInt(h)+"px",width:parseInt(w)+"px"});

}



function centerElement(theElem){

	vpW = parseInt($(window).width());

	vpH = parseInt($(window).height());

	

	elemW = parseInt($('#' + theElem).outerWidth());

	elemH = parseInt($('#' + theElem).outerHeight());

	

	elemLeft = parseInt(vpW - elemW)/2;

	elemTop = parseInt(vpH - elemH)/2;

	

	topOffset = $(window).scrollTop();

	

	if (theElem == 'loginPos'){

	$('#' + theElem).css({top:elemTop, left:elemLeft});

	}else{

	$('#' + theElem).css({top:topOffset + 25, left:elemLeft});

	}

	

}



function closeOverlay(){

	if(frames['tutorialFrame']){

	frames['tutorialFrame'].location.href = 'http://admin.bigblackbag.net/client_admin/tutorials/tutorial_intro.html';

	}

	$('#tutorialPos,#loginPos,#dimScreen,#diagramPos,.misc').hide();

	resizeOverlay();

}



function launchDiagram(img,h,w){

	$("#dimScreen").fadeIn('normal', function(){

								$('#diagramPos').css({'width' : w +'px', 'height' : h + 30 + 'px'});

								$('#diagram').css({'width' : w +'px', 'height' : h + 'px', 'backgroundImage' : 'url(' + img + ')' , 'backgroundRepeat' : 'none'});

								centerElement('diagramPos');

								$('#diagramPos,#closeOverlay2').show();

								resizeOverlay();

								}

							

							);

}



function launchMisc(miscName){

	$("#dimScreen").fadeIn('normal', function(){

								centerElement(miscName + 'Pos');

								$('#' + miscName + 'Pos').show();

								resizeOverlay();

								}

							

							);

}



function launchLogin(){

	$("#dimScreen").fadeIn('normal', function(){

								centerElement('loginPos');

								$('#loginPos').show();

								resizeOverlay();

								}

							

							);

}

