/* 

	******************************************
	**  Splošna knjižnica Javascript rutin  **
	******************************************

	(C) 2005 - 2008 Garaža studio, d.o.o. Vse pravice pridržane.

	v0.1.1, 20.05.2005:
		- prva razvojna verzija
	v0.1.2, 24.05.2005:
		- podpora za printable()
	v0.2.1, 25.05.2005:
		- prilagoditev enotnemu frameworku
	v0.3.1, 10.11.2005:
		- podpora za printableShopProd()
	v0.4.1, 21.12.2005:
		- podpora za sendlinkProd()
	v0.4.2, 29.09.2006:
		- dopolnitev prodPopup()
	v0.5.1, 24.01.2007:
		- podpora za printableShopAssistant()
	v0.6.1, 28.02.2008:
		- podpora za bestpriceWarranty()

*/


/* Odpre picture popup */
function picPopup(lang, id, w, h) {
	if (w == 0) wh = 500; else wh = w + 30;
	if (h == 0) hh = 500; else hh = h + 200;
	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,width=' + wh + ',height=' + hh);
	if (popWin != null) {
		popWin.location.href = 'applet.php?lang=' + lang + '&module=player&id=' + id;
		popWin.focus();
	}
}


/* Odpre printable popup */
function printablePage(lang, page_id, subpage_id) {
	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,height=500,width=500');
	if (popWin != null) {
		popWin.location.href = 'applet.php?lang=' + lang + '&module=printer&id=' + page_id + ',' + subpage_id;
		popWin.focus();
	}
}


/* Odpre picture popup za izdelke */
function prodPopup(lang, id, w, h) {
	if (w == 0) wh = 500; else wh = w +  10 + 20;
	if (h == 0) hh = 500; else hh = h + 100 + 20;
	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,width=' + wh + ',height=' + hh);
	if (popWin != null) {
		popWin.location.href = 'applet.php?lang=' + lang + '&module=shopplayer&id=' + id;
		popWin.focus();
	}
}


/* Odpre printable popup za izdelke */
function printableShopProd(lang, product_id) {
	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,height=500,width=500');
	if (popWin != null) {
		popWin.location.href = 'applet.php?lang=' + lang + '&module=shopprod&id=' + product_id;
		popWin.focus();
	}
}


/* Odpre okno za pošiljanje povezave */
function sendlinkProd(lang, collection_id) {
	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,height=300,width=500');
	if (popWin != null) {
		popWin.location.href = 'applet.php?lang=' + lang + '&module=shoplink&id=' + collection_id;
		popWin.focus();
	}
}


/* Odpre okno za best-price garancijo */
function bestpriceWarranty(lang, collection_id, product_id) {
	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,height=400,width=550');
	if (popWin != null) {
		popWin.location.href = 'applet.php?lang=' + lang + '&module=shoppricewarranty&id=' + collection_id + '&product_id=' + product_id;
		popWin.focus();
	}
}


/* Odpre printable popup za spletnega prodajnega pomočnika */
function printableShopAssistant() {
	var lang, assistant, order, parameters, p;

	popWin = window.open('', 'popupwindow', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,height=500,width=610');
	if (popWin != null) {
		lang 		= arguments[0];			// Jezikovna verzija
		assistant 	= arguments[1];			// Tip pomočnika
		order 		= arguments[2];			// Sortiranje rezultatov
		parameters 	= "";					// Vsi posredovani parametri
		p 			= 0;
		while (p < (arguments.length - 3)) {
			if (arguments[p + 3])  	parameters = parameters + "&par" + (p/2 + 1) + "_low="  + arguments[p + 3];
			if (arguments[p + 4]) 	parameters = parameters + "&par" + (p/2 + 1) + "_high=" + arguments[p + 4];
			p = p + 2;
		}
		// confirm('applet.php?lang=' + lang + '&module=shopassistant&assistant=' + assistant + "&order=" + order + parameters);// 
		popWin.location.href = 'applet.php?lang=' + lang + '&module=shopassistant&assistant=' + assistant + parameters;
		popWin.focus();
	}
}


/* Zapre okno */
function closeMe() {
	window.close();
}


/* Natisne okno (=print dialog) */
function printMe() {
	window.print();
}

