/*on DomRwady start*/
/*function hideNoJavaScriptAlert() {
	document.getElementById('noJavaScriptAlert').style.display = 'none';
	document.getElementById('inner').style.display = 'block';
}*/
//window.addEvent('domready', hideNoJavaScriptAlert);//here works too, but it's in index.php
/*on DomRwady end*/
/* visibility_toggler start*/
function visibility_toggler(id, id2) {
	if (id2 == undefined) {
		document.getElementById(id).style.display = (document.getElementById(id).style.display == 'block') ? 'none' : 'block';
	} else if (id2 != undefined) { 
		document.getElementById(id2).innerHTML = document.getElementById(id).innerHTML;
	}
}
/* visibility_toggler stop*/
/* google map start */
var GLat = 52.290636;  
var GLng = 20.942108;  
var Zoom = 16;  
function google_map_load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("google_map"), {mapTypes: [G_NORMAL_MAP,G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP]});
		map.enableDoubleClickZoom();
		map.enableContinuousZoom();
		map.setCenter(new GLatLng(GLat, GLng), Zoom, G_HYBRID_MAP);
		map.addControl(new GLargeMapControl());
		/*var ovcontrol = new GOverviewMapControl(new GSize(100,100)); 
		map.addControl(ovcontrol); //mniejsza 'lupa'*/
        /*map.addControl(new GScaleControl()); //podziałka*/
        map.addControl(new GMapTypeControl());
		var point = new GLatLng(GLat, GLng);   
		var marker = new GMarker(point);  
		map.addOverlay(marker);
	}
}
/*google map end*/
/*kg start*/
function kg() {
	window.location.replace('/kg/');
}
/*kg stop*/
/*forms' stuff start*/
function active(id, text, more) {
	if (document.getElementById(id).value == text) {
		document.getElementById(id).value = '';
	}
	if (more) {//or (more != undefined)
		document.getElementById(id + 'More').style.display = 'inline';
	}
}
function nonActive(id, text, more) {
	if (document.getElementById(id).value == '') {
		document.getElementById(id).value = text;
	}
	if (more) {
		document.getElementById(id + 'More').style.display = 'none';
	}
}
var inject = '<form action="php/_sender_ksiegagosci.php" method="post" id="KsiegaGosci" onreset="if (!confirm(\'Czy napewno chcesz wykasować wszystkie pola formularza?\')) return false"><p><input class="kontaktInput text_12" onfocus="active(\'Name\',\'- Imię/Nick -\');" onblur="nonActive(\'Name\',\'- Imię/Nick -\');" value="- Imię/Nick -" type="text" name="Name" id="Name" maxlength="60" size="32" /><br /><br /><textarea class="kontaktTextarea text_13" onfocus="active(\'Comments\',\'- Wiadomość -\');" onblur="nonActive(\'Comments\',\'- Wiadomość -\');" rows="6" cols="25" name="Comments" id="Comments">- Wiadomość -</textarea>	<br /><br />Wszystkie pola wymagane.<br /><br /><input type="submit" value="Wyślij" onclick="check_form_guestbook(); return false;" class="text_12" /><input type="reset" value="Skasuj"  class="text_12" /></p></form>';
function injection() {
	document.getElementById('injectionPlace').innerHTML = inject;
}
function trim(str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}
function get_value(id) {
	return trim(document.getElementById(id).value);
}
function email_validate(src) {
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(src);
}
function number_validate(src) {
	var regex = /^[0-9]+$/;
	return regex.test(src);
}
function telephone_validate(src) {
	var regex = /^[0-9- +]+$/;
	return regex.test(src);
}
function check_form_newsletter() {
	if (get_value('newsLetter') == '' || get_value('newsLetter') == '- Twój e-mail -') {
		alert('Podaj swojego e-maila!');
		return false;
	}
	if (!email_validate(get_value('newsLetter'))) {
		alert('E-mail nie jest prawidłowy!');
		return false;
	}
	document.getElementById('newsLetterForm').submit();
	return false;
}
function check_form_kontakt() {
	if (get_value('Name') == '' || get_value('Name') == '- Imię i Nazwisko -') {
		alert('Wypełnij pole "- Imię i Nazwisko -"!');
		return false;
	}
	if (get_value('Mail') == '' || get_value('Mail') == '- Twój e-mail -') {
		alert('Wypełnij pole "- Twój e-mail -"!');
		return false;
	}
	if (!email_validate(get_value('Mail'))) {
		alert('E-mail nie jest prawidłowy!');
		return false;
	}
	if (get_value('Mail') == 'info@miladance.pl') {
		alert('Proszę wpisać swój adres e-mail,\ndzięki któremu będziemy mogli się skontaktować.');
		return false;
	}
	if(get_value('Comments') == '' || get_value('Comments') == '- Wiadomość -') {
		alert('Wypełnij pole "- Wiadomość -"!');
		return false;
	}
	document.getElementById('Kontakt').submit();
	return false;
}
function check_form_guestbook() {
	if (get_value('Name') == '' || get_value('Name') == '- Imię/Nick -') {
		alert('Wypełnij pole "- Imię/Nick -"!');
		return false;
	}
	if(get_value('Comments') == '' || get_value('Comments') == '- Wiadomość -') {
		alert('Wypełnij pole "- Wiadomość -"!');
		return false;
	}
	document.getElementById('KsiegaGosci').submit();
	return false;
}
function check_form_zapisy() {
	if (get_value('Name') == '' || get_value('Name') == '- Imię i Nazwisko -') {
		alert('Wypełnij pole "- Imię i Nazwisko -"!');
		return false;
	}
	Course = false;
	for (i = 1; i <= 10; i++ ) {
		if (document.getElementById('Course'+i).checked) {
			Course = true;
			break;
		}
	}
	if (!Course) {
		alert('Wybierz przynajmniej jeden kurs!');
		return false;
	}
	if (get_value('People') == '' || get_value('People') == '- Ilość osób -') {
		alert('Wypełnij pole "- Ilość osób -"!');
		return false;
	}
	if (!number_validate(get_value('People'))) {
		alert('Liczba osób w postaci cyfr!');
		return false;
	}
	if(get_value('DateTime') == '' || get_value('DateTime') == '- Dzień i godzina -') {
		alert('Wypełnij pole "- Dzień i godzina -"!');
		return false;
	}
	if(get_value('Contact') == '' || get_value('Contact') == '- Kontakt (proszę wpisać e-mail i/lub telefon) -') {
		alert('Wypełnij pole "- Kontakt -"!');
		return false;
	}
	if(!document.getElementById('Agree').checked) {
		alert('Musisz zaakcetować regulamin i zgodzić się na przetwarzanie danych osobowych!');
		return false;
	}
	document.getElementById('Zapisy').submit();
	return false;
}
function check_form_zapytanie_short() {
	if (get_value('Description') == '' || get_value('Description') == '- Opis i charakter imprezy -') {
		alert('Wypełnij pole "- Opis i charakter imprezy -"!');
		return false;
	}
	if (get_value('DT') == '' || get_value('DT') == '- Termin i miejsce imprezy -') {
		alert('Wypełnij pole "- Termin i miejsce imprezy -"!');
		return false;
	}
	if (get_value('Budget')=='0') {
		alert('Określ "Oferowany budzet"!');
		return false;
	}
	if (get_value('Name') == '' || get_value('Name') == '- Imię i Nazwisko -') {
		alert('Wypełnij pole "- Imię i Nazwisko -"!');
		return false;
	}
	if (get_value('Company') == '' || get_value('Company') == '- Firma -') {
		alert('Wypełnij pole "- Firma -"!');
		return false;
	}
	if (get_value('Mail') == '' || get_value('Mail') == '- Twój e-mail -') {
		alert('Wypełnij pole "- Twój e-mail -"!');
		return false;
	}
	if (!email_validate(get_value('Mail'))) {
		alert('E-mail nie jest prawidłowy!');
		return false;
	}
	if (get_value('Mail') == 'info@miladance.pl') {
		alert('Proszę wpisać swój adres e-mail,\ndzięki któremu będziemy mogli się skontaktować.');
		return false;
	}
	if (get_value('Telephone') == '' || get_value('Telephone') == '- Telefon -') {
		alert('Wypełnij pole "- Telefon -"!');
		return false;
	}
	if (!telephone_validate(get_value('Telephone'))) {
		alert('Telefon w postaci cyfr!\nDodatkowe dozwolone znaki to " ", "-" i "+".');
		return false;
	}
	document.getElementById('Zapytanie_short').submit();
	return false;
}
function check_form_zapytanie_long() {
	if (get_value('Description') == '' || get_value('Description') == '- Opis i charakter imprezy -') {
		alert('Wypełnij pole "- Opis i charakter imprezy -"!');
		return false;
	}
	if (get_value('Dancers')=='0') {
		alert('Określ "Liczbę tancerzy"!');
		return false;
	}
	if (get_value('DT') == '' || get_value('DT') == '- Termin i miejsce imprezy -') {
		alert('Wypełnij pole "- Termin i miejsce imprezy -"!');
		return false;
	}
	if (get_value('Detail') == '' || get_value('Detail') == '- Szczegóły -') {
		alert('Wypełnij pole "- Szczegóły -"!');
		return false;
	}
	if (get_value('DetailCont') == '' || get_value('DetailCont') == '- Kostiumy i choreografia -') {
		alert('Wypełnij pole "- Kostiumy i choreografia -"!');
		return false;
	}
	if (get_value('Budget')=='0') {
		alert('Określ "Oferowany budzet"!');
		return false;
	}
	if (get_value('Name') == '' || get_value('Name') == '- Imię i Nazwisko -') {
		alert('Wypełnij pole "- Imię i Nazwisko -"!');
		return false;
	}
	if (get_value('Name') == '' || get_value('Name') == '- Imię i Nazwisko -') {
		alert('Wypełnij pole "- Imię i Nazwisko -"!');
		return false;
	}
	if (get_value('Company') == '' || get_value('Company') == '- Firma -') {
		alert('Wypełnij pole "- Firma -"!');
		return false;
	}
	if (get_value('Mail') == '' || get_value('Mail') == '- Twój e-mail -') {
		alert('Wypełnij pole "- Twój e-mail -"!');
		return false;
	}
	if (!email_validate(get_value('Mail'))) {
		alert('E-mail nie jest prawidłowy!');
		return false;
	}
	if (get_value('Mail') == 'info@miladance.pl') {
		alert('Proszę wpisać swój adres e-mail,\ndzięki któremu będziemy mogli się skontaktować.');
		return false;
	}
	if (get_value('Telephone') == '' || get_value('Telephone') == '- Telefon -') {
		alert('Wypełnij pole "- Telefon -"!');
		return false;
	}
	if (!telephone_validate(get_value('Telephone'))) {
		alert('Telefon w postaci cyfr!\nDodatkowe dozwolone znaki to " ", "-" i "+".');
		return false;
	}
	document.getElementById('Zapytanie_long').submit();
	return false;
}
/*forms' stuff start*/
