Victoria = new Object();

Victoria.is_safari = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(!navigator.accentColorName)?true:false;
Victoria.is_ie55 = (document.all && document.fireEvent && !document.createComment);
Victoria.win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);




$(document).ready(function() {
 externalLinks();
 replaceHrTag();
 styleSecondCol();
 addPrintLink();
 addSafariCss();
 // only make the next call if you have called the lightbox code before you call this functions file
 if($(".lightbox").length > 0)
 $(".lightbox").prettyPhoto();
});

function externalLinks(){
    if (document.getElementsByTagName){
        var objAnchors = document.getElementsByTagName('a');
        for (var iCounter=0; iCounter<objAnchors.length; iCounter++){
            if (objAnchors[iCounter].getAttribute('href') && objAnchors[iCounter].getAttribute('rel') == 'external'){
                objAnchors[iCounter].onclick = function(event){return launchWindow(this, event);};
                objAnchors[iCounter].onkeypress = function(event){return launchWindow(this, event);};
            }
        }
    }
}

function launchWindow(objAnchor, objEvent){
    var iKeyCode;
    if (objEvent && objEvent.type == 'keypress'){
        if (objEvent.keyCode)
            iKeyCode = objEvent.keyCode;
        else if (objEvent.which)
            iKeyCode = objEvent.which;
        if (iKeyCode != 13 && iKeyCode != 32)
        return true;
	}
	return !window.open(objAnchor);
}

function replaceHrTag(){	
	$("#main hr").wrap("<div class='hr'></div>"); 
}

function StripeTable(){	// must include table plugin to use this function			
	$(".stripeMe tr").mouseover(function(){
		$(this).addClass("over");
	}).mouseout(function(){
		$(this).removeClass("over");
	});
	$(".stripeMe tr:even").addClass("alt");  
}

function styleSecondCol() {
    $('tr').each(function(){		  
		var count=1;
    	$('td').each(function(){
      		count++;
			//alert(count);
			if(count%2 != 0){ 
				$(this).addClass("txtright");
			}
    	})
    })
}

function fadeLightboxImages() {
	$(".bottomcenter img").fadeTo("fast", 0.4); // This sets the opacity of thumbs to fade down to 60% on page load
	$(".bottomcenter img").hover(function(){
		$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
	},function(){
		$(this).fadeTo("fast", 0.4); // This should set the opacity back to 60% on mouseout
	});
}

function changeBox() 
{
	document.getElementById('div1').style.display='none';
	document.getElementById('div2').style.display='inline';
	document.getElementById('password').focus();
}

function restoreBox() 
{
	if(document.getElementById('password').value=='')
	{
	  document.getElementById('div1').style.display='inline';
	  document.getElementById('div2').style.display='none';
	}
}


  
  function addPrintLink() {
 // add print page link - since it can only work for JS, only add it for JS users
$('#print') // create list item
    .addClass('print') //add relevant class to it
    .append('<a href="javascript:window.print();">Print this page</a>') //put in the link
    .insertBefore('li a.foo'); //add before the li item with link of class 'foo'
  }
  
  function addSafariCss() {
	  
	  var userAgent = navigator.userAgent.toLowerCase();
	  
    
    // Is this a version of Safari?
    if($.browser.safari){
        $('body').addClass('browserSafari');
        
        // Add the version number
        userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
        userAgent = userAgent.substring(0,1);
        $('body').addClass('browserSafari' + userAgent);
    }


 
  }