nav = navigator.appName.indexOf("Microsoft")!= -1 ? 1 : 2;
function mouseX(evt){
    return evt.pageX ? evt.pageX : evt.clientX+(document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
}

function mouseY(evt){
    return evt.pageY ? evt.pageY : evt.clientY+(document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
}
function addEvent(obj,type,fn,bubbling){
    bubbling=bubbling || false;
    if(window.addEventListener){
        //Standard
        obj.addEventListener(type,fn,bubbling);
        return true;
    }else if(window.attachEvent){
        //IE
        obj['e'+type+fn]=fn;
        obj.attachEvent('on'+type,function(){
            obj['e'+type+fn](window.event);
        });
        //obj.attachEvent('on'+type,fn);
        return true;
    }
    return false;
}
addListener=addEvent;

function removeEvent(obj,type,fn,bubbling){
    bubbling=bubbling || false;
    if(obj.removeEventListener){
        //Standard
        obj.removeEventListener(type,fn,false);
        return true;
    }else if(window.detachEvent){
        //IE
        obj.detachEvent('on'+type,obj['e'+type+fn]);
        obj['e'+type+fn]=null;
        return true;
    }
    return false;
}
function SSToolTip(obj,title,content,width,fixed,padding,alpha){
    if(typeof(SSTT)=='undefined'){
        SSTT=document.createElement('div');
        document.body.appendChild(SSTT);
        SSTT.id='SSToolTip';
        SSTT.style.display="none";
        SSTT.style.position="absolute";
        SSTT.style.zIndex=10100;
        SSTT.style.left='0px';
        SSTT.style.top='0px';
        SSTT.padding=padding==null ? "4px" : padding;
        SSTT.moved=0;
        SSTT.onmouseout=function(){
            this.style.display='none';
        }
        SSTT.intID=setInterval(function(){
            if(SSTT.style.display=='' && !SSTT.moved){
                SSTT.update(SSTT.last_e);
            }
            SSTT.moved=0;
        },500);
        SSTT.update=function(e){
            if(e){
                SSTT.last_e={pageX:e.pageX,clientX:e.clientX,clientY:e.clientY,pageY:e.pageY};
            }
            if(SSTT.move){
                if(e=e ? e : window.event){
                    SSTT.moved=1;
                    var mousex=mouseX(e)+15;
                    var mousey=mouseY(e)+15;
                    var x=mousex;
                    var y=mousey;
                    if(x+SSTT.clientWidth>document.body.scrollLeft+document.body.clientWidth){
                        x=mousex-SSTT.clientWidth-20;
                        if(x<document.body.scrollLeft){
                            x=document.body.scrollLeft+document.body.clientWidth-SSTT.clientWidth;
                        }
                    }
                    if(y+SSTT.clientHeight>document.body.scrollTop+document.body.clientHeight){
                        y=mousey-SSTT.clientHeight-20;
                        if(y<document.body.scrollTop){
                            y=document.body.scrollTop;
                        }
                    }
                    SSTT.style.left = x+'px';
                    SSTT.style.top = y+'px';
                    if(SSTT.stopafterfirst){
                        SSTT.move=0;
                    }
                }
            }
        }
        addEvent(document,'mousemove',SSTT.update);
        SSTT.hide=function(){
            this.style.display='none';
            SSTT.move=0;
        }
    }
    if(obj==null){
        SSTT.hide();
    }else{
        title=decodeURIComponent(title);
        width=width==null ? "" : width;
        alpha=alpha==null ? (content==null ? 100 : 100) : alpha;
        setAlpha(SSTT,alpha);
        SSTT.style.cursor=(SSTT.onclick=obj.onclick) ? "pointer" : "default";
        SSTT.onmouseover=obj.onclick ? function(){
            this.style.display='';
        } : null;
        if(content==null){
            SSTT.innerHTML='<!--[if lte IE 6]><iframe id="SSTT_iframe" style="position:absolute;z-index:-100;filter:alpha(opacity=0);"></iframe><![endif]--><table style="border:solid 1px #36c;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(color=#333333,direction=135,strength=2,enabled=true);width:'+width+';" cellPadding="1" cellSpacing="0"><tr><td style="padding:'+SSTT.padding+';">'+title+'</td></tr></table>';
        }else{
            content=decodeURIComponent(content);
            SSTT.innerHTML='<!--[if lte IE 6]><iframe id="SSTT_iframe" style="position:absolute;z-index:-100;filter:alpha(opacity=0);"></iframe><![endif]--><table style="border:solid 1px #36c;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(color=#333333,direction=135,strength=2,enabled=true);width:'+width+';" cellpadding="1" cellspacing="0">'+(title!="" ? '<tr><td style="background:#4B5F6D;color:#fff;padding:'+SSTT.padding+';"><b>'+title+'</b></td></tr>' : '')+'<tr valign=top><td style="padding:'+SSTT.padding+';">'+content+'</td></tr></table>';
        }
        SSTT.style.display = "";
        var iframe=document.getElementById('SSTT_iframe');
        if(iframe!=null){
            iframe.style.width=SSTT.offsetWidth;
            iframe.style.height=SSTT.offsetHeight;
        }
        if(obj.onmouseout==null){
            obj.onmouseout=function(){
                SSTT.hide();
            }
        }
        SSTT.move=1;
        SSTT.stopafterfirst=fixed;
        SSTT.update();
    }
}
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 chr(cod) {
	return String.fromCharCode(cod);
}

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

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

function formatNumber(nr, decimals, dec_point, sep) {
	//created by Sebastian Serban
	//v1.1 (12.06.2006)
	if (decimals == undefined) {
		decimals = 2;
	}else if(decimals<0){
		decimals=Math.abs(decimals);
		var exact_decimals=1;
	}else{
		var exact_decimals=0;
	}
	if (dec_point == undefined) {
		dec_point = ",";
	}
	if (sep == undefined) {
		sep = ".";
	}
	nr = String(nr).split(".");
	nat = nr[0];
	nr[0] = "";
	if(nr[1]==null){
		nr[1]="";
	}
	if(exact_decimals){
		for(var i=nr[1].length;i<decimals;i++){
			nr[1]+="0";
		}
	}
	for (var i = nat.length; i>0; i -= 3) {
		nr[0] = nat.substr(Math.max(i-3, 0), 3+Math.min(i-3, 0))+sep+nr[0];
	}
	nr[0] = nr[0].substr(0, nr[0].length-sep.length);
	return nr[0]+(nr[1] != "" ? dec_point+nr[1].substr(0, decimals) : "");
}

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);
			try{
				obj[prop] = "#"+new_color;
			}catch(err){
				//alert(err.description+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);
			try{
				obj.style.backgroundColor = "#"+new_color;
			}catch(err){
				//alert(err.description+new_color);
			}
		}
	}
	obj.interval=setInterval(callf,10);
	callf();
}

