var main_img_id = 0;
var main_img_w = 0;
var main_img_h = 0;

function doLoader2(w,h,what,l,tp) {
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

    return window.open("modLoader.php?loadwhat="+what+"&tp="+tp,"load"+l,"toolbar=no,scrollbars=yes,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition);
}


function doLoader3(w,h,what,l,tp) {
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

    return window.open("modLoader.php?loadwhat="+what+"&tp="+tp,"load"+l,"toolbar=no,scrollbars=no,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition);
}

function delImgValues(i,a) {
    document.frames['imagefiles'].document.forms[0].what.value=i;
    document.frames['imagefiles'].document.forms[0].action.value='del_img_files';
    if (confirm('Biztosan törölni akarod?')) document.frames['imagefiles'].document.forms[0].submit();
    else return false;
}

function showPreview(i) {
	doLoader2(630, 600, 'subVehicle&tab=preview', 10, i);
}

function changeImg(n, id, w, h) {
	var i = getElById('img_main');
	var s = getElById('img_small_'+n);
	var t = new String(s.src);
	i.src = t.replace('_tns', '_tnn');
	main_img_id = id;
	main_img_w = w;
	main_img_h = h;
}

function setPerPages(n) {
	document.forms['forlist'].elements['action'].value = 'setperpage';
	document.forms['forlist'].elements['what'].value = n;
	document.forms['forlist'].submit();
}

function setPages(n) {
	document.forms['forlist'].elements['action'].value = 'setpage';
	document.forms['forlist'].elements['what'].value = n;
	document.forms['forlist'].submit();
}

function setOrder(n) {
	document.forms['forlist'].elements['action'].value = 'setorder';
	document.forms['forlist'].elements['what'].value = n;
	document.forms['forlist'].submit();
}

function openImgBox(i, w, h, t) {
	if (t == 'main' && main_img_id != 0) {
		var width = parseInt(main_img_w) + 40; 
		var height = parseInt(main_img_h) + 50;
		doLoader2(width, height, 'modSVehicle', 'img', 'a&par=showImg&imgID='+main_img_id);
	} else {
		var width = parseInt(w) + 40; 
		var height = parseInt(h) + 50;
		doLoader2(width, height, 'modSVehicle', 'img', 'a&par=showImg&imgID='+i);
	}
}

function showPrintBox(i) {
		doLoader2(550, 550, 'modSVehicle', 'print', 'a&par=showprint&id='+i);
}

function showEmailBox(i) {
		doLoader3(590, 550, 'modSVehicle', 'email', 'a&par=showemail&id='+i);
}

function showFinBox(i) {
		doLoader3(590, 500, 'modSFinance', 'fin', 'a&par=showmatrix&id='+i);
}

function showQuestionBox(i) {
		doLoader3(590, 250, 'modSVehicle', 'question', 'a&par=showquestions&id='+i);
}

function submitFilterBox() {
	window.frames['listbox'].document.forms['status_form'].elements['filter'].value = document.getElementById('status_filter').value;
	window.frames['listbox'].document.forms['status_form'].submit();
}

function setStatusNoteBox(t) {
	window.frames['infobox'].document.forms['status_info_form'].elements['action'].value = '';
	window.frames['infobox'].document.forms['status_info_form'].elements['what'].value = t;
	window.frames['infobox'].document.forms['status_info_form'].submit();
}
