// JavaScript Document
(
	function(){
		var UA=navigator.userAgent;
		is_ie=/msie/i.test(UA)&&!(/opera/i.test(UA))&&!(/mac_powerpc/i.test(UA));
		is_khtml=/Konqueror|Safari|KHTML/i.test(UA);
		is_gecko=/gecko/i.test(UA)&&!is_khtml;
	}
)();


function roll(a) {
	a.style.cursor='pointer';
	if (a.className.substr((a.className.length-1),1) == 'n') {b='o';}
	else {b='n';}
	a.className=a.className.substr(0,(a.className.length-1))+b;
}

function rollo(a){
	if (a.className.substr((a.className.length-2),2) == '_o')
		a.className=a.className.substr(0,(a.className.length-2));
	else
		a.className=a.className+'_o';
}

function rollId(a) {
	a.style.cursor='pointer';
	if (a.id.substr((a.id.length-1),1) == 'n') {b='o';}
	else {b='n';}
	a.id=a.id.substr(0,(a.id.length-1))+b;
}

function rollimg(a) {
	a.style.cursor='pointer';
	ext = a.src.substr((a.src.length-4),4);
	state = a.src.substr((a.src.length-6),2);
	if (state == '_o')
		a.src=a.src.substr(0,(a.src.length-6))+ext;
	else
		a.src=a.src.substr(0,(a.src.length-4))+'_o'+ext;
}

function check_numbers_input(a) {
	b = '';
	for (i=0;i<a.value.length;i++) {
		if ( (!isNaN(a.value.substr(i,1)) && a.value.substr(i,1) != ' ') || (a.value.substr(i,1) == '.' && a.value.indexOf('.')==i) || (a.value.substr(i,1) == '-' && i==0) ) {
			b += a.value.substr(i,1);
		}
	}
	if(a.value != b)
		a.value = b;
}

function delConfurm() {
	a = confirm('Сигурни ли сте, че искате да изтриете този запис?');
	if(a) {
		return true;
	}
	else {
		return false;
	}
}

function popUpCurrencyConvertor() {
	var a = '<scr'+'ipt src="http://gmodules.com/ig/ifr?url=http://www.pixelmedia.nl/gmodules/ucc.xml&amp;up_fromcur=EUR&amp;up_tocur=GBP&amp;up_uccwin=0&amp;synd=open&amp;w=250&amp;h=165&amp;title=Currency+Converter&amp;border=%23ffffff%7C0px%2C1px+solid+%23ff9977%7C0px%2C1px+solid+%23ffddcc%7C0px%2C1px+solid+%23ff9977%7C0px%2C1px+solid+%23ffddcc%7C0px%2C1px+solid+%23ff9977&amp;output=js"></scr'+'ipt>';
	return a;
}

function insert_flash (){
	parameters = '';
	file = '';
	id = '';
	width = '';
	height = '';
	bgcolor = '#ffffff';
	wmode = 'transparent';
	scale = 'showAll';
	
	for(var i=0; i<arguments.length; i++){
	    arg = arguments[i].split('=');
	  	if (arg[0] == 'file'){file = arg[1]}
		else if (arg[0] == 'id'){id = arg[1]}
		else if (arg[0] == 'width'){width = arg[1]}
		else if (arg[0] == 'height'){height = arg[1]}
		else if (arg[0] == 'bgcolor'){bgcolor = arg[1]}
		else if (arg[0] == 'wmode'){wmode = arg[1]}
		else if (arg[0] == 'scale'){scale = arg[1]}
		else {parameters += arguments[i]+'&'}
	}
	//alert(file + '\n' + HTMLobj + '\n' + width + '\n' +height + '\n' +bgcolor + '\n' +wmode + '\n' +parameters);
	document.getElementById(id).innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="temp" align="middle">'+
	'<param name="allowScriptAccess" value="sameDomain" />'+
	'<param name="movie" value="'+file+'" />'+
	'<param name="quality" value="high" />'+
	'<param name="bgcolor" value="'+bgcolor+'" />'+
	'<param name="wmode" value="'+wmode+'" />'+
	'<param name="scale" value="'+wmode+'" />'+
	'<param name="FlashVars" value="'+parameters+'">'+
	'<embed src="'+file+'" FlashVars="'+parameters+'" quality="high" wmode="'+wmode+'" scale="'+scale+'" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="temp" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
	'</object>';
}

