// JavaScript Document

//font size manager
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function checkCookie()
{
font_size=getCookie('byon_font_size');
stdSize = 3;
  //alert('Welcome again '+font_size+'!');
  
  
  if (font_size!=null && font_size!="")
  {
 		return font_size; 
  }
else
  {
  		return stdSize;
  }
}


switchFontSize=function(ckname,val){
	var bd = jQuery("body");
	switch (val) {
		case 'inc':
			if (CurrentFontSize+1 < 7) {
				bd.removeClass('fs'+CurrentFontSize);
				CurrentFontSize++;
				bd.addClass('fs'+CurrentFontSize);
			}
		break;
		case 'dec':
			if (CurrentFontSize-1 > 0) {
				bd.removeClass('fs'+CurrentFontSize);
				CurrentFontSize--;
				bd.addClass('fs'+CurrentFontSize);
			}
		break;
		default:
			bd.removeClass('fs'+CurrentFontSize);
			CurrentFontSize = val;
			bd.addClass('fs'+CurrentFontSize);
	}
	Cookie.set(ckname, CurrentFontSize,{duration:365});
}


var title;



jQuery(document).ready(function () {
	
	
	jQuery('img.menu_head6').click(function () {
	
		
		
		jQuery('ul.menu_body6').slideToggle('medium');	
		
    });
		 
		 
		 
	
	/* start menu classes*/
	
	//ADD First and last classes to menu
	jQuery('ul.menu li.active ul li:first').addClass("firstItem");
	jQuery('ul.menu li.active ul li:last').addClass("lastItem");
	
	//add irst and last classes to topmenu
	jQuery('ul#topMenu').each(function(){
		
				 jQuery(this).children('li:first').addClass("firstItem");
				 jQuery(this).children('li:last').addClass("lastItem");
				 
	});

	//ADD First and last classes to menu
	jQuery('ul#matic li ul').each(function(){
		
				 jQuery(this).children('li:first').addClass("firstItem");
				 jQuery(this).children('li:last').addClass("lastItem");
				 
	});
	
	// see if ul li ul li has chidlren if yes add class haschildren
	jQuery('ul#matic li ul li'  ).each(function(){ 
			
			if  (jQuery(this).children('ul').size() > 0 ) {
    			jQuery(this).addClass("hasChildren");
			}									   
	});
	

	jQuery("ul#matic li ul li").hover(
	  function () { 	
		jQuery(this).parents('li').addClass('topMenuLeft');	
	  },
	  function () {
		jQuery(this).parents('li').removeClass('topMenuLeft');
	  }
	);
		

	if (jQuery('ul.menu ul li').hasClass("active")) {
		
		jQuery('ul.menu li.active').attr("id", "topCurrent");
		jQuery('ul.menu ul li.active').attr("id", "current");
		jQuery('ul.menu ul li ul li.active').attr("id", "currentChild");
	}
	


	if (jQuery('ul.menu li').hasClass("active")) {
		jQuery('ul.menu > li.active').attr("id", "topCurrent");
	}
						
	/* end menu classes */
	
	if (jQuery('#page iframe').hasClass("noSizeInc")) {
			jQuery('span.styleswitcher').css('display', 'none'); 
	}


	

	
	
	
	

	

});

function showAlert(id)	{
	
	if (typeof(id) == 'undefined') {
	id = '';
	}
	
	jQuery('ul.menu_body' + id).fadeOut('opacity:"hide"');
	jQuery('ul.menu_body' + id).addClass("closed");
	jQuery('ul.menu_body'+ id).removeClass("open");
							  
}



/* Call to launch FancyBox from Flash */
function callFancy(my_href) {
			
			var j1 = document.getElementById("hiddenclicker");
			j1.href = my_href;
			jQuery('#hiddenclicker').trigger('click');
}
		
		

			

/* Fancybox launch code*/
jQuery(document).ready(function() {
	jQuery("a.overlay-flash").fancybox({
 		'padding'                : 0,
 		'overlayOpacity'        : 0.75,
		'width'				: 820,
		'height'			: 565,
		'autoScale'     	: true,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'hideOnContentClick'    : false,
		'scrolling':	'auto',
		'type'				: 'iframe'
 	});
	
	
	jQuery("a.comparison-Table").fancybox({
 		'padding'                : 0,
 		'overlayOpacity'        : 0.75,
		'width'				: 950,
		'height'			: 700,
		'autoScale'     	: true,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'hideOnContentClick'    : false,
		'scrolling':	'auto',
		'type'				: 'iframe'
 	});
	
	
});
		


