﻿/* MR, REGISTER, SPD POPUP */

function MRPopup(url) {
window.open(url, '_blank', 'toolbar=no,location=0,scrollbars=yes,width=600,height=400');
return false;
}

function RegisterPopup(url) {
window.open(url, '_blank', 'toolbar=no,location=0,scrollbars=yes,width=800,height=400');
return false;
}

function SPDAdminPopup(url) {
window.open(url, '_blank', 'toolbar=no,location=0,scrollbars=yes,width=600,height=500');
return false;
}


/* START JQUERY TABS */

$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */
	
	/* Defining an array with the tab text and AJAX pages: */
	var Tabs = {
		'Tab one'	: 'pages/page1.html',
		'Tab two'	: 'pages/page2.html',
		'Tab three'	: 'pages/page3.html',
		'Tab four'	: 'pages/page4.html'
	}
	
	/* The available colors for the tabs: */
	var colors = ['blue','green','red','orange'];
	
	/* The colors of the line above the tab when it is active: */
	var topLineColor = {
		blue:'lightblue',
		green:'lightgreen',
		red:'red',
		orange:'orange'
	}
	
	/* Looping through the Tabs object: */
	var z=0;
	$.each(Tabs,function(i,j){
		/* Sequentially creating the tabs and assigning a color from the array: */
		var tmp = $('<li><a href="#" class="tab '+colors[(z++%4)]+'">'+i+' <span class="left" /><span class="right" /></a></li>');
		
		/* Setting the page data for each hyperlink: */
		tmp.find('a').data('page',j);
		
		/* Adding the tab to the UL container: */
		$('ul.tabContainer').append(tmp);
	})

	/* Caching the tabs into a variable for better performance: */
	var the_tabs = $('.tab');
	
	the_tabs.click(function(e){
		/* "this" points to the clicked tab hyperlink: */
		var element = $(this);
		
		/* If it is currently active, return false and exit: */
		if(element.find('#overLine').length) return false;
		
		/* Detecting the color of the tab (it was added to the class attribute in the loop above): */
		var bg = element.attr('class').replace('tab ','');

		/* Removing the line: */
		$('#overLine').remove();
		
		/* Creating a new line with jQuery 1.4 by passing a second parameter: */
		$('<div>',{
			id:'overLine',
			css:{
				display:'none',
				width:element.outerWidth()-2,
				background:topLineColor[bg] || 'white'
			}}).appendTo(element).fadeIn('slow');
		
		/* Checking whether the AJAX fetched page has been cached: */
		
		if(!element.data('cache'))
		{	
			/* If no cache is present, show the gif preloader and run an AJAX request: */
			$('#contentHolder').html('<img src="img/ajax_preloader.gif" width="64" height="64" class="preloader" />');

			$.get(element.data('page'),function(msg){
				$('#contentHolder').html(msg);
				
				/* After page was received, add it to the cache for the current hyperlink: */
				element.data('cache',msg);
			});
		}
		else $('#contentHolder').html(element.data('cache'));
		
		e.preventDefault();
	})
	
	/* Emulating a click on the first tab so that the content area is not empty: */
	the_tabs.eq(0).click();
});

/* END JQUERY TABS */



/* POPUP BOX - E.G. ANTITRUST STATEMENT IN COMMUNITIES */
<!-- ANTITRUST SCRIPT -->
_spBodyOnLoadFunctionNames.push("loadMsg()");


function closeBox(toClose) {
document.getElementById(toClose).style.display = "none";
   setCookie(toClose, "closed", 1);
}

function closeBox2(toClose, chkbox) {
var numOfDays = 30;
document.getElementById(toClose).style.display = "none";
if(document.getElementById(chkbox).checked)
{
   numOfDays = 999;
}
   setCookie(toClose, "closed", numOfDays);
}

function setCookie(cName, value, expiredays) {
   var expDate = new Date();
   expDate.setDate(expDate.getDate()+expiredays);
   document.cookie=cName + "=" + escape(value) + 
   ";expires=" + expDate.toGMTString() + "; path=/";
}

function loadMsg()
{
   loadMsg2('msgbox');
   loadMsg2('msgbox2');

}

function loadMsg2(msgClass) {

   msg = document.getElementsByTagName("div");
   for (i=0; i<msg.length; i++) {
      if(msg[i].className == msgClass) {
         if(document.cookie.indexOf(msg[i].id) == -1) {
            msg[i].style.display = "block";
         }
       }
   }
}



/* HOMEPAGE REDESIGN: JQUERY CAPTION SLIDE.  USED ON FEATURED HEADLINES & NEWS */

(function($) {
	$.fn.capslide = function(options) {
		var opts = $.extend({}, $.fn.capslide.defaults, options);
		return this.each(function() {
			$this = $(this);
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			if(!o.showcaption)	$this.find('.ic_caption').css('display','none');
			else $this.find('.ic_text').css('display','none');
				
			var _img = $this.find('img:first');
			var w = _img.css('width');
			var h = _img.css('height');
			$('.ic_caption',$this).css({'color':o.caption_color,'background-color':o.caption_bgcolor,'bottom':'0px','width':w});
			$('.overlay',$this).css('background-color',o.overlay_bgcolor);
			$this.css({'width':w , 'height':h, 'border':o.border});
			$this.hover(
				function () {
					if((navigator.appVersion).indexOf('MSIE 7.0') > 0)
					$('.overlay',$(this)).show();
					else
					$('.overlay',$(this)).fadeIn();
					if(!o.showcaption)
						$(this).find('.ic_caption').slideDown(500);
					else
						$('.ic_text',$(this)).slideDown(500);	
				},
				function () {
					if((navigator.appVersion).indexOf('MSIE 7.0') > 0)
					$('.overlay',$(this)).hide();
					else
					$('.overlay',$(this)).fadeOut();
					if(!o.showcaption)
						$(this).find('.ic_caption').slideUp(200);
					else
						$('.ic_text',$(this)).slideUp(200);
				}
			);
		});
	};
	$.fn.capslide.defaults = {
		caption_color	: 'white',
		caption_bgcolor	: 'black',
		overlay_bgcolor : 'blue',
		border			: '1px solid #fff',
		showcaption	    : true
	};
})(jQuery);

