var url_full;
var id=1;

if (navigator.appName == "Netscape") {
 type = 1;
 layerRef="document.";
 styleRef="";
 showVar="'show'";
 hideVar="'hide'";
} else {
 type = 1;
// layerRef="parent.frmMain.";
 layerRef="document.all.";
 styleRef=".style";
 showVar="'visible'";
 hideVar="'hidden'";
}

function hideDiv(divn,x,y) {

  if(divn==310){ divn ="aaa";
  eval(layerRef+divn+styleRef+'.visibility = '+hideVar);
  }
  if(divn==30){ divn ="bbb";
  eval(layerRef+divn+styleRef+'.visibility = '+hideVar);
  }
}

//Divisions Show | Hide
function showDiv(divn,x,y) {

//img_left = document.getElementById("img_left");
Width  = Math.floor(getWindowWidth());
Height = Math.floor(getWindowHeight());

 if(divn==310){
	divn ="aaa";
	left = (Width/2)-(384-213);
	//top_  = Height*0.29;
        var wy = Math.floor(y);
        wy=wy+35;
	if(left < 220) left=220;
   	eval(layerRef+divn+styleRef+'.top = '+wy);
	eval(layerRef+divn+styleRef+'.left = '+left);
	
 	eval(layerRef+divn+styleRef+'.visibility = '+showVar);
 }		
 if(divn==30){ divn ="bbb";
	      var wy = Math.floor(y);
              wy=wy+100;
	      left = (Width/2)-(384-213);
	      if(left < 220) left=220;
	      eval(layerRef+divn+styleRef+'.top = '+wy);
	      eval(layerRef+divn+styleRef+'.left = '+left);	
 eval(layerRef+divn+styleRef+'.visibility = '+showVar);
}
 
}

function rollOut(x,y,id){
	hideDiv(id,x,y);
}
function rollOver(x,y,id){
	showDiv(id,x,y);
}


function OpenFullWin(url){

		if(url=="") return;
		var www;
		var height = window.screen.height;
		var width = window.screen.width;
		var win_dimensions = "height = " + eval(height+5) + ", width = " + eval(width );
		www = window.open(url, "", win_dimensions+',status=yes,menubar=no,resizable=no,scrollbars=yes');
		www.moveTo(-5 , -5);
//		www.moveTo(-5, -25);
		return;
} 

function Load( Anc, url){
	       Anc.href=url;
	       window.close(); 
	return true;
}
function go(name,url) {

		if(url==100){
			 window.open("http://www.artplast.com.ua","newWindow");
			 return;
		}
		if(url==60){
			 window.open("http://www.artplast.com.ua/forum_/","newWindow");
		 	 return;	
		}

	id = url;
	parent.frmMain.ifarme.location = "body.php?id="+url;		
	url_full = "body.php?id="+url+"&typ=full";		

}

function Page(lng){

var pg = document.forms[0].id.value;
var GoUrl = "";  
if(lng=="ua") GoUrl = "../ukr/index_.php?id="+pg;
if(lng=="ru") GoUrl = "../ru/index_.php?id="+pg;
if(lng=="en") GoUrl = "../eng/index_.php?id="+pg;
if(lng=="de") GoUrl = "../de/index_.php?id="+pg;


	//alert(GoUrl);
	document.location = GoUrl;				

	return false;
}


// helper functions
function strtrim(value)
{
  return value.replace(/^\s+/,'').replace(/\s+$/,'');
}

var selection = null;
var last_ul;

function expand(node, a)
{
	var good = false;
	ul = document.getElementById("ul" + node);

/*	if(last_ul!=null && last_ul!=ul){
		if (last_ul.className == "Shown") last_ul.className = "Hidden";
	
	}
 
	last_ul = ul;
*/
	img = document.getElementById("img" + node);
	if (good = (ul != null && img != null && ul.className != null && ul.innerHTML != null)) 
	{
		str = img.src;
		if ((ul.className == "Shown") || (ul.className == ""))
		{
			ul.className = "Hidden";
			img.src = str.substr(0, str.length-5) + "c.gif";
			//alert(img.src);
			if (a != null) a.href = "javascript:;";
		}
		else
			if (ul.className == "Hidden")
			{
				img.src = str.substr(0, str.length-5) + "o.gif";
				//alert(img.src);
				ul.className = "Shown";
			}

		if (strtrim(ul.innerHTML) == "")
		{
			ul.innerHTML = "<DIV onclick='cancelLoad(" + node + ");' class='loadMsg'>&nbsp;Загрузка,&nbsp;пожалуйста&nbsp;подождите...&nbsp;</DIV>";
			ul.className="";
		}

		if ((a != null) && ("object" == typeof(a)) && (window.length > 0)){
			a.target = 'fra' + node;
			//alert(a.target);
		}
	}
	return true;
}

function expand_(node, a)
{
	var good = false;
	ul = document.getElementById("ul" + node);

	if(last_ul!=null && last_ul!=ul){
		if (last_ul.className == "Shown") last_ul.className = "Hidden";
	}
 
	last_ul = ul;
	if (good = (ul != null && ul.className != null && ul.innerHTML != null)) 
	{
		if ((ul.className == "Shown") || (ul.className == ""))
		{
			ul.className = "Hidden";
			if (a != null) a.href = "javascript:;";
		}
		else
			if (ul.className == "Hidden")
			{
				ul.className = "Shown";
			}

		if (strtrim(ul.innerHTML) == "")
		{
			ul.innerHTML = "<DIV onclick='cancelLoad(" + node + ");' class='loadMsg'>&nbsp;Загрузка,&nbsp;пожалуйста&nbsp;подождите...&nbsp;</DIV>";
			ul.className="";
		}

		if ((a != null) && ("object" == typeof(a)) && (window.length > 0)){
			a.target = 'fra' + node;
		}
	}
	return true;
}

