<!--

if(document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule){
	document.styleSheets[0].addRule('*', 'behavior: url(iepngfix.htc)');
}

var ready = false;
var TotalImg = 0; 
var CountTotalImg = 0; // just record the total number of images...
var ImgArray = new Array();
$(function(){
	// preloading images.
	$("img").each(function(){
		var s = $(this).attr("src");
		ImgArray[CountTotalImg++] = s;

		if($(this).hasClass("hover")){
			var s_hover = s.replace('_', '2_');
			ImgArray[CountTotalImg++] = s_hover;
		}
	});
	
	//additional images
	ImgArray[CountTotalImg++] = "images/bg1.jpg";
	ImgArray[CountTotalImg++] = "images/stripe.png";
	ImgArray[CountTotalImg++] = "images/index_10.jpg";
	ImgArray[CountTotalImg++] = "images/page2_10.jpg";

	TotalImg = CountTotalImg;
	$.each(ImgArray, function(i){
		$(new Image()).load(function(){
			TotalImg--;
			var percent = Math.round(((CountTotalImg - TotalImg) * 100) / CountTotalImg);
			if(TotalImg == 1) percent = 100;
			$("div#progressBar").width(percent * 2);
			$("div#precentage").text(percent + '%');
			if(TotalImg == 0){
				$("div#cover").show(); $("body").css("background","#230000 url(images/bg1.jpg) no-repeat scroll center top");
				$("div#loader-block").remove();
			}
		}).attr("src",ImgArray[i]);
	});
	// end of preloading images..
	
	// image hover effect.. isn't it simple than dreamweaver's boring hover script!
	// the trick is.. the normal image is image_2.jpg and the hover is image2_2.jpg.. so just replace _ with 2_  ;)
function activateHover(){
	$("img.hover").unbind();
	$("img.hover").hover(
		function(){
			if(!$(this).hasClass("active"))
				$(this).attr("src",$(this).attr("src").replace('_','2_'));
		},
		function(){
			if(!$(this).hasClass("active"))
				$(this).attr("src",$(this).attr("src").replace('2_','_'));
		}
	);
}
	activateHover();
	// active current link from loaction url
	var l = location.href.toString();
	var tmp = l.split('/');
	tmp.pop();
	var cur = tmp.pop();
try {
	$("img.hover").removeClass("active"); // only for live server
	$("a[href='/"+cur+"/']").find("img").addClass("active"); // only for live server
	$("img.active").attr("src",$("img.active").attr("src").replace('_','2_'));
} catch(e) {}
	$("a").focus(function(){this.blur();}); // removes that ugly border on focus.
	$("ul#top-menu li a:first").css("cursor","default").click(function(){return false;});
	$("a.ajax").click(function(){
		var p = $(this).attr("href").replace(/\//g,'');
		var lnk = "getContent.php?p="+p;
		var hover = $(this).find("img");
		if(hover.hasClass("active")){
			return false;
		} else {
			$("img.active").attr("src",$("img.active").attr("src").replace('2_','_'));
			$("img.hover").removeClass("active");
			hover.addClass("active");
			hover.attr("src",hover.attr("src"));
		}

		$.ajax({
			url: lnk,
			beforeSend: function(){
				$("div#dynamic").removeClass().addClass("commonbg").html('<div id="loading">Loading...</div>');
			},
			success: function(d){
				$("body").append('<div id="dummy">'+d+'</div>');
				var cntImg = $("#dummy img").length;
				if(cntImg){
					$("#dummy img").each(function(){
						$(new Image()).load(function(){
							cntImg--;
							if(cntImg == 0) { 
								$("div#dynamic").html(d);
								$("#dummy").remove();
								if(p == 'home'){
									$("div#dynamic").removeClass().addClass("homebg");
									window.setTimeout(activateHover,100); // home page has one hover img!! remember.. 
									//initiate validation
									//var sprytextfield1 = null;
									window.setTimeout(function(){
										var sprytextfield1e = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {hint:"email address", validateOn:["blur", "change"], isRequired:false});
									}, 50);
								} else if (p == 'contact'){
									$("form#contactForm").submit(function(){
										var s = $("form#contactForm").serialize();
										
										$.ajax({
											// validation
											beforeSend: function(){
												if($("form#contactForm input").val() == '' || $("form#contactForm textarea").val() == ''){
													alert("Name/Email/Message can not be empty!");
													return false;
												}
											},
											url: location.href.toString(),
											type: "POST",
											data: s,
											success: function(){
												$("form#contactForm").replaceWith("Thank you for your message!");
											}
										});
										return false;
									});
								}
							}
						}).attr('src',$(this).attr('src'));
					});
				} else {
					$("div#dynamic").html(d);
					$("#dummy").remove();
					if(p == 'home'){
						$("div#dynamic").removeClass().addClass("homebg");
						window.setTimeout(activateHover,100); // home page has one hover img!! remember.. ;
						//initiate validation
						//var sprytextfield1 = null;
						window.setTimeout(function(){
							var sprytextfield1e = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {hint:"email address", validateOn:["blur", "change"], isRequired:false});
						}, 50);
					} else if(p == 'events'){
									$("table#events tr:odd").hide();
									$("table#events tr:visible:even").css({backgroundColor:"#bfaa5b"});
	$("table#events tr:hidden:even").css({backgroundColor:"#bfaa5b"});
									$("table#events tr:even").css("cursor","pointer").toggle(function(){$(this).next().show();}, function(){$(this).next().hide();});
								}
				}
			}
		});
		return false;
	});
//initiate validation
try {
	var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {hint:"email address", validateOn:["blur", "change"], isRequired:false});
	$("form#contactForm").submit(function(){
		var s = $("form#contactForm").serialize();
		$.ajax({
			// validation
			beforeSend: function(){
				if($("form#contactForm input").val() == '' || $("form#contactForm textarea").val() == ''){
					alert("Name/Email/Message can not be empty!");
					return false;
				}
			},
			url: location.href.toString(),
			type: "POST",
			data: s,
			success: function(){
				$("form#contactForm").replaceWith("Thank you for your message!");
			}
		});
		return false;
	});

	$("table#events tr:odd").hide();
	$("table#events tr:visible:even").css({backgroundColor:"#bfaa5b"});
	$("table#events tr:hidden:even").css({backgroundColor:"#bfaa5b"});
	$("table#events tr:even").css({cursor:"pointer"}).toggle(function(){$(this).next().show();}, function(){$(this).next().hide();});
} catch(e){}
});
-->
