function open(url,name1) {				
	
	if (name1 == "") {
		name="homepage";
	} else {
		name = "menu_"+name1+".html";
	}
	var url_id = document.getElementById(url);
		if (url_id != null) url_id.style.display = "block";
		document.getElementById(name).style.color = "#3969A5";
		/*document.getElementById(name).style.background = "#f6f6f2";
		document.getElementById(name).style.backgroundImage = "url('img/bg_menu.gif')";
		document.getElementById(name).style.backgroundRepeat = "no-repeat";
		document.getElementById(name).style.backgroundPosition = "0px 0px";*/
		document.getElementById(name).style.borderBottomColor = "#B00C0C"; 
	}

function send() {
	document.getElementById("keepMe").submit();
}
function cancel() {
	document.getElementById('registerForm').reset();
}

/* walidacja formularza rejestracyjnego *************************/
function handleClick(id) {
        				var obj = "";

                	// Check browser compatibility
                	if(document.getElementById)
                      obj = document.getElementById(id);
                	else if(document.all)
                        obj = document.all[id];
               	else if(document.layers)
                        obj = document.layers[id];
                	else return 1;

                	if (!obj) {return 1;}
                	else if (obj.style) {
                        obj.style.display = ( obj.style.display != "none" ) ? "none" : "";
                	} else {
                        obj.visibility = "show";
                	}
               }//koniec function handleClick
         function sprawdz(formularz) {
         for (i = 0; i < formularz.length; i++) {
              var pole = formularz.elements[i];
              var n =  new Array;
                  n[0] = 'title';
                  n[1] = 'fname';
                  n[2] = 'sname';
                  n[3] = 'jobtitle';
                  n[4] = 'zip';
				  n[5] = 'company';
				  n[6] = 'address';
				  n[7] = 'zip';
				  n[8] = 'city';
				  n[9] = 'country';
				  n[10] = 'mailadr';
              if (pole.type == 'text') {
                  for (j=0; j< n.length; j++) {
                    if (pole.name == n[j] && pole.value == '') {
                        alert('Please fill in all required elements!');
                        if(pole.focus) pole.focus();
                        return false;
                      }
                    }
                  }
              }
              return true;
         }//koniec function sprawdz
         
   function check_select(formularz,n) {
	for (i = 0; i < formularz.length; i++) {
    	var pole = formularz.elements[i];
        if ((pole.name == n) && pole.value == '')  {
             alert('Please fill in all required elements!');
             if(pole.focus)
             pole.focus();
             return false;
        	}
    	}
    	return true;
   }
   
   function validate_zip(field) {
                var valid = "0123456789-"
                var ok = "yes";
                var temp;
                for (var i=0; i<field.value.length; i++) {
                temp = "" + field.value.substring(i, i+1);
                if (valid.indexOf(temp) == "-1") ok = "no";
                }
                if (ok == "no") {
                alert("Incorrect post code!");
                field.focus();
                field.select();
                return false;
                }
                return true;
                }
    
    function email_check(field) {
  var str=field.value;
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
     alert("Incorrect e-mail address!");
     field.focus();
     return false;
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Incorrect e-mail address!");
     field.focus();
     return false;
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Incorrect e-mail address!");
      field.focus();
      return false;
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Incorrect e-mail address!");
      field.focus();
      return false;
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Incorrect e-mail address!");
      field.focus();
      return false;
   }
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Incorrect e-mail address!");
      field.focus();
      return false;
   }
   if (str.indexOf(" ")!=-1){
      alert("Incorrect e-mail address!");
      field.focus();
      return false;
   }
   return true
}

function confirm_terms()  {	
	if (!document.getElementById("confirm_terms").checked) {
		alert("Please read terms of registration and cancellation and accept them before submiting this registration form!");
		document.getElementById("register_confirm_terms").style.fontWeight = "bold";
		document.getElementById("register_confirm_terms").style.color = "#c21212";
		return false;
	}
	return true;
}

function chceckForm(form) {
    if(sprawdz(form) &&
    	check_select(form,'title') &&    	
    	validate_zip(form.zip) &&         	                        
        email_check(form.mailadr)  &&
        confirm_terms()) return true;
    return false;
}

function register(form) {
	if (chceckForm(form)) {
		form.submit();
	}
}

function resize(img,w,h,id){
  		foto = new Image();
  		foto.src=(img);
		fotoHeight = foto.height;
		fotoWidth = foto.width;			
		if (w > fotoWidth && h > fotoHeight) {
           dst_w = fotoWidth;
           dst_h = fotoHeight;										  	
        } else if (w/h < fotoWidth/fotoHeight) {
           dst_w = w;
           dst_h = w*fotoHeight/fotoWidth;													 
        } else {
           dst_w = h*fotoWidth/fotoHeight;
           dst_h = h;																
        }
		
        var fd = new Array();
        fd['dst_h'] = Math.round(dst_h);
		fd['dst_w'] = Math.round(dst_w);
		return fd;
		
				
}

function resizeFoto(img,w,h,id) {
	var fotoDimm = new Array();
	fotoDimm = resize(img,w,h,id);
	document.getElementById(id).style.height = fotoDimm['dst_h']+"px";
	document.getElementById(id).style.width = fotoDimm['dst_w']+"px";
	document.getElementById(id).style.padding = "5px";
	document.getElementById(id).style.backgroundColor = "#ffffff";
	document.getElementById(id).style.borderColor = "#f4f4f4";
	document.getElementById(id).style.borderWidth = "1px";
	document.getElementById(id).style.borderStyle = "solid";
}

function resizeFoto1(img,w,h,id) {
	var fotoDimm = new Array();
	fotoDimm = resize(img,w,h,id);
	ml = fotoDimm['dst_w'] + 40;
	document.getElementById(id).style.height = fotoDimm['dst_h']+"px";
	document.getElementById(id).style.width = fotoDimm['dst_w']+"px";
	document.getElementById(id).style.padding = "5px";
	document.getElementById(id).style.backgroundColor = "#ffffff";
	document.getElementById(id).style.borderColor = "#f4f4f4";
	document.getElementById(id).style.borderWidth = "1px";
	document.getElementById(id).style.borderStyle = "solid";
	document.getElementById("itemFull").style.marginLeft = ml+"px";
}