function get( id ){
	return document.getElementById( id );
}

function getValue( id ){
	if( get( id ) ){
		return get( id ).value;
	}
	return false;
}

function in_array( what, where ){
	var a=false;
	for(var i=0;i<where.length;i++){
		if(what == where[i]){
			a=true;
			break;
		}
	}
	return a;
}

function validateName( elem ){
	var val = elem.value;
	var val2 = val.replace(/[^A-Za-z0-9ÊÓ¡¦£¯¬ÆÑêó±¶³¿¼æñ\"\s\-\.]/, '');
	elem.value = val2;
}

function zapiszOrder( id ){
	var wpr = get( 'wprowadz_'+id );
	var data = wpr.value;
	
	ajax_target = '';
	ajax_method = 'post';
	ajax_action = 'zapiszOrder';
	plus_data = 'wpr='+data;

	ajax_done = function( text ) {
		if( text != 'notok' ){
			if( confirm( text ) ){
				var td = text.split( '|' );
				//numer
				var num = td[0] +'';
				num = num.replace( 'numer:', '' );
				var dat = td[1] +'';
				dat = dat.replace( 'data:', '' );
				var wcz = td[2] +'';
				wcz = wcz.replace( 'wczesna:', '' );
				var poz = td[3] +'';
				poz = poz.replace( 'pozna:', '' );
				//alert( num+'+'+dat+'+'+wcz+'+'+poz );
				get( "f_id" ).value = id;
				get( "f_nr" ).value = num;
				get( "f_do" ).value = dat;
				get( "f_wczesna" ).value = wcz;
				get( "f_pozna" ).value = poz;
				get( "f_form" ).submit();
			}
		}
		else {
			alert( 'b³±d wprowadzonych danych' );
		}
	}
	ajax_go( plus_data );
}

	function copyToClipboard(st) {
		var s = document.getElementById( st ).value;
		if( window.clipboardData && clipboardData.setData ) {
			clipboardData.setData("Text", s);
		}
		else {
			// You have to sign the code to enable this or allow the action in about:config by changing
			//user_pref("signed.applets.codebase_principal_support", true);
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip) {alert('a1');return false;};

			// create a transferable
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans) {alert('a2');return false;};

			// specify the data we wish to handle. Plaintext in this case.
			trans.addDataFlavor('text/unicode');

			// To get the data from the transferable we need two new objects
			var str = new Object();
			var len = new Object();

			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

			var copytext= s;
			str.data=copytext;
			trans.setTransferData("text/unicode",str,copytext.length*2);

			var clipid=Components.interfaces.nsIClipboard;
			if (!clip) return false;
			clip.setData(trans,null,clipid.kGlobalClipboard);
		}
	}