function addOption(theSel, theText, theValue){
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex){ 
	var selLength = theSel.length;
	if(selLength>0){
		theSel.options[theIndex] = null;
	}
}

function moveOptions(theSelFrom,theSelTo){

	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;

	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(var i=selLength-1;i>=0;i--){
		if(theSelFrom.options[i].selected){
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}

	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selectedCount-1; i>=0; i--){
		addOption(theSelTo, selectedText[i], selectedValues[i]);
	}
	if(theSelFrom.onchange){
		theSelFrom.onchange();
	}
	if(theSelTo.onchange){
		theSelTo.onchange();
	}
}

function isBisYear(year){
	return (year%4==0 && year%100!=0) || year%400==0
}

function correctDate(f,nume){
	var zileinluna=[0,31,29,31,30,31,30,31,31,30,31,30,31];
	zileinluna[2]=isBisYear(f[nume+'[0]'].value) ? 29 : 28;
	var nrz=zileinluna[Number(f[nume+'[1]'].value)];
	if(f[nume+'[2]'].value>nrz){
		f[nume+'[2]'].selectedIndex=nrz-(f[nume+'[2]'].options.length==31 ? 1 : 0);
	}
}

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 writeFlash(divid,url,width,height,bgcolor,id,vars,transparent,menu,style){
	document.getElementById(divid).innerHTML = '<OBJECT charset="UTF-8" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,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>';
}

