/*******************Validation Functions***********************/
function clickIE4(){
    if (event.button==2){
    return false;
}
}

function clickNS4(e){
    if (document.layers||document.getElementById&&!document.all){
        if (e.which==2||e.which==3){
    
            return false;
        }
    }
}

if (document.layers){
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS4;
}else if (document.all&&!document.getElementById){
    document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")

/*******************************************************************/
var max_font_size = 18;
var min_font_size = 10;

jQuery(function(){
	jQuery('a.controlsFont').click(function(){
	   
		var ourText = jQuery('.mainContent, .main *, .col1-layout * , .mainContent td, .content-to-zoom *');
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 12);
		var stringEnding = currFontSize.slice(-2);
		if(this.id == 'large') {
			if(finalNum < max_font_size) finalNum += 2;
		}
		else if (this.id == 'small'){
			if(finalNum > min_font_size) finalNum -=2;
		}
		ourText.css('fontSize', finalNum + stringEnding);
	});
});


/*******************************************************************/
function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = jQuery(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   group.height(tallest+10);
}
jQuery(document).ready(function() {
   equalHeight(jQuery(".column"));
});

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_showHideLayers() {
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}
var main_table_width =935;

function adjustOverlayPosition(div) 
{
    if(div=='#msub58' || div=='#msub57' || div=='#msub127'){
        jQuery(div).css("left", 12);	 //reset
        jQuery(div).css("right", 'auto');	 //reset
        
    }else{
	jQuery(div).css("left", 0);	 //reset
	//var page_offset = $("#sizer").offset().left;
	var page_offset = (jQuery(window).width() - 935) / 2
	var left = jQuery(div).offset().left - page_offset;
	var w 	 = jQuery(".overlaydiv").width();
	var right_diff = (left+w) - main_table_width;
	if(right_diff > 0) {
		jQuery(div).css("left", (jQuery(div).position().left - right_diff) - 2);
		//$(".AbsoluteSubCont", $(div)).css("left", -160);	// aligning sub menus
	}
    }
    
}
jQuery(document).ready(function(){
    adjustOverlayPosition('#msub58');
    adjustOverlayPosition('#msub57');
    adjustOverlayPosition('#msub127');
});


/***************************Set Height**********************************************/

jQuery(document).ready(function(){
	
	jQuery('#login-form .registered-users').addClass('equal_height');
	jQuery('#login-form .new-users').addClass('equal_height');
	jQuery('div.info-box').addClass('equal_height');
			
	//set the starting bigestHeight variable
	var biggestHeight = 0;
	//check each of them
	jQuery('.equal_height').each(function(){
		//if the height of the current element is
		//bigger then the current biggestHeight value
		if(jQuery(this).height() > biggestHeight){
			//update the biggestHeight with the
			//height of the current elements
			biggestHeight = jQuery(this).height();
		}
	});
	//when checking for biggestHeight is done set that
	//height to all the elements
	jQuery('.equal_height').height(biggestHeight);
		
});
/*******************************Tbas****************************************************/

jQuery(document).ready(function() {
    
	recall();
	//When page loads...
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content
	//On Click Event
	jQuery("ul.tabs li").click(function() {
 	  autotabs_current = jQuery(".tabs li").index(jQuery(this));
        
        stopAutotabs();
		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content
		
		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        
		jQuery(activeTab).fadeIn(); //Fade in the active ID content
		
		return false;
	});
	
});

 var autotabs_current = 0;
    var autotabs_tm;
    var delay_per_slide = 4000;
    
    function initAutotabs()
    {
        var firstDelay = jQuery(".tab_container > div:eq(0) li").not(".cloned").length * delay_per_slide;
        
        autotabs_tm = setTimeout(autotabsNext, firstDelay); 
    }
    
    function stopAutotabs()
    {
        clearTimeout(autotabs_tm);
    }
    function autotabsNext()
    {
        autotabs_current++;
        if(autotabs_current > jQuery(".tab_container > div").length-1) autotabs_current=0;
        
        jQuery(".tabs li:eq("+ autotabs_current +")").trigger("click");
        stopAutotabs();
        
        var nextDelay = jQuery(".tab_container > div:eq("+ autotabs_current +") li").not(".cloned").length  *    delay_per_slide;
        autotabs_tm = setTimeout(autotabsNext, nextDelay); }


    initAutotabs();

