try{
	if(typeof jQuery == 'undefined')
		throw 'err:jQuery';
	else{
		var checkUserLogin = function(formName,destination){
			var $F = '#'+formName;
			$('#loginProcess').show();
			if($('#email').val()=='' || $('#email').val()=='Email*:'){
				$('#loginProcess').hide();
				createOverlay({errCode:1,title:'Oops',msg:'Email Required!',onClose:function(){$('#email').focus();}});
				return false;
			}if($('#password').val()=='' || $('#password').val()=='Password*:'){
				$('#loginProcess').hide();
				createOverlay({title:'Oops',errCode:1,msg:'Password Required!',onClose:function(){$('#fakePass1').focus();}}); 
				return false;
			}
			$.ajax({
			   	type: "POST",
			   	url: $($F)[0].action ,
			   	data: $($F).serialize(),
			   
				beforeSend: function(){
					$('#email').attr("disabled","disabled");
					$('#password').attr("disabled","disabled");
					$('#btnAuthenticate ').attr("disabled","disabled");
				},
			   	success: function(msg){
				 	$('#loginProcess').hide();
				 	if(msg=='success') window.location = destination;
				 	else {
				 		createOverlay({errCode:1,title:'Oops',msg:msg});
						$('#email').removeAttr("disabled");
						$('#password').removeAttr("disabled");
						$('#btnAuthenticate ').removeAttr("disabled");
					}
			   	}
			});
		};
		
		var checkPasswordReset = function(destination){
			var $F = $('#passwordRecovery');
			var $B = $('#btnRecover');
			var $E = $('#email1');
			var $R = $('#recoveryProcess');
			$.ajax({
					type:'post',
					url: $F[0].action ,
					data: $F.serialize(),
					beforeSend: function(){
						$R.show();
						$B.attr("disabled","disabled");
						$E.attr("disabled","disabled");
					},
					success: function(msg){
						$R.hide();
						$('#passwordRecoverFeedback').html(msg);
					 	if(msg.search('success')<=0){
							$B.removeAttr("disabled");
							$E.removeAttr("disabled");
						}
					}
				}
			);
		};
	}

//file uploader functions
var anim = ['|','/','-','\\'];
var pos = 0;
var interval;
//function to cancel upload in progress:
var isUploading = false;
function cancelUpload(){
	$('#uploadProgress').css({display: 'none'});
	$('#iframeUpload').css({display: 'block'});
	$('#iframeUpload')[0].src=$('#iframeUpload')[0].src;
	$('#progressBar').css({width: '0%'});
	clearInterval( interval );
	isUploading = false;
	}
var getUploadProgress = function(){
	clearInterval( interval );
	
	$.ajax({
		type: "GET",
		url: progressURL ,
		success: function(msg){
			//alert('test');
			var a = anim[pos++];
			if( pos > 3 ) pos = 0;
			$('#progressStatus').html(msg + ( parseFloat(msg) ? (' %&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+a) : '' ));
			if( parseInt(msg) >0 )
				$('#progressBar').css({width: parseInt(msg)+1+'%'});
			else if( msg.search('file') >= 0 ) $('#progressBar').css({width: '100%'});
			else if( msg == 'maximum upload size has been exceeded' ){
				cancelUpload();
				createOverlay('Oops','maximum file size exeeded');
				}
			else $('#progressBar').css({width: '0%'});
			if( $('#iframeUpload').length > 0 ){
				if( $('#iframeUpload')[0].style.display == "none" ){
					interval = setInterval(getUploadProgress, 20 ); //call again to get next status
					isUploading = true;
					if( $('#jContinue').length > 0 ){
						$('#jContinue').css({display: 'none'});
						$('#jisUploading').css({display: 'block'});
						}
					}
				else{
					clearInterval( interval );
					cancelUpload();
					isUploading = false;
					if( $('#jContinue').length > 0 ){
						$('#jContinue').css({display: 'block'});
						$('#jisUploading').css({display: 'none'});
						}
					}
				}
			}
		});
	}
}catch($error){
	if($error == 'err:jQuery') document.write('<div style="color:#f00;font-size:18px">jQuery is not available</div>');
}

