

window.onload = img_replace;

//определяем высоту и ширину экрана, для функции add_to_basket()
var ScrWindth = screen.width;
var ScrHeight = screen.height;


function img_replace() {
	if (document.getElementById("img_big")) {
		big_img = document.getElementById("img_big");
		var mini_fotos = document.getElementById("example");
		var mini_fotos = mini_fotos.getElementsByTagName("p");
		var mini_fotos_len = mini_fotos.length;
		for (i=0; i<mini_fotos_len; i++) {
			if (mini_fotos[i].className == "mini_foto") {
				mini_fotos[i].onclick = replaceImg;
			}
		}
	}
	else return;
}

function replaceImg() {

	tagP = this;
	tagPP = tagP.nextSibling;
	while (tagPP.nodeName != "P") tagPP = tagPP.nextSibling;
	var clone_n = tagPP.firstChild.cloneNode(true);

	big_img_a = big_img.firstChild;
	while (big_img_a.nodeName != "A") big_img_a = big_img_a.nextSibling;
	var remove_p = big_img.removeChild(big_img_a);
	//alert(big_img);
	big_img.appendChild(clone_n);
}


function ShowFlash(src, width, height) {
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+width+"\" height=\""+height+"\" title=\"РОЯЛТОН ГРУПП\">");
	document.write("<param name=\"movie\" value=\""+src+"\">");
	document.write("<param name=\"quality\" value=\"high\">");
	document.write("<param name=\"wmode\" value=\"transparent\">");
	document.write("<embed src=\""+src+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\">");
	document.write("</embed></object>");
}

function add_to_basket(status, productID, count, site_dir){
	count=(count>0 ? count : 1);
	if (status=='Y'){
		//window.location = url;
		winName=window.open(site_dir+'personal/add2basket.php?status='+status+'&productID='+productID+'&count='+count,'someshit','width=450,height=120, resizable=yes, left='+(ScrWindth/2-225)+',top='+(ScrHeight/2-60));
		winName.focus();
	}else{
		alert('Товара нет на складе. Товар не будет помещён в корзину!');
	}
}
function sort_by_field(field, order, obj){
	document.forms['filter_form'].elements['SORT_FIELD'].value = field;
	document.forms['filter_form'].elements['SORT_ORDER'].value = order;
	document.forms['filter_form'].submit();
}

