function startPage() {
	if(jQuery("#tabs1").length) {
		document.getElementById('col2').style.display = 'Inline';
		document.getElementById('col3').style.display = 'Inline';
		jQuery("#tabs1").tabs();
		jQuery("#tabs2").tabs();
	}
	jQuery("#mapzone .center").show();
	jQuery(".mod_placehere").newsTicker();
	if(jQuery('#banerfrontowyclick a').length) {
		jQuery('#banerfrontowyclick a').fancybox({ titleShow : true, transitionIn: 'elastic',  'autoScale' : true, scrolling : 'no', showNavArrows : 'no',onComplete : function() {
				jQuery("#fancybox-img").css('cursor','pointer');
				jQuery("#fancybox-img").click(function(){
				window.location="http://www.edugis.pl/pl/aktualnosci/wydarzenia/180";       
				return false;  
				});
		}
		});
		jQuery('#banerfrontowyclick a').click();
	}
}


function clearForm(id) {
	if(document.getElementById(id)) {
       var myform = document.getElementById(id);
       for (i = 1; i != myform.elements.length; i++) {
               element = myform.elements[i];
               if (element.type == 'text') {
                       element.value = '';
               }
               if (element.type == 'select-one') {
                       element.selected="selected";
               }
               if (element.type == 'password') {
                       element.value = '';
               }
               if (element.type == 'textarea') {
                       element.value = '';
               }
               if (element.type == 'checkbox') {
                       element.checked = false;
               }
               if (element.type == 'radio') {
                       element.checked = false;
               }
       }
	}

} 

function checkRadio(table,alerttext) {
		var radioval = 0;
		var questval = '';
		var groups = document.getElementsByName(table);
		for (var z=0; z < groups.length; z++) {
			if (groups[z].checked){	
				radioval = groups[z].value; 
				questval = groups[z].value;
			}
		}
		if(radioval<1) { 
			alertpopup = alertpopup + "* " + alerttext + "\n"; 
		}
		return questval; 
}

function checkInput(val,alerttext) {
	var obj = document.getElementById(val);
	if (obj.value==''){	
		alertpopup = alertpopup + "* " + alerttext + "\n";
		return false; 
	}
	return true;
}

function checkDropdown(table,alerttext) {
	var questval = '';
	var radioval = 0;
	var groups = document.getElementById(table);
	var tableval = groups.options[groups.selectedIndex].value;
	if(tableval!='' || tableval!=false) { 
		radioval = 1; 
		questval = groups.options[groups.selectedIndex].value;		
	}
	if(radioval<1) { alertpopup = alertpopup + "* " + alerttext + "\n";}
	return questval; 
}

function checkBox(table,alerttext) {
		var radioval = 0;
		var questval = '';
		var groups = document.getElementsByName(table);
		for (var z=0; z < groups.length; z++) {
			if (groups[z].checked){	
				radioval = groups[z].value; 
				questval = groups[z].value;
			}
		}
		if(radioval<1) { 
			alertpopup = alertpopup + "* " + alerttext + "\n"; 
		}
		return questval; 
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
}


var alerttxt = "Proszę prawidłowo wypełnić formularz: ";
var alertpopup = '';

function wyslij() {
	checkInput("tytul","Tytuł");
	checkDropdown("poziom","Poziom");
	checkInput("url","Url");
	checkDropdown("jezyk","Język");
	checkInput("autor","Kto prowadzi serwis (autor, instytucja)");
	checkInput("tematyka","Tematyka serwisu");
	checkDropdown("kategoria","Kategoria serwisu");
	checkDropdown("adresat","Adresat serwisu");



	if(alertpopup) {
		alert(alerttxt+"\n"+alertpopup);
		alertpopup = '';
	} else {
		wyslijGotowe();
	}
}

function wyslijGotowe() {
	document.forms.gisform.submit();
}

function linkSearchPoziom() {
	if(jQuery("#przedmiot").val()) {
		jQuery("#poziom").show();
		resetSelect("#poziom");
		jQuery("#tematy").hide();
		resetSelect("#tematy");
	} else {
		jQuery("#poziom").hide();
		resetSelect("#poziom");
		jQuery("#tematy").hide();
		resetSelect("#tematy");
	}
}


function linkSearchZakres() {
	if(jQuery("#poziom").val() && jQuery("#przedmiot").val()!='ogólne') {
			jQuery("#zakres").hide();
			resetSelect("#zakres");
			resetSelect("#tematy");
			jQuery("#tematy").show();
			if(jQuery("#przedmiot").val()=='geografia') {
				if(jQuery("#poziom").val()=='liceum') {
					jQuery("#tematy").html(geo_lic);
				} else {
					jQuery("#tematy").html(geo_gimn);
				}
			} else 	if(jQuery("#przedmiot").val()=='biologia') {
				if(jQuery("#poziom").val()=='liceum') {
					jQuery("#tematy").html(biol_lic);
				} else {
					jQuery("#tematy").html(biol_gimn);
				}
			}
	} else {
		jQuery("#tematy").hide();	
		resetSelect("#tematy");
	}
}


function linkSearchTematy() {
	if(jQuery("#zakres").val()) {
		resetSelect("#tematy");
		jQuery("#tematy").show();
		if(jQuery("#przedmiot").val()=='geografia') {
			if(jQuery("#zakres").val()=='podstawowy') {
				jQuery("#tematy").html(geo_lic_pod);
			} else {
				jQuery("#tematy").html(geo_lic_roz);
			}
		} else 	if(jQuery("#przedmiot").val()=='biologia') {
			if(jQuery("#zakres").val()=='podstawowy') {
				jQuery("#tematy").html(biol_lic_pod);
			} else {
				jQuery("#tematy").html(biol_lic_roz);
			}
		}
	} else {
		jQuery("#tematy").hide();
		resetSelect("#tematy");
	}
}


function resetSelect(myval) {
//	alert(myval);
//	var select = jQuery(''+myval+''); 
//	select.val(jQuery('options:first', select).val());
	jQuery(''+myval+'').val( jQuery(''+myval+'' + " option:first").val() );
}


/*		jQuery("#zakres").hide();
		if(jQuery("#poziom").val()=='gimnazjum') {
			resetSelect("#tematy");
			jQuery("#tematy").show();
		} else {
			jQuery("#tematy").hide();
		}
*/
