nav = navigator.appName.indexOf("Microsoft")!= -1 ? 1 : 2;

function show1()
{     document.getElementById('apare2').style.display="none";
	document.getElementById('apare1').style.display="";
	
}


 function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}

function show2()
{document.getElementById('apare1').style.display="none";
document.getElementById('apare2').style.display="";
	
}

function free()
{document.getElementById('apare1').style.display="none";
document.getElementById('apare2').style.display="none";
	
}


function popup(url, name, width, height, scroll, modal, resizable) {
	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;
	newwin=window.open(url, name, 'scrollbars='+scroll+', menubar=no, width='+width+', height='+height+', resizable='+(resizable ? 'yes' : 'no')+',toolbar=no, left='+poz_x+', top='+poz_y+', location=no, status=yes');
	if(modal){
		popInt=setInterval(function(n){
			if(typeof(newwin.name)=="string"){
				if(newwin.document.body){
					openerfocus=function(){
						if(typeof(newwin.name)=="string"){
							newwin.focus();
						}else{
							document.body.onfocus=null;
						}
					}
					document.body.onfocus=openerfocus;
					newwin.window.document.body.onunload=function(){alert(66)}
					newwin.focus();
					/*with(newwin){
						self.focus()
						opener.document.body.onfocus=function(){self.focus();opener.alert(4);}
						self.document.body.onunload=function(){opener.document.body.onfocus=null}
					}*/
					clearInterval(popInt);
				}
			}else{
				clearInterval(popInt)
			}
		},1)
	}
}

function hex2rgb(val) {
	//hex2rgb convert
	//created by Sebastian Serban v1.0 (17.06.2005)
	return [val >> 16, val >> 8 & 0xff, val & 0xff];
};

function backgroundTrans(obj,color,time,prop,callback){
	//created by Sebastian Serban
	//v1.3 (26.10.2005)
	if(prop == undefined){
		prop = "bgColor";
	}
	clearInterval(obj.interval);
	var endValue = color;
	color = hex2rgb(Number("0x"+color.substr(1)));
	var startValue = hex2rgb(Number("0x"+obj[prop].substr(1)));
	var timePast = 0;
	obj.stopTrans = function(){
		clearInterval(this.interval);
	}
	obj.endTrans = function(){
		this.stopTrans();
		this[prop] = endValue;
		if(callback!=null){
			callback();
		}
	}
	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 bgTrans(obj,start_color,color,time,callback){
	//created by Sebastian Serban
	//v1 (25.01.2006)
	obj.style.backgroundColor=start_color;
	clearInterval(obj.interval);
	var endValue = color;
	color = hex2rgb(Number("0x"+color.substr(1)));
	//var startValue = hex2rgb(Number("0x"+obj.style.backgroundColor.substr(1)));
	var startValue = hex2rgb(Number("0x"+start_color.substr(1)));
	var timePast = 0;
	obj.stopTrans = function(){
		clearInterval(this.interval);
	}
	obj.endTrans = function(){
		this.stopTrans();
		this.style.backgroundColor = endValue;
		if(callback!=null){
			callback();
		}
	}
	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.style.backgroundColor = "#"+new_color;
                }
        }
	obj.interval=setInterval(callf,10);
	callf();
}

function schimba_opt(list_from,list_to){
	if(list_from.selectedIndex!=-1){
		var old_opt=list_from.options[list_from.selectedIndex];
		var new_opt=new Option();
		var props=["text","value"];
		for(var i=0;i<props.length;i++){
			new_opt[props[i]]=old_opt[props[i]];
		}
		i=list_to.options.length;
		//while((new_opt.text)>(list_to.options[i].text) && list_to.options[i].value!=0){
			//i++;
		//}
		list_from.remove(list_from.selectedIndex);
		list_to.add(new_opt,i);
	}
}

function schimba_all_opt(list_from,list_to){
	for(var j=list_from.options.length-1;j>=0;j--){
		var old_opt=list_from.options[j];
		var new_opt=new Option();
		var props=["text","value"];
		for(var i=0;i<props.length;i++){
			new_opt[props[i]]=old_opt[props[i]];
		}
		i=list_to.options.length;
		//while((new_opt.text)>(list_to.options[i].text) && list_to.options[i].value!=0){
			//i++;
		//}
		list_from.remove(j);
		list_to.add(new_opt,i);
	}
}

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;
	}
}

function setAlpha(obj,value){
	if(nav==1){
		//obj.filters.alpha.opacity=value;
		obj.style.filter="alpha(opacity="+value+")";
	}else{
		obj.style.opacity=value/100;
		//obj.style.MozOpacity=value/100;
	}
}

function updateCounter(txt,counter,limit){
	counter.value=limit-txt.value.length;
	counter.style.color=counter.value<0 ? "#ff0000" : "#6699cc";
}
function writeFlash(divid,url,width,height,bgcolor,id,vars,transparent,menu,style){
    document.getElementById(divid).innerHTML = '<OBJECT charset="iso-8859-2" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ID="'+id+'" WIDTH="'+width+'" HEIGHT="'+height+'" style="'+style+'" flashvars="'+vars+'">'+'<param name="allowScriptAccess" value="sameDomain" />'+'<PARAM NAME=movie VALUE="'+url+'">'+'<PARAM NAME=quality VALUE=high>'+'<PARAM NAME=bgcolor VALUE="'+bgcolor+'">'+'<PARAM NAME="FlashVars" VALUE="'+vars+'">'+(menu==0 || menu==1 ? '<PARAM NAME="menu" VALUE="'+menu+'" />' : '')+(transparent ? '<PARAM NAME="wmode" VALUE="transparent" />' : '')+'<EMBED style="'+style+'" name="'+id+'" SRC="'+url+'" QUALITY=high BGCOLOR="'+bgcolor+'" WIDTH="'+width+'" HEIGHT="'+height+'" flashvars="'+vars+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'+'</EMBED></OBJECT>';
}