function focus_search(id) {
	document.getElementById(id).value = "";
}

function blur_search (id) {
	if ( document.getElementById(id).value == "" ) {
		document.getElementById(id).value = "Zoek op deze site";
	}
}

function change_login_button ( id ) {
	document.getElementById(id).style.background = "url('img/logout_button_hover.jpg')";
}

function $(nazwa)
{
	return document.getElementById(nazwa);
}

function Focus(control) {
  control.focus();
  control.select();
}

function IsEmailCorrect(email) {
  return email.match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/)!=null;
}

function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}
/*
function formularz_sprawdz(form)
{
if (!IsEmailCorrect(form.email.value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(form.email);
    return false;
  }
return true;
}
*/
function skopiuj_dane()
{
	$("faktura_imie").value=$("imie").value;
	$("faktura_nazwisko").value=$("nazwisko").value;
	$("faktura_ulica").value=$("ulica").value;
	$("faktura_numer_domu").value=$("numer_domu").value;
	$("faktura_miejscowosc").value=$("miejscowosc").value;
	$("faktura_kod_pocztowy").value=$("kod_pocztowy").value;
	$("faktura_wojewodztwo").selectedIndex=$("wojewodztwo").selectedIndex;
}

function sprawdz_platnosc(form)
{
	if (form.pay_type.checked) 
		return true 
		else
		return false
}

function zmiendane()
{
	$("zmien_dane").value='1';
}


function send_trial_form(f) {

form = document.getElementById(f);

var status = true;
if ( !form.t_level_1.checked && !form.t_level_2.checked ) {
	alert('Graag aanhef invullen');
	Focus(form.t_level_1);
	status = false;
	}
if (IsEmpty(form.t_firstname.value) && status) {
	alert('Graag de firstname invullen');
	Focus(form.t_firstname);
	status = false;
  	}
if (IsEmpty(form.t_lastname.value) && status) {
	alert('Graag de lastname invullen');
	Focus(form.t_lastname);
	status = false;
  	}	
if (IsEmpty(form.t_jobtitle.value) && status) {
	alert('Graag de JobTitle invullen');
	Focus(form.t_jobtitle);
	status = false;
  	}	
if (IsEmpty(form.t_company.value) && status) {
	alert('Graag de company invullen');
	Focus(form.t_company);
	status = false;
  	}		
	
if (IsEmpty(form.t_adres.value) && status) {
	alert('Graag adres invullen');
	Focus(form.t_adres);
	status = false;
  	}
if (IsEmpty(form.t_postcode.value) && status) {
	alert('Graag de postcode invullen');
	Focus(form.t_postcode);
	status = false;
  	}
if (IsEmpty(form.t_city.value) && status) {
	alert('Graag de plaats invullen');
	Focus(form.t_city);
	status = false;
  	}

if (IsEmpty(form.t_telefon.value) && status) {
	alert('Graag uw telefoonnummer invullen');
	Focus(form.t_telefon);
	status = false;
	}

if (!IsEmailCorrect(form.t_email.value) && status) {
    alert('Graag een juist e-mailadres invullen');
    Focus(form.t_email);
    status = false;
	}
if (IsEmpty(form.t_opmerkingen.value) && status) {
	alert('Graag de opmerkingen invullen');
	Focus(form.t_opmerkingen);
	status = false;
  	}

	if ( status ) {
		form.submit();
	}

	return false;
}
	
	
function send_trial_form2(f) {

form = document.getElementById(f);

var status = true;
if ( !form.t_level_1.checked && !form.t_level_2.checked ) {
	alert('Graag aanhef invullen');
	Focus(form.t_level_1);
	status = false;
	}
if (IsEmpty(form.t_firstname.value) && status) {
	alert('Graag de firstname invullen');
	Focus(form.t_firstname);
	status = false;
  	}
if (IsEmpty(form.t_lastname.value) && status) {
	alert('Graag de lastname invullen');
	Focus(form.t_lastname);
	status = false;
  	}		
	
if (IsEmpty(form.t_adres.value) && status) {
	alert('Graag adres invullen');
	Focus(form.t_adres);
	status = false;
  	}
if (IsEmpty(form.t_postcode.value) && status) {
	alert('Graag de postcode invullen');
	Focus(form.t_postcode);
	status = false;
  	}
if (IsEmpty(form.t_city.value) && status) {
	alert('Graag de plaats invullen');
	Focus(form.t_city);
	status = false;
  	}

if (IsEmpty(form.t_telefon.value) && status) {
	alert('Graag uw telefoonnummer invullen');
	Focus(form.t_telefon);
	status = false;
	}

if (!IsEmailCorrect(form.t_email.value) && status) {
    alert('Graag een juist e-mailadres invullen');
    Focus(form.t_email);
    status = false;
	}
if (IsEmpty(form.t_opmerkingen.value) && status) {
	alert('Graag de opmerkingen invullen');
	Focus(form.t_opmerkingen);
	status = false;
  	}

	if ( status ) {
		form.submit();
	}

	return false;
}
	
	
	
