// JavaScript Document


function isOldBrowser(){	
	if($.browser.name == "msie" && $.browser.versionX < 7) return true;
	if($.browser.name == "firefox" && $.browser.versionNumber < 3.5) return true;
	if($.browser.name == "opera" && $.browser.versionX < 9) return true;
	if($.browser.name == "safari" && $.browser.versionX < 4) return true;
	if($.browser.name == "chrome" && $.browser.versionX < 3) return true;
	return false;
}

function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



if(isOldBrowser() && $.cookie('browserwarned') == null && window.location.href.indexOf("browser.html") == -1 ){
    var ref = window.location.href;
    window.location.href = "http://www.EJTN.net/browser.html?ref=" + ref;
}

$(document).ready(function() {
	
	////adding a few classes to the body to facilitate browser and/or OS specific CSS declarations
	////documentation on http://jquery.thewikies.com/browser/
	//add computer OS to body class eg. win
	$('body').addClass($.os.name);	
	//add browser name to body class eg. msie
	$('body').addClass($.browser.name);
	//add browser name+release to body class eg. msie8
	$('body').addClass($.browser.className);

	
	//smart input text fiels, with pre-text
   $("input[type=search].inactive,input[type=text].inactive").bind("focus", 
	function(e){
		var originalText = $(this).attr("value");		
		var originalColor = $(this).css("color");
		
		$(this).removeClass("inactive");
		$(this).css("border-color", "#888787 #D7D7D7 #D7D7D7 #BDBDBD");
		$(this).attr("value", "");		
		
		$(this).bind("blur",
		function(){
			if($(this).attr("value") == ""){
				$(this).attr("value", originalText);
				$(this).addClass("inactive");
			}
		}
		);
		$(this).siblings("input[type=image]")
		
	}
	);
   
   //manipulation of search box submit buttons
   $(".searchbox input[type=text]").bind("focus", 
	function(e){	    
	    var originalURL = $(this).siblings(":first").attr("src");
	    var newURL = originalURL.replace("search.png", "search_active.png");
		$(this).siblings(":first").attr("src", newURL);					
	}
	);
   $(".searchbox input[type=text]").bind("blur", 
	function(e){
	    var originalURL = $(this).siblings(":first").attr("src");
	    var newURL = originalURL.replace("search_active.png", "search.png");	   
		$(this).siblings(":first").attr("src", newURL);		
	}
	);
   //end of manipulation of search box submit buttons
   
   
  //Font Size
  var originalFontSize = $('html').css('font-size');
  var cookieName = "fontSize";
  var date = new Date();
  date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));

  if($.cookie(cookieName)){
	  originalFontSize = parseInt($.cookie(cookieName));	 
	  $('html').css('font-size', originalFontSize);
  }
  
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum+1;
    if(newFontSize>16){return false}
    $('html').css('font-size', newFontSize);	
	
	$.cookie(cookieName, newFontSize, { path: '/', expires: date });
	
    curvyCorners.redraw();
    
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum-1;
    if(newFontSize<11){return false}
    
    $('html').css('font-size', newFontSize);	
	$.cookie(cookieName, newFontSize, { path: '/', expires: date });
	
	curvyCorners.redraw();
	
    return false;
  });

   
});



