// JavaScript Document

/**
 * Image src URLs
 **/
var imageList = [
				 "bottom-marquee/prateek_stylome.gif",
			
				 "bottom-marquee/victory.gif",
				 "bottom-marquee/ajnara_elements.gif",
				 "bottom-marquee/ajnara_le_garden.gif",
				 "bottom-marquee/skytech-matrott.gif",
				
                 "bottom-marquee/01.gif",
               
                 "bottom-marquee/03.gif",
                 "bottom-marquee/04.gif",
                 "bottom-marquee/05.gif",
                 "bottom-marquee/06.gif",
                 "bottom-marquee/07.gif",
                 "bottom-marquee/08.gif",
				 "bottom-marquee/09.gif",
                 "bottom-marquee/10.gif",
                           "bottom-marquee/15.gif",
                 "bottom-marquee/16.gif",
				  "bottom-marquee/17.gif",
				  				 ];

var imagelink=[
			    "prateek_stylome.html",
				
				  "victory_crossroads.html",				  
			    "ajnara_elements.html",
				 "garden_villas.html",
				  "skytech_matrott.html",
				 
			   "ajnara.html",
			 
			   "mahagun_moderne.html",
			   "Homes121.html",
			   "windor_court.html",
			   "prateek_wisteria.html",
			   "prateek_laurel.html",
			   "ajnara_integrity.html",
			   "ajnara_homes.html",
			   "gaur_city.html",
			  "ajnara_daffodil.html",
			   "sikka_karnam.html",
			   "vvip.html",
			  
			   
			   ]

var imgname=[
			 
			 "Prateek Stylome",
			
			 "Victory Crossroads",			 
			 "Ajnara Elements",
			 "Ajnara Le Garden",
			 "Skytech Matrott",
			
			 "Ajnara Grand Heritage",
			
			 "Mahagun Moderne",
			 "Homes 121 ",
			 "Assotech Windor Court",
			 "Prateek Wisteria",
			 "Prateek Laurel",
			 "Ajnara Integrity",
			 "Ajnara Homes",
			 "Gaur City-2",
				 "Ajnara Daffodil",
			 "Sikka Karnam Greens",
			 	 "VVIP Addresses ",
			
			
			 ];




/**
 * Since carousel.addItem uses an HTML string to create the interface
 * for each carousel item, this method formats the HTML for an LI.
 **/
var fmtItem = function(imgUrl, url, title) {

      var innerHTML = 
          '<a href="' + 
          url + 
          '"><img src="' + 
          imgUrl +
        '" width="' +
        150 +
        '" height="' +
        50+
        '"/>' + 
          title + 
          '<\/a>';
  
    return innerHTML;
    
};

/**
 * Custom inital load handler. Called when the carousel loads the initial
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadInitHandler
 **/
var loadInitialItems = function(type, args) {
    var start = 1;/**args[0]**/
    var last = 17; /**args[1]**/

    load(this, start, last);    
};

/**
 * Custom load next handler. Called when the carousel loads the next
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadNextHandler
 **/
var loadNextItems = function(type, args) {    

    var start = 1;/**args[0]**/
    var last = 17; /**args[1]**/
    var alreadyCached = args[2];
    
    if(!alreadyCached) {
        load(this, start, last);
    }
};

/**
 * Custom load previous handler. Called when the carousel loads the previous
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadPrevHandler
 **/
var loadPrevItems = function(type, args) {
    var start = 1;/**args[0]**/
    var last = 17; /**args[1]**/
    var alreadyCached = args[2];
    
    if(!alreadyCached) {
        load(this, start, last);
	}
};
    


var load = function(carousel, start, last) {

    for(var i=start; i<=last; i++) {
        carousel.addItem(i, fmtItem(imageList[i-1], imagelink[i-1], imgname[i-1]));
		    
}
};



/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the previous button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: prevButtonStateHandler
 **/
var handlePrevButtonState = function(type, args) {

    var enabling = 1;/**args[0]**/
    var leftImage = 17;/**args[1]**/
    if(enabling) {
        leftImage.src = "bottom-marquee/left-enabled.png";        
    } else {
        leftImage.src = "bottom-marquee/left-disabled.png";    
    }
    
};

/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the next button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: nextButtonStateHandler
 **/
var handleNextButtonState = function(type, args) {

    var enabling = 1;/**args[0]**/
    var rightImage = 17;/**args[1]**/
    if(enabling) {
        rightImage.src = "bottom-marquee/right-enabled.png";    
    } else {
        rightImage.src = "bottom-marquee/right-disabled.png";
    }
    
};

/**
 * You must create the carousel after the page is loaded since it is
 * dependent on an HTML element (in this case 'dhtml-carousel'.) See the
 * HTML code below.
 **/
var carousel; // for ease of debugging; globals generally not a good idea
var pageLoad = function() 
{
    carousel = new YAHOO.extension.Carousel("dhtml-carousel", 
        {
            numVisible:        5,
            animationSpeed:    1,
            animationMethod:   YAHOO.util.Easing.easeBoth,
            scrollInc:         3,
            navMargin:         30,
            size:              17,
            loadInitHandler:   loadInitialItems,
            prevElement:     "prev-arrow",
            nextElement:     "next-arrow",
            loadNextHandler:   loadNextItems,
            loadPrevHandler:   loadPrevItems,
            prevButtonStateHandler:   handlePrevButtonState,
            nextButtonStateHandler:   handleNextButtonState
        }
    );
};

YAHOO.util.Event.addListener(window, 'load', pageLoad);