function login_form() {
	var status = true;
	if (IsEmpty($('l_login.value'))) {
		alert('Graag de velden invullen');
		Focus($('l_login'));
		status = false;
  	}
	if ( IsEmpty($('l_password.value')) && status  ) {
		alert('Graag uw wachtwoord invullen');
		Focus($('l_password'));
		status = false;
	} 
	if ( status ) {
		document.forms['login'].submit();
	}
}

/* FUNKCJE DO CZYSZCZENIA POL */

/* 
 * Cross-browser event handling, by Scott Andrew
 */
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

/* 
 * Kills an event's propagation and default action
 */
function knackerEvent(eventObject) {
    if (eventObject && eventObject.stopPropagation) {
        eventObject.stopPropagation();
    }
    if (window.event && window.event.cancelBubble ) {
        window.event.cancelBubble = true;
    }
    
    if (eventObject && eventObject.preventDefault) {
        eventObject.preventDefault();
    }
    if (window.event) {
        window.event.returnValue = false;
    }
}

/* 
 * Safari doesn't support canceling events in the standard way, so we must
 * hard-code a return of false for it to work.
 */
function cancelEventSafari() {
    return false;        
}

/* 
 * Cross-browser style extraction, from the JavaScript & DHTML Cookbook
 * <http://www.oreillynet.com/pub/a/javascript/excerpt/JSDHTMLCkbk_chap5/index5.html>
 */
function getElementStyle(elementID, CssStyleProperty) {
    var element = document.getElementById(elementID);
    if (element.currentStyle) {
        return element.currentStyle[toCamelCase(CssStyleProperty)];
    } else if (window.getComputedStyle) {
        var compStyle = window.getComputedStyle(element, '');
        return compStyle.getPropertyValue(CssStyleProperty);
    } else {
        return '';
    }
}

/* 
 * CamelCases CSS property names. Useful in conjunction with 'getElementStyle()'
 * From <http://dhtmlkitchen.com/learn/js/setstyle/index4.jsp>
 */
function toCamelCase(CssProperty) {
    var stringArray = CssProperty.toLowerCase().split('-');
    if (stringArray.length == 1) {
        return stringArray[0];
    }
    var ret = (CssProperty.indexOf("-") == 0)
              ? stringArray[0].charAt(0).toUpperCase() + stringArray[0].substring(1)
              : stringArray[0];
    for (var i = 1; i < stringArray.length; i++) {
        var s = stringArray[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1);
    }
    return ret;
}

/*
 * Disables all 'test' links, that point to the href '#', by Ross Shannon
 */
function disableTestLinks() {
  var pageLinks = document.getElementsByTagName('a');
  for (var i=0; i<pageLinks.length; i++) {
    if (pageLinks[i].href.match(/[^#]#$/)) {
      addEvent(pageLinks[i], 'click', knackerEvent, false);
    }
  }
}

/* 
 * Cookie functions
 */
function createCookie(name, value, days) {
    var expires = '';
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = '; expires=' + date.toGMTString();
    }
    document.cookie = name + '=' + value + expires + '; path=/';
}

function readCookie(name) {
    var cookieCrumbs = document.cookie.split(';');
    var nameToFind = name + '=';
    for (var i = 0; i < cookieCrumbs.length; i++) {
        var crumb = cookieCrumbs[i];
        while (crumb.charAt(0) == ' ') {
            crumb = crumb.substring(1, crumb.length); /* delete spaces */
        }
        if (crumb.indexOf(nameToFind) == 0) {
            return crumb.substring(nameToFind.length, crumb.length);
        }
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, '', -1);
}

/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 *
 * by Ross Shannon, http://www.yourhtmlsource.com/
 */

addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}





function plus(id)
{
	num = document.getElementById(id);
	var number = num.value;
	if(number<99)
	{
		number++;
	}
	
	num.value = number;
}


function minus(id)
{
	num = document.getElementById(id);
	var number = num.value;
	if(number>0)
	{
		number--;
	}
	
	num.value = number;
}









/* KONIEC F-CJI */
