var J = jQuery.noConflict();

J(document).ready(
	function()
	{
		bindEvents();
	}
);

function bindEvents()
{
	//toggle sitemap on "SiteMap" link click
	J('#sitemap-link').click(
		function ()
		{
			if(J('#nav').is(':visible'))
			{
				//J.scrollTo('-=1000px', {speed: 3000});
				J('#spacer').hide('slow');
				J('#nav').hide('slow');
			}
			else
			{
				J('#spacer').show('slow');
				J('#nav').show('slow');
				J.scrollTo('+=1000px', {speed: 3000});
			}
		}
	);

//        J('body').mousemove(
//            function( e ){
//J('#debug').html( e.currentTarget.className );
//                if( J(this).hasClass('digBroshure')) ){
//                    isAnimation = 1;
//                    J('#digDiv').animate({
//                        right: 30
//                      }, 2000, function() {
//                          isAnimation = 0;
//                    });
//                }
//            }
//        );
            var isAnimation = 0;
        J('#digDiv').hover( function(){
            if( isAnimation )
            {
//                J("#digDiv").clearQueue();
                J("#digDiv").stop();
            }
                isAnimation = 1;

                J('#digDiv').animate({
                    right: 16
                  }, 2000, function() {
                      isAnimation = 0;
                  });
            
        }, function(){//alert(this.tagName);
            if( isAnimation )
            {
//                J("#digDiv").clearQueue();
                J("#digDiv").stop();
            }

            isAnimation = 1;

            J('#digDiv').animate({
                right: -162
              }, 2000, function() {
                // Animation complete.
                isAnimation = 0;
              });
        } );
//
//        J(document).digBroshure( function(){alert(this.tagName);
//            if( ! J(this).hasClass('digBroshure') ) {
//                J(this).animate({
//                    right: -162
//                  }, 3000, function() {
//                    // Animation complete.
//                  });
//            }
//        } );
}

//GET FLASH MOVIE OBJECT
function thisMovie(movieName)
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function fillCountries() {
	var str = '';
	for ( var id in countries ) {
		str += '<option value='+id+'>'+countries[id].name+'</option>';
	}
	J('#countries').empty();
	J('#countries').append(str);
}

function fillStates( country_id ) {
	var str = '';
	for ( var id in countries[country_id].states ) {
		str += '<option value="'+id+'">'+countries[country_id].states[id].iso+'</option>';
	}
	J('#states').empty();
	J('#states').append(str);
}

function fillSeries(fid) 
{
	J('#'+fid).empty();
	
	var str = '<option value="0">Select Series</option>';
	for ( var id in series ) 
	{
		str += '<option value='+id+'>'+series[id].series_name+'</option>';
	}
	J('#'+fid).append(str);
}

function fillModels( mid, series_id ) 
{
	J('#'+mid).empty();
	
	var str = '<option value="0">Select Models</option>';
	for ( var id in series[series_id].models ) 
	{
		str += '<option value="'+id+'">'+series[series_id].models[id].name+'</option>';
	}
	J('#'+mid).append(str);
}

function fillCountriesSC() 
{
	var str = '';
	str += '<option value="226">United States</option>';
	str += '<option value="38">Canada</option>';
	
	J('#countries').empty();
	J('#countries').append(str);
}

