var activeBackgroundRootID = "";


	$(document).ready(function () {	
	
		$('#top_menu li').hover(
			function () {
				//show its submenu
				$('ul', this).slideDown(200);

			}, 
			function () {
				//hide its submenu
				$('ul', this).slideUp(200);			
			}
		);


        $(".preview a").mouseover(function(){ 

	var imgSrc = new String( $( "#" + $(this).attr("id") + "_image" ).attr( "src" ) );
	var replacedSrc = imgSrc.replace( '_off.jpg', '_on.jpg' );
	$( "#" + $(this).attr("id") + "_image" ).attr("src", replacedSrc);


	});

        $(".preview a").mouseout(function(){

                var imgSrc = new String( $( "#" + $(this).attr("id") + "_image" ).attr( "src" ) );
                var replacedSrc = imgSrc.replace( '_on.jpg', '_off.jpg' );
                $( "#" + $(this).attr("id") + "_image" ).attr("src", replacedSrc);



	});

	$(".preview a").click(function(){
		
	      var largePath = $(this).attr("href");
	      //var largeAlt = $(this).attr("title");


var cacheImage = document.createElement('img');


	    var elid = $(this).attr("id");
            activeBackgroundRootID = elid;

	    cacheImage.onload = function(){

	if( $( "#" + elid + "_misc" ).attr("value") )
	{
	    var miscOptions = new String( $( "#" + elid + "_misc" ).attr("value") );
	    var miscOptionsArray = miscOptions.split( ':' );
                     
	    if( miscOptionsArray[ 0 ] )
	    {	document.body.style.background=miscOptionsArray[ 0 ];	    }


	}
		
		$("#largeImg").attr({ src: largePath });
	     //   $("#slogan").html(largeAlt);

	    };
	    cacheImage.src = largePath;

		return false;
	});


	$( "#btn_bg1" ).click();

	});



function gotoBgLink()
{
 
    if( document.getElementById( activeBackgroundRootID + "_link" ) && document.getElementById( activeBackgroundRootID + "_link" ).value )
	{

	    document.location.href = document.getElementById( activeBackgroundRootID + "_link" ).value;
	}

    return false;
}
