// JavaScript Document

///////////////////////// Clear TextBox ////////////////////////////
function prefillClear(field) 
{
 
if (field.defaultValue==field.value) 
{
	field.value = '';
}
 
else if (field.value == '') 
{
	field.value = field.defaultValue;
}
 
}






///////////////////////// Products ////////////////////////////
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#exslideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#exslideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#exslideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});






///////////////////////// Menu Silde ////////////////////////////
$(document).ready(function(){
	
	$("#menuWrap h4").eq(0).addClass("active");
	$("#menuWrap p").eq(0).show();

	$("#menuWrap h4").click(function(){
		$(this).next("p").slideDown("slow")
		.siblings("p:visible").hide("slow");
		$(this).toggleClass("active");
		$(this).siblings("h4").removeClass("active");
	});

});







///////////////////////// Tabs of Pool ////////////////////////////

function showTab(id){
	document.getElementById("tab_1").style.display = "none";
	document.getElementById("tab_2").style.display = "none";
	document.getElementById("tab_" + id).style.display = "block";
}

function changeImg(tab){
	switch (tab)
	{
		case "tab_1":
		document.getElementById("tab_1_inactive").style.display = "none";
		document.getElementById("tab_1_active").style.display = "block";
		document.getElementById("tab_2_inactive").style.display = "block";
		document.getElementById("tab_2_active").style.display = "none";
		break;
		case "tab_2":
		document.getElementById("tab_1_inactive").style.display = "block";
		document.getElementById("tab_1_active").style.display = "none";
		document.getElementById("tab_2_inactive").style.display = "none";
		document.getElementById("tab_2_active").style.display = "block";
		break;
		
	}
}






///////////////////////// Advertisment Silde ////////////////////////////
this.nav = function() {
	$("#nav a").css("display","none");
	$("#nav a").css("background-position","0 -69px");
	$("#nav li").css("cursor","pointer");
 	$("#nav li").hover(
      function(){
        $("a",this).fadeIn("fast");
      }, 
      function(){
        $("a",this).fadeOut("fast");
      }
    );	
};
this.slideshow = function(obj) {	
		//var obj = $("#templates");
		var s = $("li", obj).length;
		var w = obj.width(); 		
		var ts = s-1;
		var t = 0;
		$("ul", obj).css("width",s*w);
		$(obj).parent().append("<span class=\"prev\"><a href=\"javascript:void(0);\"></a></span> <span class=\"next\"><a href=\"javascript:void(0);\"></a></span>");
		
		$(".prev a", obj.parent()).hide();
		$(".next a", obj.parent()).click(function(){		
			animate("next");
			if (t>=ts) $(this).fadeOut();
			$(".prev a", obj.parent()).fadeIn();
		});
		$(".prev a", obj.parent()).click(function(){		
			animate("prev");
			if (t<=0) $(this).fadeOut();
			$(".next a", obj.parent()).fadeIn();
		});	
		this.animate = function(dir){
			if(dir == "next"){
				t = (t>=ts) ? ts : t+1;	
			} else {
				t = (t<=0) ? 0 : t-1;
			};		
			p = (t*w*-1);		
			$("ul",obj).animate(
				{ marginLeft: p }, 
				800
			);	
		};
		animate("next");
		$(".prev a", obj.parent()).fadeIn();
};
this.preview = function() {
	if(document.body.id == "preview"){		
		$("body").each(function(){
			h = $(window).height();
			w = $(window).width();		
				
		});	
	}
};

this.pngfix = function() {
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if (jQuery.browser.msie && (ie55 || ie6)) {		
		$("*").each(function(){
			var bgIMG = $(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				$(this).css('background-image', 'none');
				$(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			};
		});
	};		
};

this.init = function() {
	pngfix();
	//nav();	
	$("#templates").each(function(){	
		slideshow($(this));	
	});		
	preview();
};

$(document).ready(function(){	
	init();
});










///////////////////////// ToolTip ////////////////////////////
/*
 * 	Easy Tooltip 1.0 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
(function($) {

	$.fn.easyTooltip = function(options){
	  
		// default configuration properties
		var defaults = {	
			xOffset: -120,		
			yOffset: 225,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	  
	};

})(jQuery);


$(document).ready(function(){	
		$("a#contactUsOver").easyTooltip({
			useElement: "contectUsToolTip"				   
		});
	});

