function miniWindow(url,w,h)
	{	window.open(url,'_blank','scrollbars=yes,titlebar=no,toolbar=no,status=no,resizable=yes,dependent=true,menubar=no,width='+w+',height='+h);
	}

function countChar(x,c){//x-string, c - char
	var nr=0;
	for(i=0;i<x.length;i++){
		if (x.charAt(i)==c){
			nr++;
		}
	}
	return nr;
}

function checkIfMailAddressOK(mail){
	if (mail.length==0){
		return false;
	}
	if (countChar(mail,"@")!=1){
		return false;
	}
	if (countChar(mail,".")==0){
		return false;
	}        
	return true;
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function checkRegistrationFields(ref){		
	if (! checkIfMailAddressOK(ref.strEmail.value)){
		alert("Please, give a corect email address !");
		ref.strEmail.focus();
		return false;
	}	
	if (ref.strUserPassword.value==""){
		alert("Please, enter a password !");
		ref.strUserPassword.focus();
		return false;
	}	
	if (ref.strUserPassword.value!=ref.strUserPassword2.value){
		alert("You enter different passwords !");
		ref.strUserPassword.focus();
		return false;
	}	
	if (ref.strSurname.value==""){
		alert("Please, enter your Surname !");
		ref.strSurname.focus();
		return false;
	}	
	if (ref.strName.value==""){
		alert("Please, enter your name !");
		ref.strName.focus();
		return false;
	}	
	if (ref.strTitles.value==""){
		alert("Please, enter your Title !");
		ref.strTitles.focus();
		return false;
	}	
	if (ref.strAffiliation.value==""){
		alert("Please, enter your Affiliation !");
		ref.strAffiliation.focus();
		return false;
	}	
	if (ref.strAddress.value==""){
		alert("Please, enter your address !");
		ref.strAddress.focus();
		return false;
	}	
	if (ref.strZipCode.value==""){
		alert("Please, enter your zip code !");
		ref.strZipCode.focus();
		return false;
	}
	if (ref.strCountry.value==""){
		alert("Please, enter your country !");
		ref.strCountry.focus();
		return false;
	}
	if (ref.strPhone.value==""){
		alert("Please, enter your phone !");
		ref.strPhone.focus();
		return false;
	}
	return true;
}

///// check registration form
function updateRegistrationFee(){
		if (form_registration_form.strRegistrationFee.checked)
			{
				form_registration_form.floatRegistrationFeeValue.value=350;
			}
		else 
			{
				form_registration_form.floatRegistrationFeeValue.value=0;
			}
		update_floatTotalToPay();
}

function updatePublicationAPaperFee(){
	
		form_registration_form.floatPublicationAPaperFeeValue.value=0;
		if (form_registration_form.strPublicationAPaper.checked)
			{
				form_registration_form.floatPublicationAPaperFeeValue.value=90;
			}
		update_floatTotalToPay();
}

function updateAcompaningPersonInfo(){
	
		form_registration_form.floatAcompaningPersonValue.value=0;
		if (form_registration_form.strAcompaningPerson.checked)
		{
				form_registration_form.floatAcompaningPersonValue.value=250;
				//style="visibility:hidden; "
			    document.getElementById("div_table_form_registration_form").style.visibility="visible";
		}
		else{
		    document.getElementById("div_table_form_registration_form").style.visibility="hidden";
		}
		
		update_floatTotalToPay();
}

function update_floatTotalToPay(){
	var v = 0;
	var floatToPay = 0;
	v = parseFloat(form_registration_form.floatRegistrationFeeValue.value);
	if ((form_registration_form.floatRegistrationFeeValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	v = parseFloat(form_registration_form.floatExtraPagesValue.value);
	if ((form_registration_form.floatExtraPagesValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	v = parseFloat(form_registration_form.floatExtraPapersValue.value);
	if ((form_registration_form.floatExtraPapersValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	v = parseFloat(form_registration_form.floatExtraCopiesValue.value);
	if ((form_registration_form.floatExtraCopiesValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	v = parseFloat(form_registration_form.floatPublicationAPaperFeeValue.value);
	if ((form_registration_form.floatPublicationAPaperFeeValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	v = parseFloat(form_registration_form.floatSingleRoomNightsNoValue.value);
	if ((form_registration_form.floatSingleRoomNightsNoValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	v = parseFloat(form_registration_form.floatAcompaningPersonValue.value);
	if ((form_registration_form.floatAcompaningPersonValue.value=="") || isNaN(v)){
		v = 0;
	}
	floatToPay = floatToPay + v;
	
	form_registration_form.floatTotalToPay.value = floatToPay;
}

function checkUploadedFiles(ref){
	if (ref.fWordFile.value==""){
		alert("Please, upload Word document !");
		return false;
	}
	if (ref.fPdfFile.value==""){
		alert("Please, upload PDF document !");
		return false;
	}
	return true;
}