﻿$(document).ready(function(){
	StyleWelcomeControl();
	StyleCreateGroupSiteForm();
	FixRibbonAndWorkspaceDimensions();
});

function StyleCreateGroupSiteForm() {
	try {
		console.log(document.location.pathname);
		if(document.location.pathname == '/Groups/Lists/SqtSiteCreatorJobs/NewForm.aspx') {
		
			var host = 'http://'+location.hostname+'/groups/';
			// insert url prefix						
			$('input[title=Site URL]').val(host);
			
			$('input[title=Site URL]').focusout(function() {
				var val = $(this).val();
				if(val.indexOf(host) < 0) {
					$(this).css('background','#FCCCC6');
				}
				else {
					$(this).css('background','#fff');
				}
			});
			
			// hide url desc
			$('input[title=Description]').hide();
			$('input[title=Description]').prev().hide()
		}
	}
	catch(e) {}
}

function StyleWelcomeControl() {
	try {
		$('.welcomeUserDisplayName').attr('title','SVS User Menu');
		$('.welcomeUserDisplayName').mouseenter(function() {
			$('.welcomeUserMenu').show(300);
		});
		$('.welcomeUserMenu').mouseenter(function() {
			$(this).show();
		});
		$('.welcomeUserMenu').mouseleave(function() {
			$(this).hide(300);
		});
	}
	catch(e) {}
}



function zoomIn() {
document.body.style.fontSize = "1.25" + "em";
document.getElementById('fontSmall').className = 'inactive';
document.getElementById('fontMedium').className = 'inactive';
document.getElementById('fontLarge').className = 'active';
}  

function zoomOut() {
document.body.style.fontSize = ".55" + "em";
document.getElementById('fontSmall').className = 'active';
document.getElementById('fontMedium').className = 'inactive';
document.getElementById('fontLarge').className = 'inactive';
}

function zoomNone () {
document.body.style.fontSize = "80" + "%";
document.getElementById('fontSmall').className = 'inactive';
document.getElementById('fontMedium').className = 'active';
document.getElementById('fontLarge').className = 'inactive';
}


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';
  }
}
