$(document).ready(function(){


	$('input[title!=""]').hint();
	
	equalHeight($(".page-col"));
	
	var i = 0;
	$('ul.skewed-list li').each(function(index) {
		//alert(index + ': ' + $(this).text());
		$(this).css({marginLeft:i});
		i+=3;
	});
	
	//$('.nav-btn').click(function(){mclick.play();});
	
	
	
	$('.nav-btn').hover(function(){
		mrollover.play();
		var xy = $(this).bpos().split(" ");
		$(this).stop().animate({backgroundPosition:"("+xy[0]+" -80px)"}, {duration:150})
	},function(){
		mrollover.play();
		var xy = $(this).bpos().split(" ");
		$(this).stop().animate({backgroundPosition:"("+xy[0]+" 0)"}, {duration:150})
	  	
	});
	$('.nav-sale').hover(function(){
		mrollover.play();
		var xy = $(this).bpos().split(" ");
		$(this).stop().animate({backgroundPosition:"("+xy[0]+" -92px)"}, {duration:150})
	},function(){
		mrollover.play();
		var xy = $(this).bpos().split(" ");
		$(this).stop().animate({backgroundPosition:"("+xy[0]+" 0)"}, {duration:150})
	  	
	});
	
	
	$('.rollover').hover(function(){
		$(this).toggleClass('rolledOver');
	});
	
	try{
		DD_belatedPNG.fix('.png');
	}catch(e){
	}
	
	ddsmoothmenu.init({
		mainmenuid: "smoothmenu1", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
	
	ddsmoothmenu.init({
		mainmenuid: "smoothmenu2", //Menu DIV id
		orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
		//customtheme: ["#804000", "#482400"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})


});

soundManager.debugMode = false;
soundManager.url = 'swf/';
soundManager.useFlashBlock = false;

var pageOpen;
var mrollover;
var mclick;
soundManager.onready(function() {
	pageOpen = soundManager.createSound({
		id: 'pageOpen',
		url: 'audio/page-open.mp3'
	});
	mrollover = soundManager.createSound({
		id: 'mrollover',
		url: 'audio/rollout.mp3'
	});
	mclick = soundManager.createSound({
		id: 'mclick',
		url: 'audio/click.mp3'
	});
	pageOpen.play();
});
	
function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}


(function($) {
  jQuery.fn.bpos = function() {
    var p = $(this).css('background-position');
    if(typeof(p) === 'undefined') return $(this).css('background-position-x') + ' ' + $(this).css('background-position-y');
    else return p;
  };
})(jQuery);


/**
 * @author Alexander Farkas
 * v. 1.21
 */
(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
	
	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			
			fx.start = [start[0],start[2]];
			
			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);

/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/

(function ($) {

$.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'blur';
  }
    
  return this.each(function () {
    // get jQuery version of 'this'
	
    var $input = $(this),
    
    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = $(this.form),
      $win = $(window);

	

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title
      
      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};

})(jQuery);
