/* Retailers */

	var retailers = [ 	
"online|cvs.png|http://www.cvs.com/CVSApp/search/search.jsp?searchTerm=minidrops&QP=N%3D92%26Ntk%3DAll%26Nty%3D1%26Ne%3D14%26Ntx%3Dmode+matchallpartial%26Nr%3DOR{92%2COR{93}%2COR{90}%2COR{122}}%26searchType%3DsearchHome&x=0&y=0|CVS/Pharmacy",
				 "online|amazon.png|http://www.amazon.com/Optics-Laboratory-Minidrops-Single-Use-Droppers/dp/B000GCNAHW/ref=sr_1_1?ie=UTF8&s=hpc&qid=1300199840&sr=1-1|Amazon",
				 "online|drugstore.png|http://www.drugstore.com/optics-laboratory-minidrops-eye-therapy-single-use-droppers/qxp94196?fromsrch=Minidrops+Eye+Therapy+SingleUse+Droppers++30+ea|Drugstore.com"
				 ];
	<!-- "kerrdrug.png|http://locator.kerrdrug.com/locator/store_locator.jsf" -->
	var cur;
	
	function getRandomRetailer() { 
		var toR,rand=cur;
		while(rand==cur) {rand=Math.floor(Math.random() * retailers.length); }
		cur = rand;
		return retailers[rand];
	}
	
	function displayRetailer(retailer) { 
		$('#rLogo').hide().prev().hide();
		$('#loader').show();
		$('#rLogo').html('');
		// var info = retailer.split('|'), lk = $('<a target="_blank"/>').attr('href',info[2]), img = $('<img/>').attr('src','_img/retailers/'+info[1]);
		var info = retailer.split('|'), lk = $('<span/>'), img = $('<img/>').attr('src','_img/retailers/'+info[1]);
		/*
		if(info[0]=='online') $('#rLogo').prev().html('purchase online at ');
		else 			  $('#rLogo').prev().html('purchase at ');
		*/
		img.appendTo(lk);
		lk.appendTo($('#rLogo'));
		$('#loader').fadeOut(300,function() {$('#rLogo').show().prev().show()});
	}
	
	function getNextRetailer() {
		(cur!=retailers.length-1)?cur++:cur=0;
		displayRetailer(retailers[cur]);
		return false;
	}	
	
	function getListOfRetailersWithLinks() {
		var ul = $('<ul style="text-align: left; width: 150px; margin-left:60px;"/>');	
		for(i=0;i<retailers.length;i++) {
				var info = retailers[i].split('|'), lk = info[2], name= info[3] ;
				//$('<li><a href="'+lk+'" target="_blank">'+name+'</a></li>').appendTo(ul);
				$('<li>'+name+'</li>').appendTo(ul);
		}
		return ul;	
	}
	
/**
 * @author Alexander Farkas
 * v. 1.02
 * [animate background for menu aniùmation]
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            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];

           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]];
           }
        }
	});
})(jQuery);	
	
/* Menu Animation */
$(function() {

	$('#mntm a')
		.filter(function(){return !$(this).hasClass('cur')})
		.css( {backgroundPosition: "-20px 37px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-20px 144px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(40px 37px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-20px 37px"})
			}})
		});
		
	






})