/*******************************Green Tabs***********************************/
jQuery(document).ready(function() {

	//When page loads...
	jQuery(".tab_content_green").hide(); //Hide all content
	jQuery("ul.tabs_green li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content_green:first").show(); //Show first tab content

	//On Click Event
	jQuery("ul.tabs_green li").click(function() {

		jQuery("ul.tabs_green li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content_green").hide(); //Hide all tab content

		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		jQuery(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	jQuery('ul.tabs_green li:last').css('width',300);
	jQuery('.tab_content_green li:last').addClass('stylingNone');
});


/****************Slider********************************/

function formatText(index, panel) {
		  return index + "";
	    }
    	
		function recall(){
			
		if(jQuery('#tab1 .anythingSlider li').length>1){
		  
			
		jQuery(function () {
            jQuery('#tab1 .anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 3000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
				pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
				startText: "Go",             		// Start text
				stopText: "Stop",               // Stop text
				navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
            });
        });
        }
        if(jQuery('#tab2 .anythingSlider li').length>1){
		jQuery(function () {
            jQuery('#tab2 .anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 3000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
				pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
				startText: "Go",             		// Start text
				stopText: "Stop",               // Stop text
				navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
            });
        });
        }
        if(jQuery('#tab3 .anythingSlider li').length>1){
		jQuery(function () {
        
            jQuery('#tab3 .anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 3000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
				pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
				startText: "Go",             		// Start text
				stopText: "Stop",               // Stop text
				navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
            });
        });
        }
        if(jQuery('#tab4 .anythingSlider li').length>1){
		jQuery(function () {
        
            jQuery('#tab4 .anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 3000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
				pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
				startText: "Go",             		// Start text
				stopText: "Stop",               // Stop text
				navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
            });
        });
        }
	}
    
    	jQuery(function () {
	   if(jQuery('#subAnythingSliderWide .anythingSlider li').length>1){
		jQuery('#subAnythingSliderWide .anythingSlider').anythingSlider({
			easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
			autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
			delay: 3000,                    // How long between slide transitions in AutoPlay mode
			startStopped: false,            // If autoPlay is on, this can force it to start stopped
			animationTime: 1000,             // How long the slide transition takes
			hashTags: true,                 // Should links change the hashtag in the URL?
			buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: "Go",             // Start text
			stopText: "Stop",               // Stop text
			navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
		});
		}
		jQuery("#slide-jump").click(function(){
			jQuery('.anythingSlider').anythingSlider(6);
		});
		
	});
    
    
    jQuery(document).ready(function(){
        
        jQuery('.leftGallery .anythingSlider').anythingSlider({
			easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
			autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
			delay: 3000,                    // How long between slide transitions in AutoPlay mode
			startStopped: false,            // If autoPlay is on, this can force it to start stopped
			animationTime: 1000,             // How long the slide transition takes
			hashTags: true,                 // Should links change the hashtag in the URL?
			buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: "Go",             // Start text
			stopText: "Stop",               // Stop text
			navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
		});
		
		jQuery("#slide-jump").click(function(){
			jQuery('.anythingSlider').anythingSlider(6);
		});
		
	});
        
    
		
/*******************************************************************/
var max_font_size = 18;
var min_font_size = 10;

jQuery(function(){
	jQuery('a.controlsFont').click(function(){
	   var ourText = jQuery('.mainContent, .main *, .col1-layout * , .mainContent td, .content-to-zoom *');
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 12);
		var stringEnding = currFontSize.slice(-2);
		if(this.id == 'large') {
			if(finalNum < max_font_size) finalNum += 2;
		}
		else if (this.id == 'small'){
			if(finalNum > min_font_size) finalNum -=2;
		}
		ourText.css('fontSize', finalNum + stringEnding);
	});
});


/***************************Set Height**********************************************/
/*
jQuery(document).ready(function(){
	
	jQuery('div.col-1').addClass('equal_height');
	jQuery('div.col-2').addClass('equal_height');
			
	//set the starting bigestHeight variable
	var biggestHeight = 0;
	//check each of them
	jQuery('.equal_height').each(function(){
		//if the height of the current element is
		//bigger then the current biggestHeight value
		if(jQuery(this).height() > biggestHeight){
			//update the biggestHeight with the
			//height of the current elements
			biggestHeight = jQuery(this).height();
		}
	});
	//when checking for biggestHeight is done set that
	//height to all the elements
	jQuery('.equal_height').height(biggestHeight);
		
});*/
/* adjust positions of drop menus not to overlap with the table edge from the right */

