function requestajax(url,div){
	$(div).style.display = 'block';
	new Ajax.Request(url,
  {
    method:'post', 
	 requestHeaders: [ 'Cache-Control', 'no-cache', 'Pragma', 'no-cache'],
	 encoding: 'utf-8',
	 evalJS: 'true',
	 asynchronous: 'true',
	 onCreate: function(){ $(div).innerHTML = '<div class="preloader"></div>';},
	 onSuccess: function(transport) { 
	 	var response = transport.responseText;
	 	$(div).innerHTML = response;
	 },
    onFailure: function(){ $(div).innerHTML = 'błąd'; }
  });

}

function submitajax(url,div,divout){
	new Ajax.Request(url,
  {
    method:'post',
	 requestHeaders: [ 'Cache-Control', 'no-cache', 'Pragma', 'no-cache'],
	 encoding: 'utf-8',
	 evalJS: 'true',
	 asynchronous: 'true',
	 parameters: $(div).serialize(true),
	 onCreate: function(){ $(divout).innerHTML = 'Trwa realizacja żądania...' },
	 onSuccess: function(transport) { 
	 	var response = transport.responseText;
		$(divout).innerHTML = response;
	 },
    onFailure: function(){ $(divout).innerHTML = 'błąd'; }
  });
}


function getVideoThumb(videoid, divid, width, height){
	if( videoid && divid ){
   	var atts = { id: "myytplayer" };
		var params = { allowScriptAccess: "always", allownetworking: "internal", allowfullscreen: "true", wmode: "transparent" };
		swfobject.embedSWF("http://www.youtube.com/v/"+videoid+"&enablejsapi=0&playerapiid=ytplayer", divid, width, height, "8", null, null, params, atts);
	}
	else{
		$(divid).innerHTML = 'Błąd playera . brak id źródła';
	}
}	

function loadBox(divId, which){
	
	if( $(divId).style.display == 'none' ){
		Effect.BlindDown(divId, { duration: 0.7 });
		which.style.color = '#4F4F4F';
	}
	else{
		Effect.SwitchOff(divId, { duration: 0.7 });
		which.style.color = '#C0C0C0';
	}
}

function validateForm(formtype, formid){
	var statusform = true;
	var field = $(formid).serialize(true);
	
	if( formtype == 'contactform' ){
		if( field.name == '' ){ alert('Pole Imię Nazwisko jest obowiązkowe'); statusform = false; }
		else if( field.email == '' ){ alert('Pole Adres email jest obowiązkowe!'); statusform = false; }
		else if( field.msg == '' ){ alert('Pole Treść wiadomości jest obowiązkowe!'); statusform = false; }
		else if( field.post_token == '' ){ alert('Przepisz kod z obrazka!'); statusform = false; }
		
	}
	
	return statusform;
}
