//var rMode = '?';

//function renderMode(){
//  var mode=document.compatMode;
//  if(mode){
//	  if(mode=='BackCompat')
//  		rMode='Quirks';
//  	else if(mode=='CSS1Compat')
//  		rMode='Standards Compliance';
//  	else 
//  		rMode='Almost Standards Compliance';
//  }
//}

 function positionDivs() {
	var vx = viewport.width();
	var vy = viewport.height();
  //var my = $('#masthead-image').height();
  var my = 388;
  //var mx = $('#masthead-image').width();
  var mx = 802;
  var ct = 230;
  
  $('#page').width(mx);
	$('#page').height(vy - 20);
  $('#page').css('top', 10);
  $('#page').css('left', (vx - mx)/2);
  
	var cy;
	switch(cPage) {
	case 'about.html':
			 cy = 700;
			 break;
	case 'contact.html':
			 cy = 400;
       $('#content').height(cy);
			 break;
	case 'repair.html':
    cy = 380;
    ct = 264;
  	break;
	case 'tuition.html':
    cy = 670;
    ct = 264;
  	break;
	}
  
  $('#content').css('top', ct);

	$('#lower-content').height(cy);
	$('#lower-content').css('top',ct);
	  
  $('#footer').css('top', cy+ct);
  
  switch(cPage) {
  case 'about.html':
    //news();
  	$(".n-image-slider").jCarouselLite({btnNext: ".next", btnPrev: ".prev"});  	
    $("img.thumb").hover(
      function () {
      	var img = $(this).attr('src');
        //img = img.replace(".JPG", "_L.JPG");
        $('#n-big-image').attr('src',img);
      }
    );
    break;
  case 'contact.html':
  	positionContact();
  	$(window).bind('resize.contact', positionContact);
    break;
  }
}

function positionContact() {
	var cx = $('#content').width();
	var cy = $('#content').height();
  var mx = $('#c-map').width();
  
  $('#i-map').width(mx*0.9);
  $('#i-map').height(cy*0.7);
  $('#c-address').css('left', mx + 50);
  $('#c-text').css('left', mx + 50);
  $('#c-text').width(cx - mx - 100);
}

function loadPage(page) {
  switch(cPage) {
  case 'contact.html':
  	$(window).unbind('resize.contact');
    break;
  }
  
  cPage = page;
  
	$("#content").load(page, "", positionDivs);
  pageTracker._trackPageview("/"+page );
}

//function updateNews(data) {
//   if (data.length>0){ 
//     $("#n-right").html(data); 
//   } 
//}

//function news(){ 
//  $.post("./test.php", {}, updateNews); 
//} 

function menuOnMouseOver(item, level) {
  var menuOption = $('#h-menuOption').text();
  var subMenuOption = $('#h-subMenuOption').text();
  if(item !== menuOption) {
  	$('#menu-' + item).attr('src', 'img/menu-' + item + '-highlight.gif');
  }
}

function menuOnMouseOut(item, level) {
  var menuOption = $('#h-menuOption').text();
  var subMenuOption = $('#h-subMenuOption').text();
  if(item !== menuOption){
  	$('#menu-' + item).attr('src', 'img/menu-' + item + '.gif');
  }
}

function menuOnClick(item, level) {
  var menuOption = $('#h-menuOption').text();
  if(item !== menuOption){
    	$('#menu-' + menuOption).attr('src', 'img/menu-' + menuOption + '.gif');
  
    	$('#menu-' + item).attr('src', 'img/menu-' + item + '-selected.gif');
  
			//dhtmlHistory.add(item + '.html', item);  
  		loadPage(item + '.html');    
      $('#h-menuOption').text(item);
  }
}
