/*
a00v1.js
$Revision: 1.1.2.5.2.2 $
JS Functions for the buttons.
(c) 1992-2009 Cisco Systems, Inc. All rights reserved. 
Terms and Conditions: http://cisco.com/en/US/swassets/sw293/sitewide_important_notices.html
*/

//
// ** {{{ object creation }}} **
//
// Helper function for namespace.
cdc.util.ensureNamespace('cdc.cl.a00v1-pilot');
 
// ** {{{ ready event }}} **
//
// On Page Load
jQuery(function(){	/* jQuery onload function starts here */

 /* IE6 Pixel Fix - Doesn't like ODD width buttons */
    if (typeof document.body.style.maxHeight === "undefined") { /* if ie6, hard coded values inorder to achieve corner alignment */
        jQuery('.a00v1-pilot').each(function(){ /* for each button */
            if (jQuery(this).width()%2 == 1) {/* if width is even */
                var ieAdjustWidth = jQuery(this).width()+13+'px'; /* add padding + 13px to width */
            }
			else if (jQuery(this).width()%2 != 1) {/* Added to fix 1px alignment issue for bottom right span (having class a00v1-pilot-br) */
                var ieAdjustWidth = jQuery(this).width()+12+'px'; /* add padding + 12px to width */
            }
            jQuery(this).width(ieAdjustWidth); /* set new width */
      });
   }

   jQuery('.a00v1-pilot').addClass('a00v1-pilot-js');

	// Loop for the components.
	jQuery('.a00v1-pilot').each(function(){	 /* Loop for all the anchor button components starts here */

		// adds 3 span tags inside each button anchor.
		var linkText=jQuery(this).html(); /* anchor text saved in linkText variable */
		// replacing the anchor text with spans and the linkText data
		jQuery(this).empty()
					.append('<span class="a00v1-pilot-tl"></span>')
					.append(linkText)
					.append('<span class="a00v1-pilot-bl"></span>')
					.append('<span class="a00v1-pilot-br"></span>');
		

		// Disable the button
		this.a00v1_pilot_disable = function(){		
			//Add class a00v1-pilot-disabled to anchor for normal(js-enabled) scenario
			//Add class x1-disabled to anchor for non-js scenario
			jQuery(this).addClass('a00v1-pilot-disabled');
			//Disables the href using click functionality
			jQuery(this).bind("click",function(){return false;});
		}

		// Enables the button.
		this.a00v1_pilot_enable = function(id){
			//Remove classes a00v1-pilot-disabled(for js-enabled), x1-disabled(for non-js) from anchor object to enable the button
			jQuery(this).removeClass('a00v1-pilot-disabled');	
			//unbinds click from anchor object to enable the href
			jQuery(this).unbind("click");
		}

		//Disables all the anchor buttons with class "a00v1-pilot-disabled x1-disabled"
		if(jQuery(this).hasClass('a00v1-pilot-disabled')){
			//Disable function call with the perameter current anchor object
			this.a00v1_pilot_disable(this.id);
		}

	}); /* Loop for all the anchor button components ends here */

}); /* jQuery onload function ends here */