/*--------[ bubble help ]-------------*/
var Xoffset = -80;
var Yoffset = 20;
var timedelay, skn, b_height, b_width; 
var bubble_start_working = false;

function bubble_set() {
	//document.body.innerHTML += '<div id="bubble" style="visibility:hidden; display:none; left:400px; top:200px; position:absolute; z-index:1;"></div>';
	document.onmousemove = bubble_move;
	skn = document.getElementById("bubble").style;
	skn.visibility="visible";
	skn.display="none";
	bubble_start_working = true;
}

function bubble(msg,width,height) {
	if(bubble_start_working) {
		var content = msg;
		b_height = width;
		b_width = height;
		document.getElementById("bubble").innerHTML=content;
		skn.display='';
		b_height = document.getElementById("bubble").offsetHeight;
		b_width = document.getElementById("bubble").offsetWidth;
	}
}

function bubble_move(e) {
	if(bubble_start_working) {
		if(is_ie)
			e=event;
		
		b_height = document.getElementById("bubble").offsetHeight;
		b_width = document.getElementById("bubble").offsetWidth;
		var xScroll = (document.all) ? (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) : window.pageXOffset;
		var yScroll = (document.all) ? (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) : window.pageYOffset;
		
		var x = e.clientX + xScroll;
		var y = e.clientY + yScroll;

		var xBorder = document.body.clientWidth + xScroll;
		var yBorder = document.body.clientHeight + yScroll;

		var temp_x = x + Xoffset;
		if(temp_x < 1)
			temp_x = 1;
		if( (temp_x+b_width) > xBorder )
			temp_x = document.body.clientWidth - b_width;
		skn.left = temp_x + 'px';
		var temp_y = y + Yoffset;
		if( (temp_y+b_height) > yBorder )
			temp_y = y - b_height - 10;
		skn.top = temp_y + 'px';
	}
}

function bubble_kill() {
	if(bubble_start_working) {
		clearTimeout(timedelay);
		skn.display="none"
	}
}
/*--------[ bubble help end ]-------------*/

function pic_bubble(file) {
	if(arguments[1] != undefined)
		var cWidth = arguments[1];
	else
		var cWidth = 100;
	if(arguments[2] != undefined)
		var cHeight = arguments[2];
	else
		var cHeight = 100;
	content='<table width="'+cWidth+'" height="'+cHeight+'" border="0" cellpadding="0" cellspacing="0" style="background-color:#FFF5D7;border:solid 1px #660000;">';
	if(arguments[3] != undefined)
		content+='<tr><td align="center" valign="middle" style="background-color: #A59051;color: #EEE2BE;font-size:10px;font-family:Verdana,Arial,Helvetica,sans-serif;"><div style="padding:3px;">'+arguments[3]+'</div></td></tr>';
	content+='<tr><td align="center" valign="middle"><img src="'+file+'" style="border:solid 1px #FFFFFF;" />';
	content+='</table>';
	bubble(content, cWidth, cHeight);
}
function thumb_pic_bubble(name, size, date) {
	content='<table border="0" cellpadding="0" cellspacing="2" style="background-color:#FFF5D7;border:solid 1px #660000;font-size:10px;">';
	content+='<tr valign="top"><td>name:</td><td><b>'+name+'</b></td></tr><tr valign="top"><td>size:</td><td><b>'+size+'</b></td></tr><tr valign="top"><td>date:</td><td><b>'+date+'</b></td></tr></table>';
	bubble(content,220,110);
}
