//GO



/**
  * Plik funkcji JS
  * 
  * 
  *
  * @package public
  * @author Ostrowski Dobiegniew <gniewko@infowik.pl>
  *
	*/
	
	
	
function set_innerHTMLById(id,str)
{
	document.getElementById(id).innerHTML = "<span style='font-weight:bold'>"+str+"</span>";
}



// pobiera aktualny "mode" dokumentu

function get_mode()
{	
	var location = document.location.toString();
	var index = location.indexOf("index.php");

	if(index == -1)
		return false;
	else
	return location.substr(index,location.length);
	
}


// obsługa przeźroczystości dla IE 5.5 i PNG

function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase();
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 var imgAttribs = img.attributes;
		 for (var j=0; j<imgAttribs.length; j++)
			{
			var imgAttrib = imgAttribs[j];
			if (imgAttrib.nodeName == "align")
			   {		  
			   if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
			   if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
			   break
			   }
            }
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 strNewHTML += "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }




// Blokuje możliwość przesłania POST'a Enterem w danym polu tekstowym

function block_enter(evt)
{
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
if (charCode == 13)
{
	return false
}
	return true
}



// Sprawdza czy zostało cokolwiek wpisane do pola tekstowego



function not_empty(name)
{
	
	if(trimAll(document.getElementsByName(name)[0].value) != ''){return true;}
	else{
	document.getElementsByName(name)[0].style.border = "solid 2px #FF0000";	
	/*document.getElementsByName(name)[0].focus();*/
	alert("Pole zaznaczone na czerwono musi być wypełnione!");
	return false;
	}

}




// Pokazuje/ukrywa div

function div_visibility(name)
{
	
		if(document.getElementById(name).style.display == 'block')
		{
			document.getElementById(name).style.display = 'none';
		}
		else
		{
			document.getElementById(name).style.display = 'block';
		}
	
}


function window_open(name)
{
	
		if(document.getElementsByName(name)[0].value == 'true'  || document.getElementsByName(name)[0].value == '')
			document.getElementsByName(name)[0].value = "false";
		else
			document.getElementsByName(name)[0].value = "true";
		document.forms['form'].submit();
	
}


// pytanie bezpośrednio przed usunięciem wpisu
// o zasadność usunięcia
function if_delete()
{
	if(confirm('Czy na pewno usunąć?'))
	{ 
		return true; 
	}
		return false;
}

// pytanie bezpośrednio przed wysłaniem mailingu
function if_send()
{
	if(confirm('Czy na pewno wysłać mailing do wszystkich adresatów?'))
	{ 
		return true; 
	}
		return false;
}

function set_case_name(textfield, everyword)
{
	var text = document.getElementsByName(textfield)[0];
	
	var textval = text.value.toLowerCase();
	var textarr = new Array();
	var flag = 1;
	
	//-------wrzucenie elementów z poprawionym Case do tablicy
	for(var i=0;i<textval.length;i++)
	{
		if(flag == 1)
		{
			textarr.push(textval.charAt(i).toUpperCase());
			flag = 0;
		}
		else
			textarr.push(textval.charAt(i).toLowerCase());	

		
		if((textval.charAt(i) == ' ' || textval.charAt(i) == '-') && everyword == true)
			flag = 1;			
	
	}
	
	//-------przypisanie wartości do pola tekstowego
	document.getElementsByName(textfield)[0].value = textarr.join("");
	
}


//END GO

