function reload(form)
 {
   	var val=form.state.options[form.state.options.selectedIndex].value;
    
	var val_e =form.email.value;
    var val_n =form.name_display.value;
  if (window.location.href.indexOf("registration.php") >= 0)
      {
       	var val_u = form.user.value;
		self.location = window.location.pathname + '?st=' + val + '&u=' + val_u + '&e=' + val_e + '&n=' + val_n;   
      }
      else
      {
        self.location = window.location.pathname + '?st=' + val + '&e=' + val_e + '&n=' + val_n; 
      }
  // 	alert (window.location.pathname); window.location.pathname.substring(1,3));
//	alert(self.location);
 }

 function validation_register(forma)
 {

 if (trim(document.forma.user.value) == '')
	 {
	 alert('Please enter the username !');
	 document.forma.user.focus();
	 return false;
	 }
  
 if (trim(document.forma.user.value).length < 4)
	 {
	 alert('Please enter minimum 4 characters for the username !');
	 document.forma.user.focus();
	 return false;
	 } 	

 if (document.forma.parola.value == '')
	 {
	 alert('Please enter the password !');
	 document.forma.parola.focus();
	 return false;
	 }

 if (document.forma.parola.value.length < 4)
	 {
	 alert('Please enter minimum 4 characters for the password !');
	 document.forma.parola.focus();
	 return false;
	 }


 if (document.forma.parola.value != document.forma.repeta_parola.value)
    {
    alert('Passwords are not identical !');
	return false;
    }

  if (trim(document.forma.name_display.value) == '')
	 {
	 alert('Please enter the name that will be displayed at Contact details !');
	 document.forma.name_display.focus();
	 return false;
	 }

   if (!isEmail(forma.email.value))
   {
	alert('Please enter a valid email address !');
	 document.forma.email.focus();
	 return false;
   }
 
 }

 function validation_modify_profile(forma)
 {

   if (!isEmail(forma.email.value))
   {
	alert('Please enter a valid email address !');
	 document.forma.email.focus();
	 return false;
   }
   
   if (trim(document.forma.name_display.value) == '')
	 {
	 alert('Please enter the name that will be displayed at Contact details!');
	 document.forma.name_display.focus();
	 return false;
	 }

 }

 function validation_pass()
 {

  if (document.forma.parola.value == '')
	 {
	 alert('Please enter the password !');
	 document.forma.parola.focus();
	 return false;
	 }

 if (document.forma.parola.value.length < 4)
	 {
	 alert('Please enter minimum 4 characters for the password !');
	 document.forma.parola.focus();
	 return false;
	 }


 if (document.forma.parola.value != document.forma.repeta_parola.value)
    {
    alert('Passwords are not identical !');
	return false;
    }
 
 }

function openwindow_book(id)
{
var URL = 'book.php?id='+id;
var options = "toolbar=1,status=0,menubar=0,scrollbars=1," + "resizable=0,width=400,height=200, left=350,top=100";
//alert(URL);
window.open(URL, "", options);
}

function openwindow_user(id)
{
var URL = 'user.php?id='+id;
var options = "toolbar=0,status=0,menubar=0,scrollbars=1," + "resizable=0,width=300,height=200, left=500,top=100";
//alert(URL);
window.open(URL, "", options);
}


function openwindow_helpsearch()
{
var URL = 'help_search.html';
var options = "toolbar=1,status=0,menubar=0,scrollbars=1," + "resizable=0,width=400,height=500, left=600,top=100";
//alert(URL);
window.open(URL, "", options);
}

/***********************************************************************
CONTACT
************************************************************************/
function openwindow_contact()
{
var URL = 'contact.php';
var options = "toolbar=0,status=0,menubar=0,scrollbars=0," + "resizable=0, width=300,height=100, left=800,top=600";
//alert(URL);
window.open(URL, "", options);
}


/***********************************************************************
Open Terms & Conditions
************************************************************************/
function openwindow_terms()
{
var URL = 'html/terms.html';
var options = "toolbar=0,status=0,menubar=0,scrollbars=0," + "resizable=1";
//alert(URL);
window.open(URL, "", options);
}

/***********************************************************************
Name: isEmail
Description: Checks if the string parameter is a valid e-mail address
************************************************************************/
function isEmail(str){
	str = trim(str)
	var re = /^(\w|[^_]\.|[\-]|[^\s@])+@[^_@\.](([^\s@\.]|[a-z]|\d|\-)+|([^_@\.]\.[^_@\.])*)+\.[a-z]{2,}$/i
	return re.test(str)
}

/**********************************************************************
Name: trim
Description: Removes leading and trailing spaces
**********************************************************************/
function trim(str) {
	return (str.replace(/^\s*|\s*$/gi,''))
} 

/***********************************************************************
Name: confirmDelete
Description:
************************************************************************/

function confirmDelete(confirm_message) {
	return window.confirm(confirm_message);
}






