/***
 * Global Javascript Include 
 */
if (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function
() {} }; 

showPopupWindow = function(mFileURL) { //v2.0
  MM_openBrWindow ( mFileURL, 'Corporater', 'status=yes,scrollbars=yes,width=951,height=100');
};

MM_openBrWindow = function(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
};

performAll = function(){
	setDivHeight ();
};

/*
setDivHeight = function (){
	var divh = document.getElementById('innerbodyContainer').offsetHeight+280;
	if (divh>850) {
		document.getElementById('lhs').style.height = (divh)+"px";
	} else {
		document.getElementById('lhs').style.height = "850px";
	}
};

*/
/**/
setDivHeight = function (){
	setDefaultheight();
	var divLeft = document.getElementById('lhs').offsetHeight+20;
	var divContent = document.getElementById('innerbodyContainer').offsetHeight;
    	
	if(divLeft > divContent ) {
		document.getElementById('innerbodyContainer').style.height = (divLeft)+"px";
	}
	
	if(divContent > divLeft ) {
		document.getElementById('lhs').style.height = (divContent)+"px";
	}
	
};


setDefaultheight = function (){
	document.getElementById('innerbodyContainer').style.height = "auto";
	document.getElementById('lhs').style.height = "auto";
	
};

displayLangSwitch = function() {
	
};

$(document).ready(function(){
		$("#contactinfo").hide();
		$("#languageblock").hide();	
		
		$('#global-office-link').click(function(){
			setDefaultheight();
			$('#contactinfo').toggle();	
			$('#global-office-link').toggleClass("expand");
			$('#global-office-link').toggleClass("collapse");
			setDivHeight();
		   });
		
		$("#language-switch").click(function(){
			$("#languageblock").toggle();	
		   });
		
	});



autoPopupResize = function() { //v2.0

  /*** Resize window **/
  var mWinHeight, mWinWidth, mScreenHeight, mScreenWidth;
  var xCoord, yCoord;
  var mImageContainerWidth, mImageContainerHeight;
  var STD_HEIGHT_DIFF, STD_WIDTH_DIFF;
  
  if ($.browser.msie == true) {
    STD_HEIGHT_DIFF = 50;
  } else {
    STD_HEIGHT_DIFF = 90;
  }
  
  if ($.browser.msie == true) {
    STD_WIDTH_DIFF = 60;
  } else {
    STD_WIDTH_DIFF = 60;
  }

  mWinHeight = $(document).height();
  mWinWidth = $(document).width();
  
  mScreenHeight = screen.height;
  mScreenWidth = screen.width;
  
  mImageContainerWidth = $("#popup .img-holder").width();
  mImageContainerHeight = $("#popup .img-holder").height();

  mAvailScreenHeight = mScreenHeight - 30;
  
  mActualWinHeight = mWinHeight+STD_HEIGHT_DIFF;
  
  // refresh resize handle FOR WIdTH
  if (mWinWidth > mImageContainerWidth) {
      if ((mWinWidth - mImageContainerWidth) < STD_WIDTH_DIFF) {
        var tempVal = 0;
        tempVal = mWinWidth - mImageContainerWidth;
        
        mActualWinWidth = mWinWidth+(STD_WIDTH_DIFF -tempVal) ;
      }
      else {
        mActualWinWidth = mWinWidth;
      }
  } else {
        mActualWinWidth = mImageContainerWidth + mSTD_HEIGHT_DIFF;
  }
  
  
  // screen heigth adjust handler
  if (mActualWinHeight >  mAvailScreenHeight) {
      window.resizeTo(mActualWinWidth,mAvailScreenHeight );
  } else {
      window.resizeTo(mActualWinWidth,mActualWinHeight );
  }
  
    
  // Move window 
  if (mActualWinWidth <  mScreenWidth) {
    xCoord = ((mScreenWidth - mActualWinWidth)/2);
    xCoord = Math.floor(xCoord);
    
  } else {
    xCoord = 0;
  }
  
  if (mActualWinHeight <  mAvailScreenHeight) {
    yCoord = ((mAvailScreenHeight - mActualWinHeight)/2);
    yCoord = Math.floor(yCoord);
    
  } else {
    yCoord = 0;
  }
  
  window.moveTo(xCoord,yCoord);

};





/************** NEW YEAR SNOW FALL SCRIPT **************************/

document.write("<script type='text/javascript' src='/assets/js/snowfall.min.jquery.js'></script>");

	$(document).ready(function(){
			var today = new Date();
			var dd = today.getDate();
			var mm = today.getMonth()+1;//January is 0!

			if(((dd>22)&&(mm==12))||((dd<3)&&(mm==1)))
				{	
					$('#header').css("background-image", "url(http://www.corporater.com/assets/images/corptheme/sgreeting-masthead.gif)");
					//Start the snow default options you can also make it snow in certain elements, etc.
					$(document).snowfall({round : true, minSize:3, maxSize:8,flakeCount : 60});	
				}
		});


function getUrlVars() {
	var vars = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}
