function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
* Usage:
* <form>
* <input type="text" onkeypress="return handleEnter(this, event)"><br>
* <input type="text" onkeypress="return handleEnter(this, event)"><br>
* <textarea>Some text</textarea>
* </form>
*
***********************************************/
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13) {
	var i;
	for (i = 0; i < field.form.elements.length; i++)
		if (field == field.form.elements[i])
			break;
	i = (i + 1) % field.form.elements.length;
	field.form.elements[i].focus();
	return false;
}
else
return true;
}

/***********************************************
show/hide element with hide_id id
***********************************************/
function showHideElementById(hide_id, visible) {
	if(visible){
		try {
			document.getElementById(hide_id).style.display = '';
		} catch(error) {}
	}else{
		try {
			document.getElementById(hide_id).style.display = 'none';
		} catch(error) {}
	}
}

/***********************************************
update field value when ifValue is equal "org" field value - wf tax
***********************************************/
function updateDateValue(org, change, ifValue) {
	var org_elem = document.getElementById(org);
	var change_elem = document.getElementById(change);
	if (org_elem.value == ifValue) {
		change_elem.value = org_elem.value;
	}
}

/*konwersja kodowania*/

function utf8(wide) {
	var c, s;
	var enc = "";
	var i = 0;
	while(i<wide.length) {
	c= wide.charCodeAt(i++);
	// handle UTF-16 surrogates
	if (c>=0xDC00 && c<0xE000) continue;
	if (c>=0xD800 && c<0xDC00) {
		if (i>=wide.length) continue;
		s= wide.charCodeAt(i++);
		if (s<0xDC00 || c>=0xDE00) continue;
		c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
	}
	// output value
	if (c<0x80) enc += String.fromCharCode(c);
	else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
	else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
	else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
	}
	return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
	return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s) {
	var s = utf8(s);
	var c;
	var enc = "";
	for (var i= 0; i<s.length; i++) {
	if (okURIchars.indexOf(s.charAt(i))==-1)
		enc += "%"+toHex(s.charCodeAt(i));
	else
		enc += s.charAt(i);
	}
	return enc;
}
