// JavaScript Document
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 delConfurm() {
	a = confirm('Сигурни ли сте, че искате да изтриете този запис?');
	if(a) {
		return true;
	}
	else {
		return false;
	}
}

function rollo(a){
	//if(bubble_start_working) {
		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) {
	if(bubble_start_working) {
		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 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 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))+'_n'+ext;
	else
		a.src = a.src.substr(0,(a.src.length-6))+'_o'+ext;
}

function showHideFaq( obj ) {
	if(document.getElementById(obj).style.display == 'none') {
		document.getElementById(obj).style.display='block';
		document.getElementById('ico_'+obj).src='images/ico_minus.gif';
	}
	else {
		document.getElementById(obj).style.display='none';
		document.getElementById('ico_'+obj).src='images/ico_plus.gif';
	}
}

function showHide( obj ) {
	if(document.getElementById(obj).style.display == 'none') {
		document.getElementById(obj).style.display='block';
	}
	else {
		document.getElementById(obj).style.display='none';
	}
}

function insert_flash (){
	parameters = '';
	file = '';
	id = '';
	width = '';
	height = '';
	bgcolor = '#ffffff';
	wmode = 'transparent';
	scale = 'showAll';
	name = 'flashName';
	
	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 if (arg[0] == 'name'){name = arg[1];}
		else {parameters += arguments[i] + '&'}
	}

	document.getElementById(id).innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" name="'+name+'" id="'+name+'" align="middle">'+
	'<param name="allowScriptAccess" value="always" />'+
	'<param name="movie" value="'+file+'" />'+
	'<param name="quality" value="high" />'+
	'<param name="bgcolor" value="'+bgcolor+'" />'+
	'<param name="wmode" value="'+wmode+'" />'+
	'<param name="scale" value="'+scale+'" />'+
	'<param name="FlashVars" value="'+parameters+'">'+
	'<embed src="'+file+'" FlashVars="'+parameters+'" quality="high" wmode="'+wmode+'" scale="'+scale+'" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="FF_'+name+'" id="FF_'+name+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
	'</object>';
}

function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document['FF_'+movieName];
}
function callToActionscript() {
	//getFlashMovie("browseBTN").sendToActionscript(document.getElementById('album_visibility').value,document.getElementById('category').value,document.getElementById('album').value,document.getElementById('new_album').value);
	getFlashMovie("browseBTN").sendToActionscript('','',document.getElementById('album').value,'');
}

var pup_obj, pup_popUpMenu, timer_id;
function showPopUpDelay(obj, popUpMenu) {
	pup_obj = obj;
	pup_popUpMenu = popUpMenu;
	timer_id = setTimeout("showPopUp(pup_obj, pup_popUpMenu)", 700);
}
function hidePopUpDelay(){
	clearTimeout(timer_id);
}
// PopUp menu show
function showPopUp(obj, popUpMenu) {
	curheight = obj.offsetHeight;
	curwidth = obj.offsetWidth;
	curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	document.getElementById(popUpMenu).style.top = curtop+'px';
	document.getElementById(popUpMenu).style.left = (curleft + curwidth)+'px';
	document.getElementById(popUpMenu).style.display = 'block';
	hidePopUp(popUpMenu);
}

// PopUp menu hide
function hidePopUp(obj){
	var IE = document.all?true:false
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = getMouseXY;

	function getMouseXY(e) {
		if (IE) {
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		} 
		else {
			tempX = e.pageX;
			tempY = e.pageY;
		}
		
		//alert(tempY+' '+curtop);
		
		if (tempX < curleft - 20){
			document.getElementById(obj).style.display = 'none';
		}
		if (tempX > curleft + document.getElementById(obj).offsetWidth + 10){
			document.getElementById(obj).style.display = 'none';
		}  
		if (tempY < curtop){
			//document.getElementById(obj).style.display = 'none';
		}
		if (tempY > curtop + document.getElementById(obj).offsetHeight + curheight + 400){ // koregirano zaradi selecta na albumite
			document.getElementById(obj).style.display = 'none';
		}
	}
}


// CURRENT PROJECT FUNCTIONS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function checkIt( obj, hiddenField ) {
	if( document.getElementById('mark['+hiddenField+']').value == hiddenField ) {
		document.getElementById('mark['+hiddenField+']').value = '';
		obj.style.background = "url(images/btn_checkbox_n.jpg)";
	}
	else {
		document.getElementById('mark['+hiddenField+']').value = hiddenField;
		obj.style.background = "url(images/btn_checkbox_checked_n.jpg)";
	}
}
