function getPdfOrder( ref ){
	window.location = root+'index.php/user/order/'+ref;
}

function checkLength( o, n, min, max ) {
	if ( o.val().length > max || o.val().length < min ) {
		o.addClass( "ui-state-error" );
		$('#rpError').css('display','block');
		return false;
	} 
	else {
		return true;
	}
}

function checkRegexp( o, regexp, n ) {
	if ( !( regexp.test( o.val() ) ) ) {
		o.addClass( "ui-state-error" );
		$('#rpError').css('display','block');
		return false;
	}
	else {
		return true;
	}
}
		
function doResetPassword( em ){
	
	//alert( em );
	
	$.ajax({
   		type: "POST",
   		url: root+"index.php/user/resetPassword",
   		data:{
			email: em
		},
		dataType: "html",
   		success: function(msg){
			if( msg == 'success' ){
				jAlert( $('#resMessageSuccess').html(), companyName );
			}
			else{
				jAlert( $('#resMessageError').html(), companyName );
			}
		}
 	});	
}


function userUpdateAccessData(){
	ajaxData = '&email=' + $('#email').val();
	if( $('#pwd').val() != '' ){
		ajaxData += '&pwd=' + MD5( $('#pwd').val() );
	}
	else{
		ajaxData += '&pwd=';
	}
	
	$.ajax({
   		type: "POST",
   		url: root+"index.php/ajax/updateUserAcc",
   		data: ajaxData,
   		success: function(msg){
			if( msg == 'success' ){
				jAlert( $('#resMessageSuccess2').html(), companyName );
				//$('#resMessageSuccess2').fadeIn( 400 ); //css('display', 'block');
			}
			else{
				jAlert( $('#resMessageError2').html(), companyName );
				//$('#resMessageError2').fadeIn( 400 );
			}
		}
 	});	
}

function userUpdateAddress(){
	
	ajaxData = '&title=' + $('#title').val();
	ajaxData += '&name=' + $('#name').val();
	ajaxData += '&surname=' + $('#surname').val();
	ajaxData += '&company=' + $('#company').val();
	ajaxData += '&address=' + $('#address').val();
	ajaxData += '&pc=' + $('#pc').val();
	ajaxData += '&city=' + $('#city').val();
	ajaxData += '&country=' + $('#country').val();
	ajaxData += '&phone=' + $('#phone').val();
	
	$.ajax({
   		type: "POST",
   		url: root+"index.php/ajax/updateUser",
   		data: ajaxData,
   		success: function(msg){
			if( msg == 'success' ){
				jAlert( $('#resMessageSuccess').html(), companyName );
			}
			else{
				jAlert( $('#resMessageError').html(), companyName );
			}
		}
 	});	
	
	
}

function selectSection( sect, count ){
	for( i=0; i<count; i++ ){
		if( i == sect ){
			$('#s'+i).css('background-color','lightgray');
			$('#p'+i).css('display','block');
			
		}
		else{
			$('#s'+i).css('background-color','white');
			$('#p'+i).css('display','none');
		}
	}
}
