﻿function constructions($url, $name, $width, $height){
alert ("Stránka se připravuje. Již brzy :)"); 
}



function SwitchMenu($obj)
{
	if (document.getElementById)
	{
		var el = document.getElementById($obj + '-List-Box');

		if (el.style.display == "none")
		{
			el.style.display = "block";
			document.getElementById($obj + '-Title').className = "Close-Box";
		}
		else
		{
			el.style.display = "none";
			document.getElementById($obj + '-Title').className = "Open-Box";
		}
	}
}

function switchObj($source, $target, $value, $style)
{
	if (document.getElementById($source).value == $value)
	{
		document.getElementById($target).style.display = $style;
	}
	else
	{
		document.getElementById($target).style.display = "none";
	}
}

function disableObj($source, $target, $value)
{
	if (document.getElementById($source).value == $value)
	{
		document.getElementById($target).disabled = false;
	}
	else
	{
		document.getElementById($target).disabled = true;
	}
}

var popUpWin = 0;

function popUpEditingWindow($url, $width, $height, $confirm)
{
    var l = (screen.width - $width) / 2;
    var t = (screen.height - $height) / 2;

    if ($confirm)
    {
        if (!confirm('Chcete opravdu pokračovat?'))
        {
            return false;
        }
    }

    if (popUpWin)
    {
        if (!popUpWin.closed) popUpWin.close();
    }

    popUpWin = window.open($url,'popUpWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+$width+',height='+$height+',left='+l+',top='+t+',screenX='+l+',screenY='+t+'');

    if (window.focus) popUpWin.focus()

    return false;
}

function popHelpWindow($url, $width, $height, $confirm)
{
    var l = (screen.width - $width) / 2;
    var t = (screen.height - $height) / 2;

    if ($confirm)
    {
        if (!confirm('Chcete opravdu pokračovat?'))
        {
            return false;
        }
    }

    if (popUpWin)
    {
        if (!popUpWin.closed) popUpWin.close();
    }

    popUpWin = window.open($url,'popUpWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+$width+',height='+$height+',left='+l+',top='+t+',screenX='+l+',screenY='+t+'');

    if (window.focus) popUpWin.focus()

    return false;
}

function popUpWindow($url, $name, $width, $height)
{
    var l = (screen.width - $width) / 2;
    var t = (screen.height - $height) / 2;

    $name = window.open($url,$name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+$width+',height='+$height+',left='+l+',top='+t+',screenX='+l+',screenY='+t+'');

    if (window.focus) $name.focus()

    return false;
}

function closePopUpWindow()
{
    opener.location.reload(true);
    self.close();

    return false;
}

function delConfirmBox($id)
{
    if (!confirm('Opravdu chcete položku smazat?'))
    {
        return false;
    }
}

function insertTag($target, $begin, $end)
{
    var $element = document.getElementById($target);

    insertTagCommon($element, $target, $begin, $end, false);
}

function insertTagToOpener($target, $begin, $end)
{
    var $element = opener.document.getElementById($target);

    insertTagCommon($element, $target, $begin, $end, true);

    self.close();
}

function insertTagCommon($element, $target, $begin, $end, $opener)
{
    if (document.selection) // ie support
    {
        $element.focus();
        if ($opener)
        {
            $selection = opener.document.selection.createRange();
        }
        else
        {
            $selection = document.selection.createRange();
        }
        $selection.text = $begin + $selection.text + $end;

        // $element.insert.focus();
    }
    else if ($element.selectionStart || $element.selectionStart == "0") // mozilla and netscape support
    {
        var $startPos = $element.selectionStart;
        var $endPos   = $element.selectionEnd;

        $selection = $element.value.substring($startPos, $endPos);
        $element.value = $element.value.substring(0, $startPos) + $begin + $selection + $end + $element.value.substring($endPos, $element.value.length);
    }
    else
    {
        $element.value += $begin + $end;
    }
}

function insertImage($url, $name, $width, $height)
{
    popUpWindow($url, $name, $width, $height);

    var element;
}


function updatepocet(polozka)
        {
          id = polozka.name;
          pocet = polozka.options[polozka.selectedIndex].text;

          document.location.href = '?page=cart&action=update&id='+id+'&pocet='+pocet;
      }
	  
function smazat($id){
if (window.confirm("Opravdu chcete položku smazat ?"))
{
document.location.href = '?page=users';
}
}	

function back_cart()
        {
          id = polozka.name;
          pocet = polozka.options[polozka.selectedIndex].text;

          document.location.href = '?page=cart&action=update&id='+id+'&pocet='+pocet;
      }

