// JavaScript Document

var home_images = [ "LPP_3766", "LPP_3866", "LPP_3879", "LPP_3817", "LPP_3892", "LPP_3895", "LPP_3899" ];

var imgTimer = function( ) { 
    // Property: Frequency of elapse event of the timer in millisecond
    this.Interval = 10000;
    
    // Property: Whether the timer is enable or not
    this.Enable = new Boolean(false);	
	
	this.index = 0;
	this.img = "";
	this.img_length = 0;
	this.img_list = [];
	this.fade = function( ) {
		if (this.index >= this.img_length ) {
			this.index = 0;	
		}
					
		$(this.img).fadeTo('fast', 0).attr("src","images/" + home_images[ this.index ] + ".jpg" ).fadeTo('slow',1);
		this.index++;
	}
	this.Start = function( img, img_list ) {	
        this.Enable = new Boolean(true);

		thisObject = this;
        if (thisObject.Enable)
        {
				thisObject.img = img;
				thisObject.img_list = img_list;
				thisObject.index = 0;
				thisObject.img_length = img_list.length;
                thisObject.fade;
		thisObject.timerId = setInterval(
            function()
            {

                thisObject.fade(); 
            }, thisObject.Interval);
        }
    };
    
    // Function: Stops the timer
    this.Stop = function()
    {            
        thisObject.Enable = new Boolean(false);
        clearInterval(thisObject.timerId);
    };
	
};

// cycle images
$(document).ready( function ( ) {
	if ( $("#main-content > h1").text( ) == "Home")  {
		var img = $("#right-column > img");
		 // set initial
		//$(img).attr("src","images/" + home_images[0] + ".jpg" );
		var img_timer = new imgTimer( );
		//img_timer.Start( img, home_images );
	}							 
} );


// cycle images
$(document).ready( function ( ) {
			$("#main-content > form").css('clear', 'both' );
	if ( $("#main-content > h1").text( ) == "BREADCRUMB")  {
		var img = $("#right-column > img");
		$("#main-content > h1").text("Login");

		 // set initial
		//$(img).attr("src","images/" + home_images[0] + ".jpg" );
		var img_timer = new imgTimer( );
		//img_timer.Start( img, home_images );
	}							 
} );

// Change shippng
$(document).ready( function ( ) {
	if ( $("td.pageHeading").text( ) == "Delivery Information")  {
		$("tr.main > b").each( function( ) { 
			if ( $(this).text() == "Shipping Method" ) {
				$(this).text("Delivery Method");
			} 
		} );
		
		$("tr.main > b").each( function( ) { 
			if ( $(this).text() == "Shipping Address" ) {
				$(this).text("Delivery Address");
			} 
		} );
	} 
} );