function popImage(imageURL) {
        var screen = getScreenSize();
        var opt='scrollbars=no,width=150,height=100,left=100,top=100';
        
        imgWin = window.open('','',opt);
        with (imgWin.document) {
                writeln('<html><head><title>...</title><style type="text/css">body { margin: auto; margin:0; padding: 0;overflow:hidden}</style>');
                writeln('<sc'+'ript type="text/javascript">');
                writeln('function resizePopup() {');
                writeln('width = document.images[0].width ; ');
                writeln('height = document.images[0].height ; ');
                writeln('if ('+ screen[0]+' <= width || '+screen[1]+' <= height) { width = '+screen[0]+'/2; height='+screen[1]+'/2; document.images[0].width = width; document.images[0].height = height;}');
                writeln('window.resizeTo(width+10, height+49);');
                writeln('if (window.innerWidth) { window.innerWidth = width ; window.innerHeight = height; }');
                writeln('}');
                writeln('</s' + 'cript>');
                writeln('</head><body bgcolor="#000000" onload="resizePopup();">')
                writeln('<img src="'+imageURL+'" onclick="window.close();" border="0" style="position: absolute; left: 0px; top: 0px; cursor: pointer;"/></body></html>');
                close();
        }
}

function popImageBorder(imageURL) {
        var screen = getScreenSize();
        var opt='scrollbars=no,width=150,height=100,left=100,top=100';
        
        imgWin = window.open('','',opt);
        with (imgWin.document) {
                writeln('<html><head><title>...</title><style type="text/css">body { margin: auto; margin:0; padding: 0;overflow:hidden}</style>');
                writeln('<sc'+'ript type="text/javascript">');
                writeln('function resizePopup() {');
                writeln('width = document.images[1].width ; ');
                writeln('height = document.images[1].height ; ');
                writeln('if(height > '+ screen[1] +'*0.8){x='+ screen[1] +'*0.8/height; document.images[1].width = width*x; width = width*x; document.images[1].height = height*x; height = height*x}');
                writeln('if ('+ screen[0]+' <= width || '+screen[1]+' <= height) { width = '+screen[0]+'/2; height='+screen[1]+'/2; document.images[1].width = width; document.images[1].height = height;}');
                writeln('window.resizeTo(width+10, height+134);');
                writeln('if (window.innerWidth) { window.innerWidth = width ; window.innerHeight = height+75; }');
                writeln('}');
                writeln('</s' + 'cript>');
                writeln('</head><body bgcolor="#000000" onload="resizePopup();">')
                writeln('<table width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="right" height="75" bgcolor="#0433B0"><img src="images/img_border_logo_HU.gif"/></td></tr><tr><td><img src="'+imageURL+'" onclick="window.close();" border="0" style="cursor: pointer;"/></td></tr></table></body></html>');
                close();
        }
}

function popImageBorderCountry(imageURL,country) {
        var screen = getScreenSize();
        var opt='scrollbars=no,width=150,height=100,left=100,top=10';
        
        imgWin = window.open('','',opt);
        with (imgWin.document) {
                writeln('<html><head><title>...</title><style type="text/css">body { margin: auto; margin:0; padding: 0;overflow:hidden}</style>');
                writeln('<sc'+'ript type="text/javascript">');
                writeln('function resizePopup() {');
                writeln('width = document.images[1].width; ');
                writeln('height = document.images[1].height; ');
                writeln('if(height > '+ screen[1] +'*0.8){x='+ screen[1] +'*0.8/height; document.images[1].width = width*x; width = width*x; document.images[1].height = height*x; height = height*x}');
                writeln('if ('+ screen[0] +' <= width || '+ screen[1] +' <= height) { width = '+ screen[0] +'/2; height='+ screen[1] +'/2; document.images[1].width = width; document.images[1].height = height;}');
                writeln('window.resizeTo(width+10, height+134);');
                writeln('if (window.innerWidth) { window.innerWidth = width ; window.innerHeight = height+75; }');
                writeln('}');
                writeln('</s' + 'cript>');
                writeln('</head><body bgcolor="#000000" onload="resizePopup();">')
                writeln('<table width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="right" height="75" bgcolor="#0433B0"><img src="images/img_border_logo_'+country+'.gif"/></td></tr><tr><td><img src="'+imageURL+'" onclick="window.close();" border="0" style="cursor: pointer;"/></td></tr></table></body></html>');
                close();
        }
}

function changeImage(id,g2_border){
	document.getElementById('mainPic').src = 'usedcar_image2.php?id='+id+'&amp;size=200';

	document.getElementById('mainPic').onclick = function() {
		if ( g2_border == 'g2_border' ) {
			popImageBorder('usedcar_image2.php?id='+id);
		}
		else {
			popImage('usedcar_image2.php?id='+id);
		}
	}
}

function changeImageCountry(id,g2_border,country){
	document.getElementById('mainPic').src = 'usedcar_image2.php?id='+id+'&amp;size=200';

	document.getElementById('mainPic').onclick = function() {
		if ( g2_border == 'g2_border' ) {
			popImageBorderCountry('usedcar_image2.php?id='+id,country);
		}
		else {
			popImage('usedcar_image2.php?id='+id);
		}
	}
}

function opendoc(docURL, w, h) {
 var opt='scrollbars=no,toolbar=no,status=no,menubar=no,width='+w+',height='+h+',left=100,top=100';
 imgWin = window.open(docURL,'',opt);
}

function opendoc2(docURL, w, h) {
 var opt='scrollbars=yes,toolbar=no,status=no,menubar=no,width='+w+',height='+h+',left=100,top=100';
 imgWin = window.open(docURL,'',opt);
}

function popupPrintPreview(carId) {
        var opt='scrollbars=no,width=850,height=700,left=100,top=100,menubar=1,toolbar=1,titlebar=1,scrollbars=1';
        previewWin = window.open('print_preview.php?type=1&car_id=' + carId,'',opt);
}


function getScreenSize() {
    var screenW = 1024, screenH = 768;
    if (parseInt(navigator.appVersion)>3) {
    screenW = screen.width;
    screenH = screen.height;
    }
    else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled()) {
        var jToolkit = java.awt.Toolkit.getDefaultToolkit();
        var jScreenSize = jToolkit.getScreenSize();
        screenW = jScreenSize.width;
        screenH = jScreenSize.height;
    }
    return new Array(screenW, screenH);
}

function load_page(url) {
    document.location.href = url;
}