function zamknij() {
	document.getElementById('divIMG').style.display = "none";
}

function schowajobr() {
	document.getElementById('powiekszenie').src = '../img/cp.gif';
	document.getElementById('divIMG').style.left = '-4000px';
	zapasscroll = -1;
}

function keyCheck(e) {
    var keynum;
    
    if(window.event) { //IE
        keynum = e.keyCode;
    }else if(e.which) {
        keynum = e.which;
    }
    return String.fromCharCode(keynum);
}

function numOnly(e) {
    var keychar = keyCheck(e);
    return ( /\d|[\b]/.test(keychar) );
}

function checkData(data) {
    return ( /^(((?:19|20)\d\d)[-](0*[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01]))|[\b]$/.test(data) );
}

function checkReference(form) {
    with(form) {
        if ( tytul.value.length==0 ) {
            alert("Brak tytułu!");
            return false;            
        }
        if ( checkData(data.value) == false ) {
            alert("Niepoprawna data!");
            return false;
        }
    }
    return true;
}

function getSection() {
    if ( null != document.URL.match("referencje") ) return "referencje";
        else if ( null != document.URL.match("komunikaty") ) return "komunikaty";
        else if ( null != document.URL.match("mediaonas") ) return "mediaonas";
        else if ( null != document.URL.match("sekcje") ) return "sekcje";
        else if ( null != document.URL.match("produkty") ) return "produkty";
        else if ( null != document.URL.match("nowosci") ) return "nowosci";            else if ( null != document.URL.match("gl_promo") ) return "gl_promo";            else if ( null != document.URL.match("casestudy") ) return "casestudy";    
    return false;
}

function drop(id) {
    var section = getSection();
    if(section && confirm('Usun±ć element z bazy?')) {
        document.location = "actions.php?task=drop&section=" + section + "&id=" + id;
    }
}

function edit(id) {
    var section = getSection();
    if ( section ) {
        document.location = "index.php?src=" + section + "&id=" + id;
    }    
}

function unlinkFile(id) {
    var sel = document.getElementById("linked_files");
    if ( sel.options[sel.selectedIndex].text != "NIC" ) {
        window.location = "actions.php?task=unlink_file&id=" + id + "&name=" + sel.options[sel.selectedIndex].text;
    }
}

function linkFile(id) {
    var sel = document.getElementById("file_list");
    if ( sel.options[sel.selectedIndex].text != "NIC" ) {
        window.location = "actions.php?task=link_file&id=" + id + "&name=" + sel.options[sel.selectedIndex].text;
    }
}

function showTip(evt,name)
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		x = evt.clientX + document.body.scrollLeft;
		y = evt.clientY + document.body.scrollTop;
	}
	else
	{
		x = evt.pageX;
		y = evt.pageY; 	
	}
	obj = document.getElementById(name);
	obj.style.left = (x + 15) + 'px';
	obj.style.top = (y + 15) + 'px';
	obj.style.visibility = 'visible';
}

function hideTip(name)
{
	obj = document.getElementById(name);
	obj.style.visibility = 'hidden';
}

function changeFotos()
{
    var sel = document.getElementById("foto_type")
    var item = sel.options[sel.selectedIndex].value
    window.location = 'index.php?src=zdjecia&dzial=' + item
}

function news(id) {
    if(confirm('Czy zmienić status produktu?')) {
        window.location = "actions.php?task=news&id=" + id
    }
}