function clearSelection(node)
{
	if (node != null && node.className != null)
		node.className = "";
}

function setSelection(node)
{
	if (node != null && node.className != null)
		node.className = "Current";
}

function setSel(node)
{
	if (selection != null)
	{
		// array
		if (selection.length != null)
		{
			for (var i = 0; i < selection.length; i++)
				clearSelection(selection[i]);
		}
		// scalar value
		else
			clearSelection(selection);
	}
	selection = node;
	
	if (node)
	{
		var textNode = node;
		// array
		if (typeof(node[0]) != "undefined")
		{
			for (var i = 0; i < node.length; i++)
				setSelection(node[i]);
			// to retrieve text use first element
			textNode = node[0];
		}
		// scalar value
		else
			setSelection(node);
			
		if	(textNode != null && "object" == typeof(window.parent))
			if (window.parent.document.title != null)
				window.parent.document.title = textNode.innerHTML + " - artplast.com.ua";
	}
	return;
}

function cancelLoad(id)
{
	fra = document.getElementById("fra" + id);
	if (fra != null)
		fra.src = "about:blank";

	expand(id);
}

function loadNode(id, node, selID)
{
	ul = document.getElementById("ul"+id);
	
	if (ul != null && "object" == typeof(ul) && node && "object" == typeof(node)) 
	{
		ul.className = "Hidden";
		ul.innerHTML = node.innerHTML;
		expand(id);
	}
	
	if (selID)
	{
		a = document.getElementById("a" + selID);
		setSel(a);
	}
	else
	{
		a = document.getElementById("a" + id);
		if (selection == null)
			setSel(a);
		else
			if (selection.innerHTML == null || selection.innerHTML == '')
				setSel(a);
	}
	return;
}

function initSel(id)
{
	var select;
	var focus = null;
  // array
	if (typeof(id[0]) != "undefined")
	{
		select = new Array(id.length);
		for (var i = id.length - 1; i >= 0 ; i--)
		{
			select[i] = document.getElementById("a" + id[i]);
			if ("object" == typeof(select[i]))
				focus = select[i];
		}
	}
	else
	{
		select = document.getElementById("a" + id);
		if ("object" == typeof(select))
			focus = select;
	}

	setSel(select);
		
	if (focus != null)
	{
		if (focus.offsetTop != null && document.body.clientHeight != null)
			window.scrollTo(0, focus.offsetTop - (document.body.clientHeight / 2));
	}
	return;
}

	function SendR_RU() {

	if(document.forms[0].responsible.value==""){
	//Контактное лицо 	responsible
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	if(document.forms[0].responsible.value==""){
	//Компания		company
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	if(document.forms[0].phone1.value==""){
	//Тел/Факс		phone phone1
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	if(document.forms[0].namep.value==""){
	//Название продукции	namep
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	if(document.forms[0].size.value==""){
	//Объем			size
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	if(document.forms[0].height.value==""){
	//Высота упаковки		height
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	
	if(document.forms[0].width.value==""){
	//Ширина упаковки		width
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}

	if(document.forms[0].mat.value==""){
	//Материал		mat
	alert("Внимание: поля помеченные *,обязательные к заполнению");
	return false;
	}
	return true;
}
	function SendR_UKR() {

	if(document.forms[0].responsible.value==""){
	//Контактное лицо 	responsible
	alert("Увага: поля відмічені *, обов`язкові для заповнення");
	return false;
	}
	if(document.forms[0].responsible.value==""){
	//Компания		company
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}
	if(document.forms[0].phone1.value==""){
	//Тел/Факс		phone phone1
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}
	if(document.forms[0].namep.value==""){
	//Название продукции	namep
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}
	if(document.forms[0].size.value==""){
	//Объем			size
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}
	if(document.forms[0].height.value==""){
	//Высота упаковки		height
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}
	
	if(document.forms[0].width.value==""){
	//Ширина упаковки		width
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}

	if(document.forms[0].mat.value==""){
	//Материал		mat
	alert("Увага: поля відмічені *, обов'язкові для заповнення");
	return false;
	}
	return true;
}

function ZoomOut(images){
	images.width=70;	
	images.height=70;

}
function ZoomIn(images){
	images.width=200;	
	images.height=200;
}

function ZoomOutS(images){
	images.width=70;	
	images.height=70;
//	window.scrollBy(0, 35); 

}
function ZoomInS(images){
	
	var n1  = images.src.lastIndexOf("/"); 
	var n2  = images.src.lastIndexOf("."); 
	n1++;
	var size = n2 - n1;
	var anc = images.src.substr(n1, size); 
//	alert(anc);
	images.width=200;	
	images.height=200;
	window.location = "#"+anc;

//	alert(images.src);
//	window.scrollTo( 0,200);
	//window.scrollBy(0, 180); 
}

function ZoomOutS1(images,w,h){
	images.width=w;	
	images.height=h;
//	window.scrollBy(0, 35); 

}
function ZoomInS1(images,w,h){
	
	var n1  = images.src.lastIndexOf("/"); 
	var n2  = images.src.lastIndexOf("."); 
	n1++;
	var size = n2 - n1;
	var anc = images.src.substr(n1, size); 

	window.location = "#"+anc;
	images.width=w;	
	images.height=h;

}

function getWindowWidth() 
{ 
if (document.all) return document.body.clientWidth; 
if (document.layers) return innerWidth; 
return 800 
}

function getWindowHeight() 
{ 
if (document.all) return document.body.clientHeight; 
if (document.layers) return innerHeight; 
return 800 
}
