ie = (document.all) ? true : false;
nn4 = (document.layers) ? true : false;

//ie4 = document.all && !document.getElementById;
//ie5 = ie6 = document.all && document.getElementById;
nn6 = (document.getElementById && !document.all) ? true : false;

// var nn6 = (navigator.product=="Gecko") ? true : false;
//var W3C = (document.getElementById) ? true : false;

var $text = Array();
var $prev = "0";

function hideRow(name,first) {
	if (ie) { if (first=='1') $text[name] = document.all(name).innerHTML; document.all(name).innerHTML ="";	}
	if (nn6) { if (first=='1') $text[name] = document.getElementById(name).innerHTML; document.getElementById(name).innerHTML =""; }	
}
		
function changeView(name,id) {
	if (ie) { document.all(name).innerHTML =$text[name]; }	
	if (nn6) { document.getElementById(name).innerHTML =  $text[name]; }	

	document.data.showdata.value = id;
	document.data.showdata_prev.value = $prev;

$prev = id;
}	

function sel_click(qry_str_xsl,so,sf,f,l,p) {
var w=window.location.replace("search_res.php?"+qry_str_xsl+"&amp;check=1&amp;so="+so+"&amp;sf="+sf+"&amp;l="+l+"&amp;f="+f+"&amp;p="+p); 
}

var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

   if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
	else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } 

    if ( currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase() ) {

        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
        }
    }

    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }

    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } 

    if (newColor) {
        var c = null;
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            }
        }
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } 

    return true;
} 

function imageShow(id, width, height, id_advert) {
		var width = width + 150;
		var height = height + 100;
		var oh=(screen.height-height)/2;
		var ow=(screen.width-width)/2;
		window.open('/image.php?id='+id+'&width='+width+'&height='+height+'&id_a='+id_advert, 'Zdjecie', 'alwaysRaised,height='+height+',width='+width+',screenX='+ow+'+,screenY='+oh+',left='+ow+'+,top='+oh+',hotkeys=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no');
	}

function clear_form(){
	document.forms['answer']['msg'].value = "";
	document.forms['answer']['signature'].value = "";
	document.forms['answer']['u_phone'].value = "";
	document.answer.msg.focus();
}

function clear_form_bc(){
	document.forms['answer']['first_name'].value = "";
	document.forms['answer']['last_name'].value = "";
	document.forms['answer']['firm_name'].value = "";
	document.forms['answer']['city'].value = "";
	document.forms['answer']['country'].value = "";
	document.forms['answer']['zip'].value = "";
	document.forms['answer']['signature'].value = "";
	document.forms['answer']['u_phone'].value = "";
	document.forms['answer']['address'].value = "";
	document.forms['answer']['msg'].value = "";
	document.answer.first_name.focus();
}

function getType(id, qid, sel_val) {
	var width = 300;
	var height = 130;
	var oh=(screen.height-height)/2;
	var ow=(screen.width-width)/2;
	if (sel_val	== '')	{
		window.open('/modeleos.php?id='+id+'&qid='+qid, 'modele', 'alwaysRaised,height='+height+',width='+width+',left='+ow+'+,top='+oh+',hotkeys=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no');
	}
	else	{
		window.open('/modeleos.php?id='+id+'&qid='+qid+'&selected='+escape(sel_val), 'modele', 'alwaysRaised,height='+height+',width='+width+',left='+ow+'+,top='+oh+',hotkeys=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no');
	}
}

function selType(ob, qid, sel_val) {
	var marka = ob[ob.selectedIndex].value;
	if (marka == -1 || marka == '') {
		alert('Proszę wybrać markę!');
		return false;
	}
	getType(ob.value,qid,sel_val);
}

function DeleteAdvert($id_advert, $start, $text)
{
	if (confirm($text))
	window.location.href='my_adverts.php?id_advert='+$id_advert+'&action=remove&start='+$start;
}

function printOffer(id_advert) {
	var oh=(screen.height-600)/2;
	var ow=(screen.width-800)/2;
	window.open('/print_offer.php?id_advert='+id_advert, 'Drukowanie', 'alwaysRaised,height=600,width=800,screenX='+ow+'+,screenY='+oh+',left='+ow+'+,top='+oh+',hotkeys=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no');
}

function printPage()
{	
	if (window.print != null) { window.print(); } else { alert('B\263\261d'); }
}                                        