function OpenWindow(url, jmeno, w, h, res) {
	var leftVal = ( screen.width - w ) / 2 ;
	var topVal = ( screen.height - h ) / 2 ;

	Fokus = window.open(url, jmeno,'status=0,resizable=0,scrollbars=' + res + ',top=' + leftVal + ',left=' + topVal + ',menubar=0,width=' + w + ',height=' + h);
	Fokus.focus() ;
}

function OpenIframe( url, E, width, height, nameframe ) {

	if ( !nameframe ) {
		var nameframe;
		nameframe = 'iframe' ;
	}

	if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
              {

               elm=document.getElementById( nameframe ) ;
               
               var cursor = getPosition( E ) ;
                if (document.all && !window.opera) {
                  elm.style.pixelLeft = cursor.x;
                  elm.style.pixelTop = cursor.y;
                 }
                 else {
                  elm.style.left = cursor.x + "px";
                  elm.style.top = cursor.y + "px";
                 }

               elm.style.display = "block"
              }
	document.getElementById( nameframe ).src = url ;
	document.getElementById( nameframe ).frameborder = '0' ;
	document.getElementById( nameframe ).width = width ;
	document.getElementById( nameframe ).height = height ;
}

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}


function IframeClose ( elm ) {
	window.top.document.getElementById( elm ).style.display = 'none';
}

function redir_menu_sel ( input, xsl, reason, id_art, article ) {
	var value = document.getElementById(input).value ;
	OpenWindow('/admin/a_menu_sel.php?id=' + value + '&form=' + input + '&xsl=' + xsl + '&reason=' + reason + '&id_art=' + id_art + '&article=' + article, 'Select', 500, 600, 1 ) ;
}

function redir_new_sel ( input ) {
	var value = document.getElementById(input).value ;
	OpenWindow('/admin/a_new_sel.php?id=' + value + '&form=' + input,'Select', 500, 600, 1 ) ;
}

function redir_version_sel ( inp ) {
	var val = document.getElementById( inp ).value ;
	OpenWindow('eshop_version_sel.php?id=' + val + '&form=' + inp, 'Select', 500, 600, 1 ) ;
}

function OpenHelp( E, textdiv ) {
	if( document.getElementById ) {
	
		var elm = document.getElementById( 'help' )
		if (document.all && !window.opera) {
			x = E.clientX + document.body.scrollLeft + 10 ;
			y = E.clientY + document.body.scrollTop + 10 ;
		} else {
			x = E.pageX + 10 ;
			y = E.pageY + 10 ;
		}
		if (document.all && !window.opera) {
			elm.style.pixelLeft = x ;
			elm.style.pixelTop = y;
		}else {
			elm.style.left = x + "px";
			elm.style.top = y + "px";
		}
		elm.style.display = "block" ;
		elm.innerHTML = textdiv ;
	}
}

function CloseHelp () {
	if ( document.getElementById( 'help' ).style.display = '' )
		document.getElementById( 'help' ).style.display = 'none' ;
}

function GalleryWindow( url, iwidth, iheight ) {
	var gallery ;
	var leftVal = ( screen.width - iwidth ) / 2 ;
	var topVal = ( screen.height - iheight ) / 2 ;

	gallery = window.open( url, 'gallery', 'top=' + topVal + ', left=' + leftVal + ', width=' + ( iwidth + 10 ) + ', height=' + ( iheight + 10 ) + ', scrollbars=no' ) ;
	gallery.focus() ;
}