/*Quick Link Code*/
var tmpstate= 1;

jQuery(function() {
 	// hides the slickbox as soon as the DOM is ready (a little sooner that page load)
  	jQuery('#quickLinksMore').hide();
 	
	jQuery('#quickLinksMoreShow').click(function() {
    	jQuery('#quickLinksMore').slideToggle(750);
		
			if (tmpstate == 1) {
			jQuery('#quickLinksMoreShow').html(" - Quick Links ");
			tmpstate= 2;
			} else {
			jQuery('#quickLinksMoreShow').html(" + Quick Links ");
			tmpstate= 1;
		
		}
		return false;
  	});
});
	





	
		 
/*side nav handler */
jQuery(document).ready(function () {
														 
	jQuery('table.expandTb tbody tr:first-child td').addClass('dropDownLink');
	jQuery('table.stripeTable tbody tr td').removeClass('dropDownLink');
	jQuery('ul#btmMenu li:last').addClass('lastBtmMenu');
	jQuery('#btmAdverts p:last').addClass('last');
	
	
	
				
	jQuery(function() {
					
					
            var offset = jQuery("#leftMenu").offset();
			
            var topPadding = 20;
			var rightPadding = 40;
			var bottom = 0;
			
			var yLeftToGo = document.height - (window.pageYOffset + window.innerHeight);
			
			if ( jQuery("body").hasClass("byond") ) {
				
			 var loggedin = 1;
			}
			
			
			
            jQuery(window).scroll(function() {
				
				
				var yLeftToGo = jQuery(document).height() - (jQuery(window).height() + window.pageYOffset);
				if 	(yLeftToGo > 0) {
				
				bottom = 0;
				
				} else {
					
				bottom = 1;
				
				}
										   
							   
										   
				
				var windowHeight = jQuery(window).height();
	
				var windowHeightMinusHeader = windowHeight - 175;
				
				//alert(windowHeightMinusHeader);
				
				var leftSideHeight = jQuery("#leftMenu").height(); 
				
				var rightSideHeight = jQuery("#mainRight").height(); 
				
				var problemLeft = 0;
				var problemRight = 0;
				
				var overallProblem = 0;
				
				
				if (windowHeightMinusHeader < leftSideHeight ) {
					
				problemLeft =1;
					
				} 
				
				if (rightSideHeight > windowHeightMinusHeader  ) {
					
				problemRight =1;
					
				}

				if (problemLeft == 1 && problemRight == 1 ) {
					
				overallProblem = 1;
				
				}
				
				//alert("overallProblem = " + overallProblem);
				//alert("right side = " + problemRight);
				
			
				if (problemLeft == 1 || problemRight == 1) {
					
					jQuery("#internalFixed").css("position", "absolute");
			
					
				}  else if (loggedin == 1)  {
					
					jQuery("#internalFixed").css("position", "absolute");
				
				
               }  else if (problemLeft == 1 && problemRight == 0 && (jQuery(window).scrollTop() < (offset.top - 175) )) {
                    
					jQuery("#leftMenu").stop().animate({
                        marginTop: 30
                    });
					
					jQuery("#mainRight").stop().animate({
                        marginTop: 30
                    });
					
			  }  else if (problemLeft == 0 && problemRight == 1 && (jQuery(window).scrollTop() < (offset.top - 175) )) {
                    
					jQuery("#leftMenu").stop().animate({
                        marginTop: 30
                    });
					
					jQuery("#mainRight").stop().animate({
                        marginTop: 30
                    });	
                
				} else {
					
					  jQuery("#leftMenu").stop().animate({
                        marginTop:30
                    
						});
					  
					  jQuery("#mainRight").stop().animate({
                        marginTop: 30
                    
						});
					  
					 jQuery("#internalFixed").css("position", "fixed");
					
				}
				
				
				
			
				
            });
        });
	
	
	



});





