/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 10;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});


















function CountWords (this_field, show_word_count, show_char_count) 
{
				if (show_word_count == null) 
				{
					show_word_count = true;
				}
				
				if (show_char_count == null) 
				{
					show_char_count = false;
				}
				
				var char_count = this_field.value.length;
				var fullStr = this_field.value + " ";
				var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
				var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
				var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
				var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
				var splitString = cleanedStr.split(" ");
				var word_count = splitString.length -1;
				if (fullStr.length <2) 
				{
					word_count = 0;
				}
				
				if (word_count == 1) 
				{
					wordOrWords = " word";
				}
				else 
				{
					wordOrWords = " words";
				}
				
				if (char_count == 1) 
				{
				charOrChars = " character";
				} 
				else 
				{
				charOrChars = " characters";
				}

				if (show_word_count & show_char_count) 
				{ 
					alert ("Word Count:\n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars);
				}
				else 
				{
				
								if (show_word_count) 
								{
									alert ("Word Count:  " + word_count + wordOrWords);
								}
								else 
								{
									if (show_char_count) { alert ("Character Count:  " + char_count + charOrChars);	}
								 }
				}

}






function jumpy(fieldy,maxy,targy)
{
	if(fieldy.value.length==maxy)
	{
		
		targy.focus();
	}
}


function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
}
