//function update(url,title,text)
function update(url, id) {
 	document['PhotoBig'].src=url;	
	
	var p="pages_set_"+id;
	var tit="portfolio_title_"+id;
	var tex="portfolio_text_"+id;
	
	document.getElementById('pages_set').style.display = 'none';
	document.getElementById('portfolio_title').style.display = 'none';
	document.getElementById('portfolio_text').style.display = 'none';
	
	document.getElementById(p).style.display = 'block';
	document.getElementById(tit).style.display = 'inline';
	document.getElementById(tex).style.display = 'inline';	
}

function updateOut(url, id) {
 	document['PhotoBig'].src=url;	
	
	var p="pages_set_"+id;
	var tit="portfolio_title_"+id;
	var tex="portfolio_text_"+id;
	
	document.getElementById('pages_set').style.display = 'block';
	document.getElementById('portfolio_title').style.display = 'inline';
	document.getElementById('portfolio_text').style.display = 'inline';	
	
	document.getElementById(p).style.display = 'none';		
	document.getElementById(tit).style.display = 'none';
	document.getElementById(tex).style.display = 'none';			
}

function html_mydecode(string)
{
	tmp_str = string.toString();
	str_replace('*cc*','&#039;',tmp_str);
	str_replace('*c*','&quot;',tmp_str);
	return tmp_str;
}

function stripHTML(oldString) {

   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
   
        if(oldString.charAt(i) == '<') inTag = true;
        if(oldString.charAt(i) == '>') {
              if(oldString.charAt(i+1)=="<")
              {
              		//dont do anything
	}
	else
	{
		inTag = false;
		i++;
	}
        }
   
        if(!inTag) newString += oldString.charAt(i);

   }

   return newString;
}

// Sprawdzanie formularzy

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
}

/* FORMULARZ */

function formularz_sprawdz(form, text, calendar, textarea, checkbox, radio)
{
	if (text!='')
	{
		var pola_text=text.split(" ");
		for (var i=0; i<pola_text.length; i++)
		{
			var pole=document.getElementById("pole_"+pola_text[i]);
			if (IsEmpty(pole.value)) 
			{
				alert('Niet alle verplichte velden zijn ingevuld!');
				Focus(pole);
				return false;
			}
		}
	}
	if (calendar!=''){
		var pola_calendar=calendar.split(" ");
		for (var i=0; i<pola_calendar.length; i++){
			var pole=document.getElementById("pole_"+pola_calendar[i]);
			if (IsEmpty(pole.value)) {
				alert('Niet alle verplichte velden zijn ingevuld!');
				Focus(pole);
				return false;
			}
		}
	}	
	if (textarea!=''){
		var pola_textarea=textarea.split(" ");
		for (var i=0; i<pola_textarea.length; i++){
			var pole=document.getElementById("pole_"+pola_textarea[i]);
			if (IsEmpty(pole.value)) {
				alert('Niet alle verplichte velden zijn ingevuld!');
				Focus(pole);
				return false;
			}
		}
	}
	if (checkbox!=''){
		var pola_checkbox=checkbox.split(" ");
		for (var j=0; j<pola_checkbox.length; j++){
			var pole='pole_'+pola_checkbox[j]+'[]';
			var zaznaczony = 0;
			var elements = form.elements;
			for (var i = 0;i<elements.length ;i++ )
				if (elements[i].name == pole)
				{
					var numer=i;
					if (elements[i].checked)
						var zaznaczony = 1;
				}
			if (zaznaczony!=1) {
				alert('Niet alle verplichte velden zijn ingevuld!');
				Focus(document.getElementById('pole_'+pola_checkbox[j]+"_0"));
				return false;
			}
		}
	}
	if (radio!=''){
		var pola_radio=radio.split(" ");
		for (var j=0; j<pola_radio.length; j++){
			var pole='pole_'+pola_radio[j]+'[]';
			var zaznaczony_r = 0;
			var elements = form.elements;
			for (var i = 0;i<elements.length ;i++ )
				if (elements[i].name == pole)
					if (elements[i].checked)
						var zaznaczony_r = 1;
			if (zaznaczony_r!=1) {
				alert('Niet alle verplichte velden zijn ingevuld!');
				Focus(document.getElementById('pole_'+pola_radio[j]+"_0"));
				return false;
			}
		}
	}
	return true;
}


//funkcja sprawdza formularz z polami textowymi które mają zadane value
//author: Mateusz Przetocki
//yellowteam.pl
function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}

function formularz_sprawdz2(form, text, def_text)
{
	if (text!='')
	{
		var pola_text=text.split(" ");
		var pola_def=def_text.split("||");		
		for (var i=0; i<pola_text.length; i++)
		{
			var pole=document.getElementById(pola_text[i]);
			if (IsEmpty(pole.value) || pole.value==pola_def[i]) 
			{
				alert('Niet alle verplichte velden zijn ingevuld!');
				Focus(pole);
				return false;
			}
		}
	}	
	return true;
}

/*
function show(id,value)
{
	var el = document.getElementById(id);
	if(el.value=='')
	{
		el.value = value;
	}
}
function hide(id,value)
{
	var el = document.getElementById(id);
	if(el.value==value)
	{
		el.value = '';
	}
}
*/
