function setFocus() { if (document.loginForm.username) {document.loginForm.username.select(); document.loginForm.username.focus();} }
function setFocusTrans() { if (document.transform.oURL) {document.transform.oURL.select(); document.transform.oURL.focus();} }

function PostToTwitter(){ var text = $("#ToTwitter").val(); location.href="http://twitter.com/home?status="+text;}


function doTransform(affNT) { //var resDiv; resDiv = affNT.toUpperCase()+"UP";

  $('#urlForm').validate(); if ( $('#urlForm').valid() ) {

  $("#ajax-load").show();  $("#res").html(''); var oURL = escape($("#longUrl").val()); var userID=""; userID = $("#userID").val(); alert(userID);
  $.post("/get.php", {url: oURL, uid: userID},
    function(data){ returned = data.split("+");   var affNT; var elig=""; isElig =  returned[1]; var userID=""; userID = $("#userID").html();      
       if (isElig==1) {elig = "<div class=\"eligLink\"><br/>* This link is eligible for rewards.";
       if (userID!="") elig = elig + " Please<a href=\"signup.html\">Sign Up</a>or<a href=\"login.html\">Login</a>to start getting paid</div>"; 
         else elig = elig + "</div>";       
       }
       var twitt = "<br/><div class=\"bar\"><h3><label class=\"doing\" for=\"ToTwitter\">Post to Twitter:</label></h3><span class=\"numeric\" id=\"chars_left_notice\"><strong class=\"char-counter\" id=\"ToTwitterCnt\" style=\"color: rgb(204, 204, 204);\">140</strong></span></div><div class=\"info\"><textarea tabindex=\"1\" autocomplete=\"off\" name=\"ToTwitter\" id=\"ToTwitter\" rows=\"2\" cols=\"40\">"+returned[0]+"</textarea><div class=\"status-btn\"><input type=\"submit\" tabindex=\"2\" class=\"status-btn round-btn disabled\" id=\"ToTwitterPost\" value=\"Post to Twitter\" name=\"ToTwitterPost\" onClick=\"PostToTwitter(); return false;\"/></div></div><script language=\"Javascript\">$(\"#ToTwitter\").charCounter(140, {container: \"#ToTwitterCnt\"});</script><span class=\"sn\"><hr noshadow/><br/>Share:&nbsp;&nbsp;<a target=\"_blank\" href=\"http://www.facebook.com/sharer.php?u="+returned[0]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh6.ggpht.com/_u4gySN2ZgqE/StWBRx3pPJI/AAAAAAAAA30/ibp8P4sWWog/facebook_16_thumb.png\"/>&nbsp;Facebook</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://twitter.com/?status="+returned[0]+"\"><img border=\"0\" src=\"http://lh6.ggpht.com/_u4gySN2ZgqE/StWBiO6g_0I/AAAAAAAAA40/CLxmC7qBy1M/twitter_16_thumb.png\"/>&nbsp;Twitter</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://www.stumbleupon.com/submit?url="+returned[0]+"&amp;title="+returned[2]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh6.ggpht.com/_u4gySN2ZgqE/StWBd1gRzRI/AAAAAAAAA4k/e6BCij0UJTY/stumbleupon_16_thumb.png\"/>&nbsp;StumbleUpon</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://del.icio.us/post?url="+returned[0]+"&amp;title="+returned[2]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh3.ggpht.com/_u4gySN2ZgqE/StWBoBpBJOI/AAAAAAAAA5M/3SJnoMwKm64/delicious_16_thumb%5B1%5D.png\"/>&nbsp;Del.icio.us</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://reddit.com/submit?url="+returned[0]+"&amp;title="+returned[2]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh5.ggpht.com/_u4gySN2ZgqE/StWBaAlz5MI/AAAAAAAAA4U/DGi1_wSfILA/reddit_16_thumb.png\"/>&nbsp;Reddit</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://digg.com/submit?phase=3&amp;url="+returned[0]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh6.ggpht.com/_u4gySN2ZgqE/StWBP60xzPI/AAAAAAAAA3s/LdvUYX8Md58/digg_alt_16_thumb.png\"/>&nbsp;Digg</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://www.google.com/bookmarks/mark?op=add&amp;bkmk="+returned[0]+"&amp;title="+returned[2]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh4.ggpht.com/_u4gySN2ZgqE/StWBWL6uQEI/AAAAAAAAA4E/QwUyagFuuv0/google_16_thumb.png\"/>&nbsp;Google</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://myweb2.search.yahoo.com/myresults/bookmarklet?u="+returned[0]+"&amp;title="+returned[2]+"\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh4.ggpht.com/_u4gySN2ZgqE/StWBkW79O8I/AAAAAAAAA48/gignTnJLVos/yahoo_16_thumb.png\"/>&nbsp;Yahoo</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"{$email}\"><img width=\"16\" height=\"16\" border=\"0\" src=\"http://lh5.ggpht.com/_u4gySN2ZgqE/StWD4W5eOqI/AAAAAAAAA5U/ST9cOuI_UT8/email_16_thumb%5B1%5D.png\" alt=\"Email\"/>&nbsp;Email</a></span>";
       $("#res").html('Your short URL: <a href="'+returned[0]+'">'+returned[0]+'</a>'+elig+twitt);  $("#res").slideDown("normal"); $("#ajax-load").hide(); 
      }, "html");  
  }    
}

jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) jQuery("<img>").attr("src", arguments[i]);
}
jQuery.preloadImages("key.gif", "keyo.gif", "rss.gif", "rsso.gif", "sel.gif", "selo.gif");

jQuery(document).ready(function(){	
	$("#iconbar li a").hover(
		function(){
			var iconName = $(this).children("img").attr("src");
			var origen = iconName.split(".gif")[0];
			$(this).children("img").attr({src: "" + origen + "o.gif"});
			$(this).css("cursor", "pointer");
			$(this).animate({ width: "140px" }, {queue:false, duration:"normal"} );
			$(this).children("span").animate({opacity: "show"}, "fast");
		}, 
		function(){
			var iconName = $(this).children("img").attr("src");
			var origen = iconName.split("o.")[0];
			$(this).children("img").attr({src: "" + origen + ".gif"});			
			$(this).animate({ width: "24px" }, {queue:false, duration:"normal"} );
			$(this).children("span").animate({opacity: "hide"}, "fast");
		});
});


/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
 
(function($) {
	/**
	 * attaches a character counter to each textarea element in the jQuery object
	 * usage: $("#myTextArea").charCounter(max, settings);
	 */
	
	$.fn.charCounter = function (max, settings) {
		max = max || 100;
		settings = $.extend({
			container: "<span></span>",
			classname: "charcounter",
			format: "%1",
			pulse: true,
			delay: 0
		}, settings);
		var p, timeout;
		
		function count(el, container) {
			el = $(el);
			if (el.val().length > max) {
			    el.val(el.val().substring(0, max));
			    if (settings.pulse && !p) {
			    	pulse(container, true);
			    };
			};
			if (settings.delay > 0) {
				if (timeout) {
					window.clearTimeout(timeout);
				}
				timeout = window.setTimeout(function () {
					container.html(settings.format.replace(/%1/, (max - el.val().length)));
				}, settings.delay);
			} else {
				container.html(settings.format.replace(/%1/, (max - el.val().length)));
			}
		};
		
		function pulse(el, again) {
			if (p) {
				window.clearTimeout(p);
				p = null;
			};
			el.animate({ opacity: 0.1 }, 100, function () {
				$(this).animate({ opacity: 1.0 }, 100);
			});
			if (again) {
				p = window.setTimeout(function () { pulse(el) }, 200);
			};
		};
		
		return this.each(function () {
			var container = (!settings.container.match(/^<.+>$/)) 
				? $(settings.container) 
				: $(settings.container)
					.insertAfter(this)
					.addClass(settings.classname);
			$(this)
				.bind("keydown", function () { count(this, container); })
				.bind("keypress", function () { count(this, container); })
				.bind("keyup", function () { count(this, container); })
				.bind("focus", function () { count(this, container); })
				.bind("mouseover", function () { count(this, container); })
				.bind("mouseout", function () { count(this, container); })
				.bind("paste", function () { 
					var me = this;
					setTimeout(function () { count(me, container); }, 10);
				});
			if (this.addEventListener) {
				this.addEventListener('input', function () { count(this, container); }, false);
			};
			count(this, container);
		});
	};

})(jQuery);



