function move2left(obj, left){
	$(obj).animate({
		"left": left+"px",
		"opacity": "1"
	 },"slow"
	);	
}

function tep_scroll_anywhere(obj, anc){
	$j.fn.extend({
		autoscroll: function(options) {
			return this.each(function() {
				var $this = $j(this);
				$this.css({overflow:'hidden'});
				if(options.direction == 'horizontal') $this.mousemove(function(e) {
					var width = $this.width();
					$this.attr({ scrollLeft: ($this.attr('scrollWidth')-width)*(0.5-Math.cos(Math.PI*(e.pageX-$this.offset().left)/width)/2) });
				});
				else if(options.direction == 'vertical') $this.mousemove(function(e) {
					var height = $this.height();
					$this.attr({ scrollTop: ($this.attr('scrollHeight')-height)*(0.5-Math.cos(Math.PI*(e.pageY-$this.offset().top)/height)/2) });
				});
				else $this.mousemove(function(e) {
					var width = $this.width(), height = $this.height();
					$this.attr({ scrollLeft: ($this.attr('scrollWidth')-width)*(0.5-Math.cos(Math.PI*(e.pageX-$this.offset().left)/width)/2), scrollTop: ($this.attr('scrollHeight')-height)*(0.5-Math.cos(Math.PI*(e.pageY-$this.offset().top)/height)/2) });
				});
			});
		}
	});
	
	$j(obj).animate({
		//scrollTop: $j(anc).offset().top
		scrollTop: "9999"
	}, "slow" );
	
	
}

function tep_emailverify(value, required){
	if(required != 1){		
		if(value.length==0)return 'success';
	}
		var email = value;
		var passed;
		var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen;
		intAtSign=email.indexOf("@");
		intDot=email.indexOf(".",intAtSign);
		intComma=email.indexOf(",");
		intSpace=email.indexOf(" ");
		intLastDot=email.lastIndexOf(".");
		intDomain=intDot-intAtSign;
		intStrLen=email.length;
		// *** CHECK FOR BLANK EMAIL VALUE
		
		if (email == ""){
			return 'This is a required field.'
		}else if (intAtSign == -1){
			return "Your email address is missing the \"<b>@</b>\".";
		}else if (intComma != -1){
			return "Email address cannot contain a comma.";
		}else if (intSpace != -1){
			return "Email address cannot contain spaces.";
		}else if ((intDot <= 2) || (intDomain <= 1)  || (intStrLen-(intLastDot+1) < 2)){
			return "Please enter a valid Email address.<br><b>" + email + "</b> is not valid.";
		}else{
			return 'success';
		};
};

function tep_submit_poll(){
	if(document.pollalumni.opinyun.value.length < 1){
		errorCallback = function(){
			document.pollalumni.opinyun.focus();	
		}
		tep_create_errordialog('Maari lamang ilahad ang iyon opinyon', errorCallback);
	}else if(document.pollalumni.firstname.value == ''){
		errorCallback = function(){
			document.pollalumni.firstname.focus();	
		}
		tep_create_errordialog('First name is required.', errorCallback);
	}else if(document.pollalumni.lastname.value == ''){
		errorCallback = function(){
			document.pollalumni.lastname.focus();	
		}
		tep_create_errordialog('Last name is required.', errorCallback);
	}else if(tep_emailverify(document.pollalumni.email.value, 1) != 'success'){
		errorCallback = function(){
			document.pollalumni.email.focus();	
		}
		tep_create_errordialog(tep_emailverify(document.pollalumni.email.value, 1), errorCallback);
	}else{
		var fname = document.pollalumni.firstname.value;
		
		
		urlu='process.php?area=alumni&action=save&'+account_session;	
		$j.ajax({
		  type: 'POST',
		  url: urlu,
		  cache: false,
		  data: $j("#pollalumni").serialize(),
		  success: function(data){
				document.pollalumni.firstname.disabled = 'disabled';	
				document.pollalumni.lastname.disabled = 'disabled';
				document.pollalumni.email.disabled = 'disabled';
				document.pollalumni.opinyun.disabled = 'disabled';
				document.pollalumni.year_graduated.disabled = 'disabled';
			  	$j("#dialog_content").html('<center>Your answer has been submitted and subject for review.<br>Thank you <b>'+fname+'</b> for participating LNHS Alumni survey.<br><br>Good day/night!</center>');
				$j("#dialog_content:ui-dialog").dialog( "destroy" );
				$j("#dialog_content").attr('title', 'Success notification');
				
				$j( "#dialog_content" ).dialog({
					resizable: false,
					width:350,
					modal: true,
					buttons: {
						"Okay" : function() {
							$j( this ).dialog( "close" );
							goto('');
						}
					}
				});
		  }
		});
	}
}






function tep_create_errordialog(text, errorCallback){
	// 
	$j("#dialog_content").html(text);
	$j("#dialog_content:ui-dialog").dialog( "destroy" );
	$j("#dialog_content").attr('title', 'Error notification');

	$j( "#dialog_content" ).dialog({
		resizable: false,
		width:350,
		modal: true,
		buttons: {
			"Okay" : function() {
				$j( this ).dialog( "close" );
				setTimeout(errorCallback, 50);
			}
		}
	});
}






function tep_enabler(){
	if(document.getElementById('dataholder_text_enabler')){
		clearTimeout(globalTimeout);
	}else{
		globalTimeout = setTimeout("tep_enabler()", 300);
	}
}
