function openwindow(url, width, height) {
	// hack for IE 7
	if(navigator.appVersion.indexOf('MSIE 7') != -1) {
		height += 20;
	}

	xposition = 20; yposition = 20;
	if ((parseInt(navigator.appVersion) >= 4 )){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}

	args = "width=" + width + ","
		    + "height=" + height + ","
			+ "location=0,"
			+ "menubar=0,"
			+ "resizable=0,"
			+ "scrollbars=no,"
			+ "status=0,"
			+ "titlebar=0,"
			+ "toolbar=0,"
			+ "hotkeys=0,"
			+ "screenx=" + xposition + ","  //NN Only
			+ "screeny=" + yposition + ","  //NN Only
			+ "left=" + xposition + ","     //IE Only
			+ "top=" + yposition;           //IE Only
	ww = window.open(url, '', args);
}



function addEvent(obj, sType, fn, rmFn)
{
	if(obj.addEventListener) {
		try
		{
			obj.removeEventListener(sType, rmFn, false);
		}
		catch(e)
		{
		}
		obj.addEventListener(sType, fn, false);
	}
	else if (obj.attachEvent)
	{
		try
		{
			var r = obj.detachEvent('on'+sType, rmFn);
		}
		catch(e)
		{
		}
		var r = obj.attachEvent('on'+sType, fn);
	}
	else
	{
		alert("Neimanoma prisieti veiksmo!");
	}
}

function removeEvent(obj, sType, fn) {
	if (obj.removeEventListener) {
		obj.removeEventListener(sType, fn, false);
	}
	else {
		obj.detachEvent('on' + sType, fn);
	}
}

function removeAllEditors() {
	for(i = 0; i < document.forms.length; i++) {
		if(document.forms[i] != null)
			for(j = 0; j < document.forms[i].elements.length; j++) {
				element = document.forms[i].elements[j];
				if (tinyMCE.get(element.id) != null) {
					element.value = tinyMCE.get(element.id).getContent();
					tinyMCE.execCommand('mceRemoveControl', 'false', element.id);
				}
			}
	}
}

function toggleEditor(id) {
	var elm = document.getElementById(id);
	// submitinant tevine forma reikia nuimti redaktoriu
	if (tinyMCE.getInstanceById(id) == null) {
		$('.toggle-editor-on').hide();
		$('.toggle-editor-off').show();
		tinyMCE.execCommand('mceAddControl', 'false', id);
	}
	else {
		$('.toggle-editor-off').hide();
		$('.toggle-editor-on').show();
		tinyMCE.execCommand('mceRemoveControl', 'false', id);
	}
}

var isAnimation1 = false;
var isAnimation2 = false;

var maxMargin = 600;

if(navigator.userAgent.indexOf('MSIE 6') != -1) {
	maxMargin = 360;
}

function animateBlockInner(pIndex)
{	
	if(pIndex == 1) {
		if($('.quickMenuSeparator1').css('marginLeft') == '0px' && !isAnimation1) {
			isAnimation1 = true;
			$('.quickMenuSeparator1').animate({marginLeft : maxMargin }, 600,  'easeInOutExpo', function() {isAnimation1 = false;});
		}

		if($('.quickMenuSeparator2').css('marginLeft') == maxMargin + 'px' && !isAnimation2) {
			isAnimation2 = true;
			$('.quickMenuSeparator2').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation2 = false;});
		}
	}
	else if(pIndex == 2) {
		if($('.quickMenuSeparator1').css('marginLeft') == maxMargin + 'px' && !isAnimation1) {
			isAnimation1 = true;
			$('.quickMenuSeparator1').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation1 = false;});
		}
		
		if($('.quickMenuSeparator2').css('marginLeft') == '0px' && !isAnimation2) {
			isAnimation2 = true;
			$('.quickMenuSeparator2').animate({marginLeft : maxMargin }, 600,  'easeInOutExpo', function() {isAnimation2 = false;});
		}
	}
	else if(pIndex == 3) {
		if($('.quickMenuSeparator1').css('marginLeft') == maxMargin + 'px' && !isAnimation1) {
			isAnimation1 = true;
			$('.quickMenuSeparator1').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation1 = false;});
		}
		
		if($('.quickMenuSeparator2').css('marginLeft') == maxMargin + 'px' && !isAnimation2) {
			isAnimation2 = true;
			$('.quickMenuSeparator2').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation2 = false;});
		}
	}
}

function animateBlockTitle(pIndex)
{
	if(navigator.userAgent.indexOf('MSIE 6') != -1) {
		maxMargin = 280;
		somePlus = 100;
	}
	else {
		maxMargin = 380;
		somePlus = 0;
	}
	
	if(pIndex == 1) {
		flashAction('setActive', 'true', 'text1');
		flashAction('setActive', 'false', 'text2');
		flashAction('setActive', 'false', 'text3');
		
		if($('.frontBlockSeparator1').css('marginLeft') == '0px' && !isAnimation1) {
			isAnimation1 = true;
			$('.frontBlockSeparator1').animate({marginLeft : maxMargin }, 600,  'easeInOutExpo', function() {isAnimation1 = false;});
		}
	
		if($('.frontBlockSeparator2').css('marginLeft') == maxMargin + somePlus + 'px' && !isAnimation2) {
			isAnimation2 = true;
			$('.frontBlockSeparator2').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation2 = false;});
		}
	}
	else if(pIndex == 2) {
		flashAction('setActive', 'false', 'text1');
		flashAction('setActive', 'true', 'text2');
		flashAction('setActive', 'false', 'text3');
		
		if($('.frontBlockSeparator1').css('marginLeft') == maxMargin + 'px' && !isAnimation1) {
			isAnimation1 = true;
			$('.frontBlockSeparator1').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation1 = false;});
		}
		
		if($('.frontBlockSeparator2').css('marginLeft') == '0px' && !isAnimation2) {
			isAnimation2 = true;
			$('.frontBlockSeparator2').animate({marginLeft : maxMargin + somePlus }, 600,  'easeInOutExpo', function() {isAnimation2 = false;});
		}
	}
	else if(pIndex == 3) {
		flashAction('setActive', 'false', 'text1');
		flashAction('setActive', 'false', 'text2');
		flashAction('setActive', 'true', 'text3');
		
		if($('.frontBlockSeparator1').css('marginLeft') == maxMargin + 'px' && !isAnimation1) {
			isAnimation1 = true;
			$('.frontBlockSeparator1').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation1 = false;});
		}
		
		if($('.frontBlockSeparator2').css('marginLeft') == maxMargin + somePlus + 'px' && !isAnimation2) {
			isAnimation2 = true;
			$('.frontBlockSeparator2').animate({marginLeft : 0 }, 600,  'easeInOutExpo', function() {isAnimation2 = false;});
		}
	}
}
