function popup(url, name, width, height, scroll) {
	width=Math.min(screen.availWidth,width);
	height=Math.min(screen.availHeight-40,height);
        var poz_x=(screen.availWidth-width)/2;
        var poz_y=(screen.availHeight-height-30)/2;
        window.open(url, name, 'status=no, scrollbars='+scroll+', menubar=no, width='+width+', height='+height+', resizable=no,toolbar=no, left='+poz_x+', top='+poz_y+', location=no');
}

function viewImage(url,name,width,height,scroll){
	if(screen.width<width || screen.height-height){
		scroll="yes";
	}
	if(screen.width<width){
		width=screen.width;
	}
	if(screen.height<height){
		height=screen.height;
	}
        var x=(screen.width-width)/2
        var y=(screen.height-height)/2
	var newwin=window.open(url, nume, 'scrollbars='+scroll+', menubar=no, height='+inaltime+', width='+latime+', resizable=no,toolbar=no, left='+poz_x+', top='+poz_y+', location=no,status=yes');
	newvin.watch("document",function(id,oldval,newval){alert(444)});
}

function swapImg(img,path,ids,paths){
	for(var i=0;i<ids.length;i++){
		document.getElementById(ids[i]).src=paths[i];
	}
	img.src=path;
}

function chr(cod) {
	return String.fromCharCode(cod);
}

function ord(character) {
	return character.charCodeAt(0);
}

Array.prototype.isIn = function(elem) {
	//function for that check existance of an element in an array
	//created by Sebastian Serban, v1.0 (2.02.2005)
	for (var i=0; i<this.length; i++) {
		if (this[i] == elem) {
			return true;
		}
	}
	return false;
}

Array.prototype.find = function(elem, all) {
	//function for finding elements in arrays
	//created by Sebastian Serban, v3.2 (18.10.2004)
	//this function receives "elem" which may be an number or an array and returns the position or an array of the positions
	//if param "all" is defined, then function return array with all the positions instead of position of the first element found
	if (elem.length == undefined || typeof (elem) != "object") {
		elem = [elem];
		single = true;
	}else{
		single = false;
	}
	var result = [];
	if (all == undefined) {
		for (var k = 0; k<elem.length; k++) {
			result[k] = -1;
			toFind = elem[k];
			for (var i = 0; i<this.length; i++) {
				if (this[i] == toFind) {
					result[k] = i;
					break;
				}
			}
		}
	} else {
		for (var k = 0; k<elem.length; k++) {
			result[k] = [];
			toFind = elem[k];
			for (var i = 0; i<this.length; i++) {
				if (this[i] == toFind) {
					result[k].push(i);
				}
			}
			if (result[k][0] == undefined) {
				result[k] = -1;
			}
		}
	}
	if (single) {
		return result[0];
	} else {
		return result;
	}
};

String.prototype.toInt=function(allowNull){
	result="";
	for(i=0;i<this.length;i++){
		if(Number(this.charAt(i))>=0){
			result+=this.charAt(i);
		}
	}
	if(result==""){
		if(allowNull){
			return "";
		}else{
			return 0;
		}
	}else{
	   return parseInt(result);
	}
}

function openLocation(location, frame){
	if(frame == undefined){
		document.location.href = location;
	}else{
		top.frames[frame].document.location.href = location;
	}
}

function getColorComponents(value) {
	return [parseInt(value/0x10000), parseInt(value/0x100)%0x100, parseInt(value%0x100)];
}

function backgroundTrans(obj,color,time,prop){
	//created by Sebastian Serban
	//v1.1 (7.03.2005)
	if(prop == undefined){
		prop = "bgColor";
	}
	clearInterval(obj.interval);
	var endValue = color;
	color = getColorComponents(Number("0x"+color.substr(1)));
	var startValue = getColorComponents(Number("0x"+obj[prop].substr(1)));
	var timePast = 0;
	obj.stopTrans = function(){
		clearInterval(this.interval);
	}
	obj.endTrans = function(){
		this.stopTrans();
		this[prop] = endValue;
	}
	var callf = function(){
                timePast+=50;
                if(timePast >= time){
                        obj.endTrans();
                }else{
                        var new_color = (parseInt(startValue[0]+timePast*(color[0]-startValue[0])/time))*0x10000;
                        new_color += (parseInt(startValue[1]+timePast*(color[1]-startValue[1])/time))*0x100;
                        new_color += (parseInt(startValue[2]+timePast*(color[2]-startValue[2])/time));
                        new_color = new_color.toString(16);
                        obj[prop] = "#"+new_color;
                }
        }
	obj.interval=setInterval(callf,10);
	callf();
}

function setGroupProperty(objs, prop, value) {
	//created by Sebastian Serban, v1.0 (6.12.2004)
	for(var i=0; i<objs.length; i++) {
		objs[i][prop] = value;
	}
}

function keyDownFloat(evt,nopktvir){
	var oEvent = (window.event) ? window.event : evt;
	k=oEvent.keyCode ? oEvent.keyCode : oEvent.which ? oEvent.which : void 0;
	//alert(k);
	//alert(oEvent.charCode);
	if(document.all){
		specialk=[8,9,37,39,35,36,96,97,98,99,100,101,102,103,104,105];
	}else{
		specialk=[8,9,37,39,35,36];
	}
	if(nopktvir==undefined){
		if(document.all){
			specialk.splice(0,0,188,190,110);
		}else{
			specialk.splice(0,0,44,46);
		}
	}
	var gasit=false;
	for(var i=0;i<specialk.length;i++){
		if(specialk[i]==k){
			gasit=true;
			break;
		}
	}
	if(!gasit){
		if(k>=48 && k<=57){
			gasit=true;
		}
	}
	if(!gasit){
		return false;
	}
}

function blurFloat(obj,zek){
	var str=obj.value.split('');
	var pp=-1;
	for(var i=0;i<str.length;i++){
		if(str[i]==','){
			str[i]='.';
		}
	}
	if(str[0]=='.'){
		str.splice(0,0,0);
		
	}
	for(i=0;i<str.length;i++){
		if(str[i]=='.'){
			pp=i;
			break;
		}
	}
	if(pp!=-1){
		for(i=pp+1;i<str.length;i++){
			if(str[i]=='.'){
				str.splice(i,1);
				i--;
			}
		}
	}
	i=str.length;
	while(str[--i]=='.'){
		str.splice(i,1);
	}
	for(i=0;i<str.length;i++){
		if(str[i]==0 && str[i+1]==0){
			str.splice(i,1);
		}
		if(str[i]!=0){
			break;
		}
	}
	if(zek!=undefined && pp!=-1){
		str.splice(pp+zek+1,100000000000);
	}
	if(str!=''){
		str=parseFloat(str.join(''));
	}
	if(isNaN(str)){
		str="";
	}
	obj.value=str;
}