function updateCounter(txt,counter,limit){
	counter.value=limit-txt.value.replace(/\r\n/g,'\n').replace(/\n/g,'\r\n').length;
	counter.style.color=counter.value<0 ? "#ff0000" : "#6699cc";
}

function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	return charCode<31 || charCode>48 && charCode<57;
}

function checkKey(evt,str){
	var charCode = (evt.which) ? evt.which : event.keyCode
	var re=new RegExp("^["+str+"]$");
	return charCode<31 || re.test(chr(charCode));
}

arr_escape=[];
arr_escape["ă"]="%C4%83";
arr_escape["Ă"]="%C4%82";
arr_escape["î"]="%C3%AE";
arr_escape["Î"]="%C3%8E";
arr_escape["â"]="%C3%A2";
arr_escape["Â"]="%C3%82";
arr_escape["ş"]="%C5%9F";
arr_escape["Ş"]="%C5%9E";
arr_escape["ţ"]="%C5%A3";
arr_escape["Ţ"]="%C5%A2";
arr_escape["+"]="%2B";
arr_escape["/"]="%2F";
arr_unescape=[];
for(var i in arr_escape){
	arr_unescape[arr_escape[i]]=i;
}

function rawurlencode(str){
	var result="";
	for(var i=0;i<str.length;i++){
		var chr=str.charAt(i);
		if(arr_escape[chr]!=undefined){
			result+=arr_escape[chr];
		}else{
			result+=escape(chr);
		}
	}
	return result;
}

function rawurldecode(str){
	var result="";
	for(var i=0;i<str.length;i++){
		var chr=str.charAt(i);
		if(arr_unescape[chr]!=undefined){
			result+=arr_unescape[chr];
		}else{
			result+=unescape(chr);
		}
	}
	return result;
}


/***************************************************/

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[15,25]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

var defaultimageheight = 200;	// maximum image size.
var defaultimagewidth = 200;	// maximum image size.

var timer;


var t_id = setInterval(animate,20);
var pos=0;
var dir=2;
var len=0;

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-600px"
	clearTimeout(timer);
}

function showtrail(imagename,title,width,height){
	i = imagename
	t = title
	w = width
	h = height
	timer = setTimeout("show('"+i+"',t,w,h);",0);
}
function show(imagename,title,width,height)
{
 document.onmousemove=followmouse; 
    var imagename=imagename;
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500))
	{
		var imagename=imagename;
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		
		defaultimageheight = height
		defaultimagewidth = width
	
		

		
		newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px"><div id="loader_container"><div id="loader"><div align="center">Loading website preview...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
		newHTML = newHTML + '' + ' '+title + ''
		
    	newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0"></div>';
		newHTML = newHTML + '</div>'; 
		
		if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 )
		{
			newHTML = newHTML+'<iframe style="display:none;" src="about:blank" scrolling="no" frameborder="0" width="'+width+'" height="'+height+'"></iframe>';
		}		

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
		

	}
}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
			ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

function animate()
{
var elem = document.getElementById('progress');
if(elem != null) {
if (pos==0) len += dir;
if (len>32 || pos>79) pos += dir;
if (pos>79) len -= dir;
if (pos>79 && len==0) pos=0;
elem.style.left = pos;
elem.style.width = len;
}
}

function remove_loading() {
this.clearInterval(t_id);
var targelem = document.getElementById('loader_container');
targelem.style.display='none';
targelem.style.visibility='hidden';
var t_id = setInterval(animate,60);
}

