var domain ='';
var domainRef ='';
function init(d, dr) {
	domain = d;
	domainRef = dr;
	$(document).ready(function(){
		// fix breadcrumbs
		$("#breadcrumbs li:last").removeAttr('class');
		$("#breadcrumbs li").each(function(){
			if ($(this).attr('class')) {
				$(this).find(".breadcrumb-title").wrapInner('<a href="'+$(this).attr('class')+'"></a>');
			}
		});
		
		// fix forms
		$(".siteForm").attr("name", d+$(".siteForm").attr("name"));
		
		stripeTable();
		
		//slider
		$("#login_tab").click(function () {
			$("#login_slide").slideToggle("slow");
			//$("#login_slide input:text:visible:enabled:first").focus();
		});
		
		$('label.over').labelOver('over-do-it');
		
		$('input:text, input:password').addClass("text");

	});
}
jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", domainRef+arguments[i]);
  }
}
function stripeTable() {
	// works backwards because the index of the first row is 0. :) nice
	$("table.stripe tr:even").addClass("odd");
	$("table.stripe tr:odd").addClass("even");
}

// Not only when the DOM is ready, but when the images have finished loading,
// important, but subtle difference to $(document).ready();
$(window).bind('load', function () {
	$('img.fade').hover(
		function () {
			$(this).stop().animate({opacity: .5}, 250);
		},
		function () {
			$(this).stop().animate({opacity: 1}, 500);
		}
	);
	
});


// Input field text show/hide functions
$(document).ready(function(){  
     $("#txtSearch").blur(function(){  
         if(!$(this).val()) $(this).val("Search Site");  
     });  
     $("#txtSearch").focus(function(){  
         if($(this).val() == "Search Site") $(this).val("");  
     });  
 });
$(document).ready(function(){  
     $("#txtEmail").blur(function(){  
         if(!$(this).val()) $(this).val("Email");  
     });  
     $("#txtEmail").focus(function(){  
         if($(this).val() == "Email") $(this).val("");  
     });  
 });
$(document).ready(function(){  
     $("#txtPwd").blur(function(){  
         if(!$(this).val()) $(this).val("Password");  
     });  
     $("#txtPwd").focus(function(){  
         if($(this).val() == "Password") $(this).val("");  
     });  
 });


/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

