function isEmail(str) {
	  var supported = 0;
	  if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	  }
	  if (!supported) 
	  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	  return (!r1.test(str) && r2.test(str));
}

function goPage(url)
{
	window.location.href= url;
}

function getCalendar(num){
	$.ajax({
		  type: 'POST',
		  url: '../cmsengine/lib/ajaxdata.php',
		  data: {action:'calendar',num:num},
		  success: function(r){
			 $("#showCalendar").html(r);
		  }
	});
}

function showSideMenu(id){
	$(".submenu_"+id).toggle();
	$.ajax({
		  type: 'POST',
		  url: '../cmsengine/lib/ajaxdata.php',
		  data: {action:'listmenu',id:id}
	});
}

function showContentLab(id){
	$('div[class^="listLab_"]').each(function(){
		$(this).hide();	
	});
	$(".listLab_"+id).show();
}

function toSearch(){
	var Url = "../Search/index.php?menuName=search&SearchType="+$('#SearchType').val();
	Url += "&txtSearch="+ $("#tsearch").val();
	if($("#tsearch").val()!=""){
		window.location.href = Url;
	}
}

function saveDownload(file){
	var Url = '../home/download.php?file=' + file;
	window.location.href = Url;
}

$(document).ready(function(){
	/*  Start Up Script*/	
	
	$("#tsearch").keyup(function(e){
		if(e.keyCode == '13') toSearch();
	});
	
	$('img').each(function(){
		$(this).error(function(){
			$(this).attr("src","../images/noimages.jpg");	
		});	
	});
	
	getCalendar(0);
	
	$("#tabs").tabs();
									   
	$("a[rel*='prettyPhoto']").prettyPhoto();
	
});
