/*
 * @author Ruben
 * Synpro Development
 */
var $j = jQuery.noConflict();

Cufon.replace('h5');

$j(window).load( function() {
	$j("a img").fadeTo("fast", 1.0); // This sets the opacity of the thumbs to 100% when the page loads

	$j("a img").hover( function() {
		$j(this).fadeTo("fast", 0.7); // This should set the opacity to 70% on hover
	}, function() {
		$j(this).fadeTo("fast", 1.0); // This should set the opacity back to 100% on mouseout
	});
	
// remove link hover on home slider
	$j('#featured a img').unbind('mouseenter mouseleave');

	
	$j('#featured').orbit();
	$j('.brand_rotator').orbit( {  
	        animation: 'horizontal-push', 		// fade, horizontal-slide, vertical-slide, horizontal-push
	        animationSpeed: 600, 				// how fast animtions are
	        timer: true, 						// true or false to have the timer
	        advanceSpeed: 4000, 				// if timer is enabled, time between transitions 
	        pauseOnHover: false, 				// if you hover pauses the slider
	        startClockOnMouseOut: false, 		// if clock should start on MouseOut
	        startClockOnMouseOutAfter: 1000, 	// how long after MouseOut should the timer start again
	        directionalNav: false, 				// manual advancing directional navs
	        captions: false, 					// do you want captions?
	        captionAnimation: 'fade', 			// fade, slideOpen, none
	        captionAnimationSpeed: 600, 		// if so how quickly should they animate in
	        bullets: false,						// true or false to activate the bullet navigation
	        bulletThumbs: false,				// thumbnails for the bullets
	        afterSlideChange: function(){} 		// empty function 
	 	});
	 	
	 $j('.timer').hide();
	
	
});

/*
 *  Dealer JS
 * 
 */

$j( function() {
	$j(".hiddensubmit").hide();
	$j( ".submitbutton" ).button({
		icons: {
			primary: "ui-icon-search"
		}
	});
	$j(function() {
		$j('.tooltip').tipsy({fade: true, gravity: "w"});
		$j('.tooltip_e').tipsy({fade: true, gravity: "e"});
	});
	
	$j("button").each(function(index, obj) { 
		 var text=true;
		 if ($j(obj).attr('text')!==undefined && $j(obj).attr('text') == 'false') {
		 	text=false; 
		 }
		 var icons = {};
		 if ($j(obj).attr('icon')!==undefined) {
		 	icons['primary'] = "ui-icon-"+$j(obj).attr('icon'); 
		 }
		 if ($j(obj).attr('icon_right')!==undefined) {
		 	icons['secondary'] = "ui-icon-"+$j(obj).attr('icon_right'); 
		 }
		 $j(obj).button({icons:icons, text: text});
		 $j(obj).click(function() {  
		 	if ($j(obj).attr('link') !== undefined) {
		 		window.location.href=$j(obj).attr('link');
		 	} 
		 });
	});
		// if ($(this).attr('icon')!==undefined) {
	$j('.ui-icon-locked').parent().hover(
		function(){$j(':first-child', this).removeClass("ui-icon-locked"); $j(':first-child', this).addClass("ui-icon-unlocked");},
		function(){$j(':first-child', this).removeClass("ui-icon-unlocked"); $j(':first-child', this).addClass("ui-icon-locked");}
	);
	
	$j(".bigbuttonset").buttonset();
	// $j(".bigbuttonset:even").fadeTo(0, 0.6);
	
	
	// $j('.bigbuttonset a').css({ 'padding-top': '4px', 'padding-bottom': '4px' });
	// $j('.bigbuttonset span').css({ 'line-height': '16px' });
	// $j('.bigbuttonset button').css({ 'height': '20px' });
	// $j('.bigbuttonset .ui-button-text-only .ui-button-text').css({ 'padding': '4px 0 4px 0' });

	// $j(".ico_edit").button({icons:{primary: "ui-icon-wrench"},text:false});	
	// $j(".ico_link").button({icons:{primary: "ui-icon-link"}});	
	// $j(".ico_add").button({icons:{primary: "ui-icon-plus"},text:false});	
	
	$j(".search_input").addClass("ui-corner-left");
	$j("#id_q").addClass("ui-corner-left");
	$j(".submitbutton").removeClass("ui-corner-all");
	$j(".submitbutton").addClass("ui-corner-right");
	$j("#login_form input").addClass("ui-corner-all");
	
	$j(".submitbutton_top").click( function() {
	$j("#search_top").submit();
	});
	
	// $j("img").addClass("ui-corner-all");
	// $j("hr").addClass("ui-corner-allb");
	// $j(".rotator_img1 img").removeClass("ui-corner-all");
	// $j(".rotator_img2 img").removeClass("ui-corner-all");
	// $j(".rotator_img3 img").removeClass("ui-corner-all");
	// $j(".rotator_img1 img").addClass("ui-corner-top");
	// $j(".rotator_img3 img").addClass("ui-corner-bottom");
	// $j(".luxe_logo").removeClass("ui-corner-all");
	// $j(".luxe_logo").addClass("ui-corner-bottom");
	
	
});


