$(function(){

	$(this).bind("contextmenu", function(e) {
                //e.preventDefault();
    });
	
	/** Rounded corners **/
	$('.rounded').each(function() {
		var t = $(this).corner("5px");
		eval(t);
	});
	$('.rounder').each(function() {
		var t = $(this).corner("8px");
		eval(t);
	});
	
	
	// tooltip //
	$('.south').tipsy({html:true, gravity: 's'});
	
	
	/** Btn mouseover **/
	$(".png").hover(function(){
		$(this).attr("src","tpl/files/images/btn"+$(this).attr("title")+"_hover.png");
	});
	$(".png").mouseout(function(){
		$(this).attr("src","tpl/files/images/btn"+$(this).attr("title")+".png");
	});
	
	$(".gif").hover(function(){
		$(this).attr("src","tpl/files/images/btn"+$(this).attr("title")+"_hover.gif");
	});
	$(".gif").mouseout(function(){
		$(this).attr("src","tpl/files/images/btn"+$(this).attr("title")+".gif");
	});
	
	$(".jpg").hover(function(){
		$(this).attr("src","tpl/files/images/btn"+$(this).attr("title")+"_hover.jpg");
	});
	$(".jpg").mouseout(function(){
		$(this).attr("src","tpl/files/images/btn"+$(this).attr("title")+".jpg");
	});
	
	
	$(".txtSearch").click(function(){
		
		if($(this).val() == "Type keywords and press Enter")
		$(this).val("");
	});
	$(".txtSearch").blur(function(){
		
		if($(this).val() == "")
		$(this).val("Type keywords and press Enter");
	});
	
	$("#txtName").click(function(){
		
		if($(this).val() == "Enter your full name")
		$(this).val("");
	});
	$("#txtName").blur(function(){
		
		if($(this).val() == "")
		$(this).val("Enter your full name");
	});
	$("#txtEmail").click(function(){
		
		if($(this).val() == "Enter your email address")
		$(this).val("");
	});
	$("#txtEmail").blur(function(){
		
		if($(this).val() == "")
		$(this).val("Enter your email address");
	});
	
	$("#frmSubscribe").submit(function() {
		
		$(".error").hide();
		var name = $("#txtName").val();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailblockReg =
		 /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/;
	 
		var emailaddressVal = $("#txtEmail").val();
		if(emailaddressVal == '') {
		  $("#txtEmail").after('<span class="error">Please enter your email address.</span>');
		  hasError = true;
		}
	 
		else if(!emailReg.test(emailaddressVal)) {
		  $("#txtEmail").after('<span class="error">Enter a valid email address.</span>');
		  hasError = true;
		}
		
		if(name == "Enter your full name") {
		  $("#txtName").after('<span class="error">Enter your full name</span>');	
		}
	 
		if(hasError == true) { return false; }
	 
	});
	
	$("#frmInform").submit(function() {
		
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailblockReg =
		 /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/;
	 
		var emailaddressVal = $("#txtEmail2").val();
		if(emailaddressVal == '') {
		  $("#btnInform").after('<span class="error">&nbsp; Please enter your email address.</span>');
		  hasError = true;
		}
	 
		else if(!emailReg.test(emailaddressVal)) {
		  $("#btnInform").after('<span class="error">&nbsp; Enter a valid email address.</span>');
		  hasError = true;
		}
		
	 
		if(hasError == true) { return false; }
	 
	});
	
	
	$("#frmDownload").submit(function() {
		
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailblockReg =
		 /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/;
	 
	 	var name = $("#txtDName").val();
		var emailaddressVal = $("#txtDEmail").val();
		if(emailaddressVal == '') {
		  $("#txtDEmail").after('<br /><span class="error">&nbsp; Please enter your email address.</span>');
		  hasError = true;
		}
	 
		else if(!emailReg.test(emailaddressVal)) {
		  $("#txtDEmail").after('<br /><span class="error">&nbsp; Enter a valid email address.</span>');
		  hasError = true;
		}
		
		if(name == '') {
			$("#txtDName").after('<br /><span class="error">&nbsp; Please enter your name.</span>');
		  	hasError = true;
		}
	 
		if(hasError == true) { return false; }
	 
	});
	
	
	// main tabs //
	$(".link").click(function(){
		var id = $(this).attr("id");
		var alt = $(this).attr("alt");
		
		var vars = {
            currentSlide: 0,
            currentImage: '',
            totalSlides: 0,
            randAnim: '',
            running: false,
            paused: false,
            stop:false
        };
		
		$("#slideshow1").css("display", "none");
		$("#slideshow2").css("display", "none");
		$("#slideshow3").css("display", "none");
		$("#slideshow4").css("display", "none");
		$("#slideshow5").css("display", "none");
		$("#slideshow6").css("display", "none");
		
		$(".tab1").attr("src", "tpl/files/images/btn/highlight_unirazak.png");
		$(".tab2").attr("src", "tpl/files/images/btn/highlight_bank.png");
		$(".tab3").attr("src", "tpl/files/images/btn/highlight_razak.png");
		$(".tab4").attr("src", "tpl/files/images/btn/highlight_graduate.png");
		$(".tab5").attr("src", "tpl/files/images/btn/highlight_centre.png");
		$(".tab6").attr("src", "tpl/files/images/btn/highlight_pintar.png");
		
		$("#tab1").attr("class", "tab link");
		$("#tab2").attr("class", "tab link");
		$("#tab3").attr("class", "tab link");
		$("#tab4").attr("class", "tab link");
		$("#tab5").attr("class", "tab link");
		$("#tab6").attr("class", "tab link");
		
		
		
		$("#slideshow"+id.substring(3)).fadeIn("slow");
		
		$(this).attr("class", "tab active");
		$("."+id).attr("src", "tpl/files/images/btn/highlight_rollover_"+alt+".png");
		
		
	});
	
	$("#tab1").click(function(){
		var id = $(this).attr("id");
		var alt = $(this).attr("alt");
		
		var vars = {
            currentSlide: 0,
            currentImage: '',
            totalSlides: 0,
            randAnim: '',
            running: false,
            paused: false,
            stop:false
        };
							  
		$("#tab2").attr("class", "tab link");
		$("#tab3").attr("class", "tab link");
		$("#tab4").attr("class", "tab link");
		$("#tab5").attr("class", "tab link");
		$("#tab6").attr("class", "tab link");
		$(".tab2").attr("src", "tpl/files/images/btn/highlight_bank.png");
		$(".tab3").attr("src", "tpl/files/images/btn/highlight_razak.png");
		$(".tab4").attr("src", "tpl/files/images/btn/highlight_graduate.png");
		$(".tab5").attr("src", "tpl/files/images/btn/highlight_centre.png");
		$(".tab6").attr("src", "tpl/files/images/btn/highlight_pintar.png");
		
		$("#slideshow2").css("display", "none");
		$("#slideshow3").css("display", "none");
		$("#slideshow4").css("display", "none");
		$("#slideshow5").css("display", "none");
		$("#slideshow6").css("display", "none");
		
		
		
		
		$("#slideshow1").fadeIn("slow");
		
		$(this).attr("class", "tab active");
		$(".tab1").attr("src", "tpl/files/images/btn/highlight_rollover_"+alt+".png");
		
		
	});
	
	// back to top //
	$(".back-to-top").click(function() {
		$('html, body').animate({scrollTop: '0px'}, 300);
     	return false;
	});
	
	// footer slide //
	$(".quickOpen").click(function(){
								   
		$("#btm_panel").slideDown("fast");
		
		$(this).css("display", "none");
		$(".quickClose").css("display", "block");
		
	});
	$(".quickClose").click(function(){
								   
		$("#btm_panel").slideUp("fast");
		
		$(this).css("display", "none");
		$(".quickOpen").css("display", "block");
		
	});
	
	
	$(".smaller").click(function(){
		
		fnsize = $(this).attr("name");
		
		if(fnsize > 9) {
			smaller = fnsize-1;
			bigger = smaller+2;
			hsize = parseInt(fnsize)+6;
			h6size = parseInt(fnsize)+1;
					
			$(".content-text p").css("font-size", fnsize+"px");
			$(".content-text span").css("font-size", fnsize+"px");
			$(".content-text li").css("font-size", fnsize+"px");
			$(".content-text h3").css("font-size", fnsize+"px");
			$(".content-text h1").css("font-size", hsize+"px");
			$(".content-text h2").css("font-size", hsize+"px");
			$(".content-text h6").css("font-size", h6size+"px");
			
			$(this).attr("name", smaller);
			$(".bigger").attr("name", bigger);
		}
	
	});
	$(".bigger").click(function(){
		
		fnsize = $(this).attr("name");
		
		if(fnsize < 15) {
			smaller = fnsize-1;
			bigger = smaller+2;
			hsize = parseInt(fnsize)+6;
			h6size = parseInt(fnsize)+1;
			
			$(".content-text p").css("font-size", fnsize+"px");
			$(".content-text span").css("font-size", fnsize+"px");
			$(".content-text li").css("font-size", fnsize+"px");
			$(".content-text h3").css("font-size", fnsize+"px");
			$(".content-text h1").css("font-size", hsize+"px");
			$(".content-text h2").css("font-size", hsize+"px");
			$(".content-text h6").css("font-size", h6size+"px");
			
			$(this).attr("name", bigger);
			$(".smaller").attr("name", smaller);
		}
	
	});
	
	$(".hit").click(function() {
		var id = $(this).attr("id");
		
		
		$.ajax({
			type: "POST",
			data: "id="+id,
			url: "hit",
			success: function(msg)
			{
				
			}
		});
	});
	
	
	$(".ev-det").click(function() {
		
		var id = $(this).attr("id");
		$.ajax({
			type: "POST",
			data: "id="+id,
			url: "../event-details",
			success: function(msg)
			{
				$(".ev-body").html(msg);
			}
		});	
	});
	

});

    

