﻿$(document).ready(function(){
	$('#zz1_TopNavigationMenun8').mouseover(function() {
		$(this).removeAttr('onmouseover');
		changeClip();
	});
	leftNavStuff();
	removeStyles();
	hideLeftCol();
	regButtons();
	nacsSearchResults();
});


function FixRibbonAndWorkspaceDimensions(){
  ULSxSy:;
  g_frl = true;
  var elmRibbon = GetCachedElement("s4-ribbonrow");
  var elmWorkspace = GetCachedElement("s4-workspace");
  var elmTitleArea = GetCachedElement("s4-titlerow");
  var elmBodyTable = GetCachedElement("s4-bodyContainer");
  if(!elmRibbon || !elmWorkspace || !elmBodyTable){
    return;
  }
  if (!g_setWidthInited){
    var setWidth = true;
    if (elmWorkspace.className.indexOf("s4-nosetwidth") > -1)
      setWidth = false;
    g_setWidth = setWidth;
    g_setWidthInited = true;
  }
  else{
    var setWidth = g_setWidth;
  }
  var baseRibbonHeight = RibbonIsMinimized() ? 44 : 135;
  var ribbonHeight = baseRibbonHeight + g_wpadderHeight;
  if(GetCurrentEltStyle(elmRibbon, "visibility") == "hidden"){
    ribbonHeight = 0;
  }

  // Override default resizing behavior
  // -- adds padding to the top of the "s4-workspace" <div> if the ribbon exists and has content
  // -- allows the ribbon to be positioned using CSS instead of JavaScript (more accessible)
  // -- checks to see if the page is inside a "no-ribbon" dialog
  if(elmRibbon.children.length > 0 && document.getElementsByTagName("html")[0].className.indexOf('ms-dialog-nr') == -1){
    elmWorkspace.style.paddingTop = ribbonHeight + 'px';
  }
  else{
  	$('#s4-workspace').addClass('noRibbon');	
  }
}

function changeClip() {
	$('#zz1_TopNavigationMenun8Items').toggle();
}

function leftNavStuff() {
	$('ul.root > li.static > ul.static > li.selected').parents('li.static').children('a').addClass('active subIsActive');
	$('ul.root > li.static > span.static > span.additional-background > span.menu-item-text').addClass('AspNet-Menu-NonLink');
}

function removeStyles() {
	$('.butMaker').removeAttr('style');
}

function hideLeftCol() {
	var leftcoltext = $('#LeftNavigationAreaCell').text();
	if (leftcoltext.length < 1) {
		$('#LeftNavigationAreaCell').hide();
	}
}

function regButtons() {
var url = window.location.href;

if (url.search("SiteRegistration.aspx") > 0) {
	$('#controlWell').attr('style','position:relative;');
    $('a.butMakerSubmit:contains("Create New Account")').removeAttr('class').attr('style','position:absolute; white-space:nowrap;top:15px;').parent().removeAttr('class').parent('').attr('style','display:inline; margin-left: 180px; position: absolute;');
    $('input[name*="btnContinue"]').parent().parent().attr('style', 'position:absolute; right:0; margin-top:10px;');
    $('input[name*="btnSearchAgain"]').parent().parent().attr('style', 'float:left;margin-top:10px;');
}
}


function nacsSearchResults() {
var url = window.location.href;
	if (url.search("NACSSearch") > 0) {
		$('td.ms-bodyareaframe > div').css('height','auto');
	}
}
