// суть скрипта
var open_img = new Image();
open_img.src = '/images/cat0o.gif';
var closed_img = new Image();
closed_img.src = '/images/cat0c.gif';

function showhide(obj, reccurent) {
	if (
		(obj.tagName == "SELECT") ||
		(obj.tagName == "INPUT") ||
		(obj.tagName == "A") ||
		(obj.tagName == "IMG") ||
		(obj.tagName == "OPTION") ||
		(obj.tagName == "TEXTAREA")) {
		return(false);
	}

	if (obj.tagName == "TABLE" && reccurent == 0) {
		while ((obj != null) && !(obj.tagName == "TR" && obj.attributes.getNamedItem('thisid') != null)) {
			obj = obj.parentNode;
		}
	}

	if (obj == null) {
		return(false);
	}
	var table = obj;
	while ((table != null) && (table.tagName != "TABLE")) {
		table = table.parentNode;
	}

	if (reccurent == 0) {
		if (obj.attributes.getNamedItem('showhidestatus') == null) {
			var status = document.createAttribute('showhidestatus');
			status.value = 'hide';
			obj.attributes.setNamedItem(status);
					  //alert(status.value);
		} else {
			obj.attributes.removeNamedItem('showhidestatus');
		}
	}

	var node;
	var key = 0;
	var imgObj = document.getElementById('img_' + obj.thisid);
	if (imgObj != null) {
		imgObj.src = (imgObj.src == open_img.src ? closed_img.src : open_img.src);
	}

	if (table != null) {
		var thisid = obj.attributes.getNamedItem('thisid');
		for (var i = 0; (node = table.getElementsByTagName("tr").item(i)); i++) {
			var parent = node.attributes.getNamedItem('parent');
			if ((parent != null) && (parent.value == thisid.value)) {
				node.style.display = (node.style.display == 'none' ? 'block' : 'none');
				if ((node.style.display == "block") && (parent.value > 10000000)){
          key = 1;
        }				
/*
				var sub_thisid = node.attributes.getNamedItem('thisid');
				var sub_status = node.attributes.getNamedItem('showhidestatus');
				if (sub_thisid != null && sub_status == null) {
					showhide(node, 1);
				}
*/
			}
			parent = null;
		}
	}
	if (key == 1){
    alert("Товар из новой коллекции заказывается отдельно от остальных направлений");
  }	
	return(false);
}

function draw(mark) {
  	big_img = new Image();
  	big_img.src = ("images/items_big/"+mark+"_big.jpg");
	img_wait(mark);
}
  
function img_wait(mark) {
  	if((big_img.width != 0) && (big_img.height != 0)) {
		sb(mark);
	}
	else {
		func = "img_wait('" + mark + "')";
    	interval = setTimeout(func, 20);
	}
}
  
function sb(draw) {
  	sW = big_img.width; //350;
	sH = big_img.height; //520;
	options="toolbar=0, status=0, menubar=0, location=0, scrollbars=0, resizable=1, top=50, left=50, width=" + sW + ", height=" + sH;
	OpenWindow=open(big_img.src, draw, options);
	OpenWindow.document.write('<html><head><title>' + big_img.src + '<\/title><\/head><body style="background: url(\''+big_img.src+'\') no-repeat;" onclick=\'javascript: window.opener="x"; window.close();\'><\/body><\/html>');
    OpenWindow.resizeBy(sW - OpenWindow.document.body.clientWidth,
         sH - OpenWindow.document.body.clientHeight)
	OpenWindow.focus();
	self.name="main";
}
