
function fixPNG(element)
{
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{
		var src;
		
		if (element.tagName=='IMG')
		{
			if (/\.png$/.test(element.src))
			{

				src = element.src;
				element.src = "../images/spacer.gif";
			}
		}
		else
		{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if (src)
			{
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		
		if (src) 
		{
			element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		}
	}
}



active_obj = null;
cX = 0;
cY = 0;

function div_drag(obj, event)
{
	if(!event)
		event = window.event;
	if(!active_obj)
	{
		active_obj = obj;
		cX = event.clientX;
		cY = event.clientY;
		/*rX = new String(active_obj.style.left);
		rX = rX.substring(0,rX.length-2) ;*/
		//active_obj.style.left = Math.floor(rX) + 100;
		//alert(active_obj.style.left);
		
		
	}
	return false;
	//alert(active_obj.style.left);
	/**
		запомнить объект,
		если объек уже есть, то игнорировать
	*/
	//alert(obj);
	//mouse_downed = true;
	//alert("div_drag");
}
function div_move(event)
{
	/**
	здесь вычислять координаты запомненного объекта и перемещать
	*/
	if(!event)
		event = window.event;
	if(active_obj)
	{			
		tX = event.clientX;
      	tY = event.clientY;      	
      	rX = new String(active_obj.style.left);
      	rX = rX.substring(0,rX.length-2);
      	rY = new String(active_obj.style.top);
      	rY = rY.substring(0,rY.length-2);      	
      	
      	active_obj.style.left =Math.floor(rX) + tX - cX;
      	active_obj.style.top =Math.floor(rY) + tY - cY;
      	cX = event.clientX;
      	cY = event.clientY;
      	
	}
	return false;
	/*if(mouse_downed)
		alert("div_move");*/
}
function div_drop(obj)
{
	/**
	освободить объект
	*/
	/*if(obj == active_obj)
	{*/
		active_obj = null;
		cX = 0;
		cY = 0;
	//}
	return false;
//	alert("div_drop");
	
}

function CompanyClick()
{
	if(document.getElementById('company_popup'))
	{
	  return;	
	}
	var bs = document.getElementById("body_sz");
	bs.style.height = "1083px";
	var divId = customFunctionCreateCompositeWindow('../company/?top=1','../company/?cont=1','../company/?bottom=1',711,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-481,0,0,true);	
	window.scrollTo(0,0);
	var obj = document.getElementById('dhtml_goodies_id' + divId);
	obj.style.height = "1083px";

}
function resizeDoc()
{
	var bs = document.getElementById("body_sz");
	bs.style.height = "";

}
function ProjectRDGo()
{	
	if(document.getElementById('rd_popup'))
	{
	  return;	
	}
	var divId = customFunctionCreateCompositeWindow('../projects/?proj=rd&top=1','../projects/?proj=rd&cont=1','../projects/?proj=rd&bottom=1',709,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-41,0,0,true);
	window.scrollTo(0,0);		
var obj = document.getElementById('dhtml_goodies_id' + divId);
obj.style.height =(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight; //"100%";
}
function ProjectRLGo()
{
	if(document.getElementById('rl_popup'))
	{
	  return;	
	}

	var divId = customFunctionCreateCompositeWindow('../projects/?proj=rd&top=1','../projects/?proj=rl&cont=1','../projects/?proj=rd&bottom=1',709,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-41,0,0,true);
	window.scrollTo(0,0);		
	var obj = document.getElementById('dhtml_goodies_id' + divId);
	obj.style.height = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;//"100%";
}

function ProjectCarnageGo()
{
	if(document.getElementById('carnage_popup'))
	{
		return;	
	}
	var divId = customFunctionCreateCompositeWindow('../projects/?proj=carn&top=1','../projects/?proj=carn&cont=1','../projects/?proj=carn&bottom=1',709,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-41,0,0,true);
	window.scrollTo(0,0);
	var obj = document.getElementById('dhtml_goodies_id' + divId);
	obj.style.height =((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight); //"100%";	
}
function AllVacanGo()
{	
/*
	Если окно открыто, то надо на него перейти
*/
/*	if(document.getElementById('vacan_popup'))
	{
		return;	
	}*/

	if(!document.getElementById("vacan_link_1"))
	{
		var divId = customFunctionCreateCompositeWindow('../vacan/?top=1','../vacan/?cont=1','../vacan/?bottom=1',709,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-41,0,0,true);
		var obj = document.getElementById('dhtml_goodies_id' + divId);
		obj.style.height = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight; //"100%";
	}
	window.scrollTo(0,0);	
	
}
function VacanIdGo(id)
{
	if(document.getElementById("vacan_link_"+id))
	{
		OpenVacan(document.getElementById("vacan_link_"+id),id);
	}
	else
	{
		var pFunc = function() {OpenVacan(document.getElementById("vacan_link_"+id),id);}
		var divId = customFunctionCreateCompositeWindow('../vacan/?top=1','../vacan/?cont=1','../vacan/?bottom=1',709,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-41,0,0,true, pFunc);
		window.scrollTo(0,0);	
		var obj = document.getElementById('dhtml_goodies_id' + divId);
		obj.style.height = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight; //"100%";
	}
	
}
function ShowVacan(ajaxIndex,divId)
{	
	for(var i=1;i<8;i++)
	{
		if(i!==divId)
		{
			
			document.getElementById(i).style.display = "none";
			if(document.getElementById("vacan_link_"+i))
				document.getElementById("vacan_link_"+i).style.color = "#561063";
			
		}
	}
	document.getElementById(divId).innerHTML = ajaxObjects[ajaxIndex].response;	
	document.getElementById(divId).style.display = "block";
	document.getElementById(divId).style.padding ="10px 0px 10px 0px";
}
function OpenVacan(obj,id)
{	
	/**
	Запустить ajax
	*/
	document.getElementById(id).innerHTML = "Загрузка...";
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = "../vacan/get_vacan.php?vacan_id="+id;	
	ajaxObjects[ajaxIndex].onCompletion = function(){ ShowVacan(ajaxIndex,id); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();
	
	obj.onclick = function() { CloseVacan(obj,id);}
	obj.style.color = "#C42588";
        obj.id = "vacan_link_"+id;
}
function CloseVacan(obj, id)
{	
	//alert(id);
	document.getElementById(id).innerHTML = "";		
	document.getElementById(id).style.display = "none";
	obj.onclick = function() { OpenVacan(obj,id);}
	obj.style.color = "#561063";
}
function cleanActiveWindow()
{
	cleanNode(activeWindow);
	hideWindow();
}
function cleanNode(dest)
{
  while (dest.firstChild)
    dest.removeChild(dest.firstChild);
}

function CommandGo()
{
	hideWindow();
	resizeDoc();
	var divId = customFunctionCreateCompositeWindow('../company/?top=1','../company/?type=command&cont=1','../company/?type=command&bottom=1',1000,((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight)-41,0,0,true);
	window.scrollTo(0,0);
	var obj = document.getElementById('dhtml_goodies_id' + divId);
	obj.style.height = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight; //"100%";
	obj.style.width = "100%";

}

function CompanyLowsGo()
{
	hideWindow();
	resizeDoc();	
	///((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight) - 41
	var window_height = 6250;
	var bs = document.getElementById("body_sz");
	bs.style.height = window_height + "px";
	
	var divId = customFunctionCreateCompositeWindow('../company/?top=1','../company/?type=lows&cont=1','../company/?type=command&bottom=1',711, window_height-41,0,0,true);
	window.scrollTo(0,0);
	var obj = document.getElementById('dhtml_goodies_id' + divId);
	obj.style.height =window_height +"px";

	//obj.style.height =window_height; ///(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}

function CompanyBusiness()
{
	hideWindow();
	resizeDoc();	
	///((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight) - 41
	var window_height = 4850;
	var bs = document.getElementById("body_sz");
	bs.style.height = window_height + "px";

	var divId = customFunctionCreateCompositeWindow('../company/?top=1','../company/?type=bus&cont=1','../company/?type=command&bottom=1',711, window_height-41,0,0,true);
	window.scrollTo(0,0);
	var obj = document.getElementById('dhtml_goodies_id' + divId);
	obj.style.height =window_height +"px";
}