/*
 Copyright (c) 2010 Don Magee
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the "Software"), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:
 
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 
 Table rounded corners
 */
 
(function($j){
    $j.fn.tableCorners = function(options) {
 
        var defaults = {
            collapse: true,
            thead: true,
            tbody: true,
            tfoot: false,
            radius: '4px'
        };
        var options = $j.extend(defaults, options);
 
        return this.each(function() {
            obj = $j(this);
            $j(this).css('-moz-border-radius', options.radius);
            $j(this).css('-webkit-border-radius', options.radius);
            if(options.collapse)
            {
                obj.attr('cellspacing', '0');
            }
            if(options.thead)
            {
                $j(obj).find('thead tr:first th:first').css('-moz-border-radius-topleft', options.radius);
                $j(obj).find('thead tr:first th:first').css('-webkit-border-top-left-radius', options.radius);
                $j(obj).find('thead tr:first th:last').css('-moz-border-radius-topright', options.radius);
                $j(obj).find('thead tr:first th:last').css('-webkit-border-top-right-radius', options.radius);
            }
            if(options.tbody)
            {
                if(!options.thead)
                {
                    $j(obj).find('tbody tr:first td:first').css('-moz-border-radius-topleft', options.radius);
                    $j(obj).find('tbody tr:first td:first').css('-webkit-border-top-left-radius', options.radius);
                    $j(obj).find('tbody tr:first td:last').css('-moz-border-radius-topright', options.radius);
                    $j(obj).find('tbody tr:first td:last').css('-webkit-border-top-right-radius', options.radius);
                }
                if(!options.tfooter)
                {
                    $j(obj).find('tbody tr:last td:first').css('-moz-border-radius-bottomleft', options.radius);
                    $j(obj).find('tbody tr:last td:first').css('-webkit-border-bottom-left-radius', options.radius);
                    $j(obj).find('tbody tr:last td:last').css('-moz-border-radius-bottomright', options.radius);
                    $j(obj).find('tbody tr:last td:last').css('-webkit-border-bottom-right-radius', options.radius);
                }
            }
            if(options.tfoot)
            {
                $j(obj).find('tfoot tr:last td:first').css('-moz-border-radius-bottomleft', options.radius);
                $j(obj).find('tfoot tr:last td:first').css('-webkit-border-bottom-left-radius', options.radius);
                $j(obj).find('tfoot tr:last td:last').css('-moz-border-radius-bottomright', options.radius);
                $j(obj).find('tfoot tr:last td:last').css('-webkit-border-bottom-right-radius', options.radius);
            }
            if(!options.tbody && !options.thead && !options.tfoot)
            {
                $j(obj).find('tr:first td:first').css('-moz-border-radius-topleft', options.radius);
                $j(obj).find('tr:first td:first').css('-webkit-border-top-left-radius', options.radius);
                $j(obj).find('tr:first td:last').css('-moz-border-radius-topright', options.radius);
                $j(obj).find('tr:first td:last').css('-webkit-border-top-right-radius', options.radius);
                $j(obj).find('tr:last td:first').css('-moz-border-radius-bottomleft', options.radius);
                $j(obj).find('tr:last td:first').css('-webkit-border-bottom-left-radius', options.radius);
                $j(obj).find('tr:last td:last').css('-moz-border-radius-bottomright', options.radius);
                $j(obj).find('tr:last td:last').css('-webkit-border-bottom-right-radius', options.radius);
            }
        });
    };
})(jQuery);


/*
 * Tables rounded corners
 */
$j(document).ready(function(){
	$j("table").tableCorners({
	  collapse: true,
	  thead: false,
	  tbody: true,
	  tfoot: false,
	  radius: '4px'
	});
});
