function ffSpecFeature()
{
	var name = $(this).attr('name');
	var jqTR = $(this).parent().parent();
	var jqTable = jqTR.parent();
	if(jqTR.attr('class')=='close'){
		jqTable.find("tr[@name='"+name+"']").show();
		jqTR.attr('class', 'open');
	}
	else{
		jqTable.find("tr[@name='"+name+"']").hide();
		jqTR.attr('class', 'close');
	}
}

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && document.getElementById == undefined) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(objElement,bolVisible){
	if(isNS4||isIE4){
		if(!bolVisible) {
			objElement.visibility ="hidden"
		} else {
			objElement.visibility ="visible"
		}     
	} else if (isIE5 || isNS6) {
		if(!bolVisible){
			objElement.style.display = "none";
		} else {
			objElement.style.display = "block";
		}
	}
	return 1;
}

function dw(s){
	document.write(s);
}

function menu_ff(name){
	var objElement = getElementById(name);
	var newCookie = 0;
	if(isNS4||isIE4){
		if(objElement.visibility == "hidden") {
			objElement.visibility == "visible";
			newCookie = 1;
		} else {
			objElement.visibility == "hidden";
			newCookie = 0;
		}     
	} else if (isIE5 || isNS6) {
		if(objElement.style.display == "none"){
			objElement.style.display='block';
			newCookie = 1;
		} else {
			objElement.style.display='none';
			newCookie = 0;
		}
	}
	document.cookie = escape(name)+'='+newCookie;
}

function getElementById(myid) {
	if (isNS4){
		objElement = document.layers[myid];
	}else if (isIE4) {
		objElement = document.all[myid];
	}else if (isIE5 || isNS6) {
		objElement = document.getElementById(myid);
	}
	return(objElement);
}

function checkLen(fld, lenMax)
{
	if(fld.value.length > lenMax)
	{
		fld.value = fld.value.substr(0, lenMax);
	}
}

function GetXmlHttpObject()
{
	var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function wndEditWare(wareId)
{
	var newWindow;
	newWindow=window.open("/shop.php?act=wareDscGet&wrs="+wareId, null, "height=450, width=650, resizable=yes, location=no, menubar=no, scrollbars=yes, status=yes, toolbar=no, top=200, left=300");
	newWindow.focus();
}
function fw01AddDesc(wareId)
{
	if(dscAddChk = document.getElementById("yesAddDescTo" + wareId)) {
		if(dscAddChk.checked){
			document.location.href = "/shop.php?act=createDesc&wrs=" + wareId;
			return true;
		}
	}
}
function fw01SetWareImg(wareId, imgMini, imgMaxi)
{
	if(imgPH = document.getElementById("wrs" + wareId + "imgPH")){
		if(imgMini != "")
			imgHTML = "<img src=\"/FLDB/wares/"+wareId+"/"+imgMini+"?"+Math.random()+"\" alt=\"\" border=\"0\" / >";
		else{
			if(imgMaxi)
				imgHTML = "фото";
			else
				imgHTML = "без фото";
		}
		if(imgMaxi)
			imgHTML = "<a href=\"/FLDB/wares/"+wareId+"/"+imgMaxi+"?"+Math.random()+"\" target=\"_blank\">"+imgHTML+"</a>";
		imgPH.innerHTML = imgHTML;
	}
}
function fw01SetWareLink(wareId, newLink)
{
	if(wareLink = document.getElementById("wrs" + wareId + "DscLnk")){
		if(newLink != "")
			imgHTML = "<a href=\""+newLink+"\" target=\"_blank\">описание</a>";
		else
			imgHTML = "";
		wareLink.innerHTML = imgHTML;
	}
}
var xmlHttp;
var fw01WareInterval = "";
var fw01WareIntervalField = 0;
function fw01UplWareImg(field)
{
	fw01WareInterval = window.setInterval(fw01UplWareImg2,10);
	fw01WareIntervalField = field;
}
function fw01UplWareImg2()
{
	window.clearInterval(fw01WareInterval);
	if(fw01WareIntervalField === 0)
		return;
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp != null){
		imgUrl = false;
		divType = fw01WareIntervalField.id.split("_")[1];
		if(divType == "Link")
			srchTag = "A";
		else
			srchTag = "IMG";
		for(i = 0; i < fw01WareIntervalField.all.length; i++){
			if(fw01WareIntervalField.all(i).tagName == srchTag){
				if(srchTag == "IMG")
					imgUrl = fw01WareIntervalField.all(i).src;
				else
					imgUrl = fw01WareIntervalField.all(i).href;
				break;
			}
		}
		if(imgUrl !== false){
			var url="?act=wareDscImgSet&id="+escape(fw01WareIntervalField.id)+"&url="+escape(imgUrl)+"&rnd="+Math.random()
			xmlHttp.onreadystatechange=fw01UplWareImg3 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
	}
	fw01WareIntervalField.innerHTML = "";
	fw01WareIntervalField = 0;
}
function fw01UplWareImg3()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
//		alert(xmlHttp.responseText);
		var aResp = xmlHttp.responseText.split("|");
		if(aResp[0] == "UPDATE_SUCCESSFULL")
			fw01SetWareImg(aResp[1], aResp[2], aResp[3]);
		else if(aResp[0] == "LINK_UPDATE_SUCCESSFULL")
			fw01SetWareLink(aResp[1], aResp[2]);
	}
}

function zoom(bigPictURL, altText, altText2)
{
	nwindow = window.open('', '', 'toobar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=820,height=670');
	nwindow.document.write(
'<html>' +
'<head>' +
'<title>Neotronik</title>' +
'<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>' +
'<link rel="stylesheet" href="st1.css" type="text/css"/>' +
'</head>' +
'<body onclick="window.close();" style="cursor: pointer; margin: 0; padding: 0; border: 0; height: 100%; max-height: 100%;" title="закрыть окно"><table width="100%" height="100%">' +
'<tr style="height: 5%;"><td style="padding: 0.5em;"><h2>' + altText + '</h2>' + altText2 + '</td></tr>' +
'<tr style="height: 95%;"><td style="text-align: center; vertical-align: middle;"><img src="' + bigPictURL + '" alt="" /></td></tr>' +
'</table></body>' +
'</html>');
	nwindow.focus();
	nwindow.document.close();
}
