// JavaScript Document
jQuery(function(){
			
  $('#social li img').each(function(){
		$(this).mouseover(function(){
    		$(this).attr("src",$(this).attr("src").replace('out','over'));
  		}).mouseout(function(){
    		$(this).attr("src",$(this).attr("src").replace('over','out'));
  		});
  });
	
  $('#menu ul li.Subcat').next().each(function(){
		$(this).css("border-top","1px dotted #565553");								   
	});
  $('#nav li').children("ul").css({
    display: "none"
  });
  $('#nav li').hover(function() {
    $(this)
      .children('ul')
      .stop(true, true)
      .slideDown('medium');
  }, function() {
    $(this)
      .find('ul')
      .stop(true,true)
      .css('display','none');
  });
jQuery.preloadImages(
		"images/logo.gif"
);

$("#menu > li:first").find("a").css({"border" : "none"});
$("#nav > li:last").find("a").css({"border" : "none"});
$("#content > div.latest:odd").css({"margin-right" : "0"});	
$("#footer dl:last").css({"margin-right" : "0"});

	$("#printversion").click(function(){
		$("#printlogo").remove();
		$("#header").append("<img src='images/logo.gif' id='printlogo' />");
		print();
	});
});
(function($) {
  var cache = [];
  $.preloadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);

// Remove border from header menu first item
function MkAlias(Src,Trgt)
{
	$('#'+Trgt).val($('#'+Src).val().toLowerCase().replace(' ','-'));
}

function ValidateSubscribe(ObjID){
var error = "";

var strSearch = document.getElementById(ObjID).value;

		if(strSearch.trim() == "" || strSearch.trim().length < 4){
			error = "Please enter a email address.";
		}
		else if(IsValidEmail(strSearch) == false) {
      		error = 'Invalid Email Address';
      		return false;
   		}		
		if(error){
			alert(error);
			return false;
		}
return true;
}

function ValidateSearch(ObjID){
	var error = "";
	var strSearch = document.getElementById(ObjID).value;
	if(strSearch.trim() == "" || strSearch.trim().length < 4){
		error = "Please enter a atleast 4 characters for your search.";
	}		
	if(error){
		alert(error);
		return false;
	}
	return true;
}


function ValidateTAF(){
	var error = "";
	var fromName = $('#Name').val();
	var fromEmail = $('#Email').val();
	var fromEmail1 = $('#Email1').val();
	var fromEmail2 = $('#Email2').val();
	var fromEmail3 = $('#Email3').val();
	
	
	if(fromName.trim() == "" || fromName.trim().length < 4){
		error += "Please enter a atleast 4 characters for your name.\n";
	}	
	if(fromEmail.trim() == "" || fromEmail.trim().length < 4){
		error += "Please enter your email address.\n";
	}else if(IsValidEmail(Email) == false){
		error += "Your email address seems invalid, Please provide correct email address.\n";
	}	
	if(fromEmail1.trim() == "" || IsValidEmail(fromEmail1) == false){
		error += "Your friend(1) email is empty/invalid, Please provide correct email address.\n";
	}	
	if(fromEmail2.trim() != "" && IsValidEmail(fromEmail2) == false){
		error += "Your friend(2) email is invalid, Please provide correct email address.\n";
	}	
	if(fromEmail3.trim() != "" && IsValidEmail(fromEmail3) == false){
		error += "Your friend(3) email is invalid, Please provide correct email address.\n";
	}		
	
	if(error){
		alert(error);
		return false;
	}
	return true;
}

function IsValidEmail(Email){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;	
	if(reg.test(Email) == false) {
      		return false;
   	}
	return true;
}


 function HideLoading(){	 
	$('#ov-main').remove();
 }
 function ShowLoading(){
  	$('<div id="ov-main"><div id="ov-bg" onclick="HideLoading();"></div><div id="ov-contents"></div></div>').appendTo('body');
	
	$('#ov-main').css("display","block");
	$('#ov-main').css("position","fixed");
	$('#ov-main').css("top","0");	
	$('#ov-main').css("left","0");
	$('#ov-main').css("width","100%");	
	$('#ov-main').css("height","100%");
	$('#ov-main').css("z-index","40000");

	$('#ov-bg').css("width","100%");	
	$('#ov-bg').css("height","100%");
	$('#ov-bg').css("background-color","#FFFFFF");
	$('#ov-bg').css("opacity","0.8");				
			
	$('#ov-contents').css("position","absolute");
	$('#ov-contents').css("text-align","center");
	$('#ov-contents').css("opacity","1.0");
	$('#ov-contents').css("top", (($(window).height() - $('#ov-contents').outerHeight()) / 2) + $(window).scrollTop() + "px");
	$('#ov-contents').css("left", (($(window).width() - $('#ov-contents').outerWidth()) / 2) + $(window).scrollLeft() + "px");		
	$('<div>Please wait....</div><img id="ov-img" src="../images/loading.gif" alt="Loading..." />').appendTo('#ov-contents');
 }

$(window).load(function(){
	if($("#main #menu").height() < $("#main #content").height() || $("#main #menu").height() < $("#main .column").height()){
		$("#main #menu").animate({
			height : ($("#main #content").height() < $("#main .column").height()) ? $("#main .column").height() : $("#main #content").height()
		}, 2000, 'swing');
	}						  
});


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}
function trim(str) 
{
	return str.replace(/^\s*|\s*$/g,"");
}

