//pcichon

function getPageElement(id)
{
//"NN4";
    if(document.layers)
    {
		return document.layers[id];
    }
//"ie"    
    if(document.all)
    {
		return document.all[id];
    }
//"NN6";    
    if(!document.all && document.getElementById)
    {
		return document.getElementById(id);
    }
    
    return false;
}

var rollOvers = new Array();
var timer;

function Is(){
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns =	   ((agent.indexOf('mozilla')!= -1)
				&& ((agent.indexOf('spoofer')== -1)
				&& (agent.indexOf('compatible')== -1)));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (this.major >= 5));
	this.ie = (agent.indexOf("msie")!= -1);
	this.ie4 =	   (this.ie && (this.major == 4)
				&& (agent.indexOf("msie 5.")== -1));
	this.ie5 =     (this.ie && (this.major >= 4)
				&& (agent.indexOf("msie 5.")!=-1));
}


function getAbsX(elt)
{
	return (elt.x) ? elt.x : getAbsPos(elt,"Left");
}

function getAbsY(elt)
{
	return (elt.y) ? elt.y : getAbsPos(elt,"Top");
}

function getAbsPos(elt,which)
{
	iPos = 0;
	while (elt != null)
	{
		iPos += elt["offset" + which];
		elt = elt.offsetParent;
	} return iPos;
}

function showMenu(name)
{
	hideAll();
	clearTimeout(timer);
	var item=getPageElement("menu"+name);
	
	var is = new Is();
	if (item)
	{	
		if (is.ie)
		{
			item.filters[0].Apply();
			item.style.visibility="visible";
			item.filters[0].Play();
		} 
		else 
		{ 
			item.style.visibility="visible";
		}
	}
}


function checkPos (img) 
{
	return img.offsetLeft;
}


function hideMenu(name)
{
	timer=setTimeout("hide(\'menu"+name+"\')",100);
}

function hide(name)
{
	var item=document.getElementById(name);
	if (item)
		item.style.visibility='hidden';
}


function hideAll()
{
	for (i=1;i<=6;i++) hide("menu"+i);
}

function hideAllTimer(stimer)
{
	timer=setTimeout("hideAll()",eval(stimer));
}

function imgRollOverMenu(src,idm,width,height,id)
{
	var i = src.indexOf(".",src.length-5);
	var srcOver;

	if (src.indexOf("_over")!=-1) srcOver=src;
		else srcOver = src.substr(0,i) + "_over" + src.substr(i);

	var s = '<img id="img'+idm+'" name="img'+idm+'" src="' + src + '"'
			+ ' align="absmiddle"' 
			+ ' border="0"' 
			+ ' onMouseOver="this.src=\'' + srcOver + '\';showMenu(\''+idm+'\');return true;"'
			+ ' onMouseOut="this.src=\'' + src + '\';hideAllTimer(2000);return true;"';

	if (width)
	{
		s += ' width="' + width + '"';
    }

	if (height)
    {
		s += ' height="' + height + '"';
    }

	if (id)
    {
		s+= ' id="' + id + '"';
    }

	s += '>';

	rollOvers[rollOvers.length] = new Image();
	rollOvers[rollOvers.length-1].src = srcOver;
	rollOvers[rollOvers.length-1].src2 = src;
	rollOvers[rollOvers.length-1].id = id;

	document.write(s);
}

function imgRollOver(src,id,width,height)
{
	var i = src.indexOf(".",src.length-5);
	var srcOver;

	if (src.indexOf("_over")!=-1) srcOver=src;
		else srcOver = src.substr(0,i) + "_over" + src.substr(i);

	var s = '<img src="' + src + '"'
			+ ' border="0"' 
			+ ' onMouseOver="this.src=\'' + srcOver + '\';"'
			+ ' onMouseOut="this.src=\'' + src + '\'"';

	if (width)
		s += ' width="' + width + '"';

	if (height)
		s += ' height="' + height + '"';

    if (id)
        s+= ' id="' + id + '"';

	s += '>';

	rollOvers[rollOvers.length] = new Image();
	rollOvers[rollOvers.length-1].src = srcOver;
	rollOvers[rollOvers.length-1].src2 = src;
	rollOvers[rollOvers.length-1].id = id;

	document.write(s);
}

function imgOverById(id,src)
{
	if (!src)
	{
		var i;
		for (i=0; i<rollOvers.length; i++)
		{
			if (rollOvers[i].id == id)
			{
				src = rollOvers[i].src;
			}
		}
	}

	var img = document.getElementById(id);
	if (img)
	{
		img.src = src;
	}
}

function imgOutById(id,src)
{
	if (!src)
	{
		var i;
    	for (i=0; i<rollOvers.length; i++)
		{
			if (rollOvers[i].id == id)
			{
                src = rollOvers[i].src2;
            }
        }
    }

    var img = document.getElementById(id);
    if (img)
    {
        img.src = src;
    }
}

function showBiger(path, width, height, title, top, left)
{
	if (width=='') width=16;
	if (height=='') height=16;

	width = width*1;
	height = height*1;

    var margin = 50;

    if (!title) title = path;
    width += margin;
    height += margin*2;


    // scroll if neaded 
    var margin = 100;
    var scroll = "no";
    if (((window.screen.width-margin<width) || (window.screen.height - margin<height)))
    {
        scroll = "yes";
        if (window.screen.width - margin < width) width = window.screen.width - margin;
        if (window.screen.height - margin < height) height = window.screen.height - margin;
    }

    if (!top) top = (window.screen.height - margin - height) / 2
    if (!left) left = (window.screen.width - margin - width) / 2

	if( path.charAt(0) != '/' )
	  path = '/' + path;

    var rand = Math.random();
    var wnd = window.open("/products/modalphoto.xml?rand=" + rand + "&image=" + path + "&title=" + title, "larger",
        "top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + ",status=0,help=0,scroll=" + scroll);
    
    wnd.focus();
}

function PopupWindow(url,width,height,windowName)
{
	_PopupWindow(url,width,height,150,windowName);
}

function _PopupWindow(url,width,height,top,windowName)
{
	var center_x = (screen.width - width)/2;
	var center_y = (screen.height - height)/2;	
//    var num = Math.round(Math.random()*10000000);
//    var str = new String(num);
    var win = window.open(url,windowName,"toolbar=no,location=no,directories=no,"+
      "status=no,menubar=no,scrollbars=yes,resizable=no,"+
      "copyhistory=no,left="+center_x+",top="+center_y+",width="+width+",height="+height);
}
// -----------------------------------------------------------------------------
// NTC
// -----------------------------------------------------------------------------

function take(href)
{
    var width  = 750;
    var height = 600;
    var center_x = (screen.width - width)/2;
    var center_y = (screen.height - height)/2;	
    var win = window.open(href,"work_element","toolbar=no,location=no,directories=no,"+
        "status=no,menubar=no,scrollbars=no,resizable=yes,"+
        "copyhistory=no,left="+center_x+",top="+center_y+",width="+width+",height="+height);
    win.openerWindow = window;
    win.focus();
}

function showTips(id)
{
    var width  = 750;
    var height = 600;
    var center_x = (screen.width - width)/2;
    var center_y = (screen.height - height)/2;	
    var win = window.open("/online/work_element_tips.xml?document_id=" + id ,"tips" , "toolbar=no,location=no,directories=no,"+
        "status=no,menubar=no,scrollbars=no,resizable=yes,"+
        "copyhistory=no,left="+center_x+",top="+center_y+",width="+width+",height="+height);
    win.focus();
}

function topMenu(src, name)
{
    if (name != sectionName)
    {
        imgRollOver(src);
    }
    else
    {
        var i = src.indexOf(".",src.length-5);
        var srcOver = src.substr(0,i) + "_over" + src.substr(i);

        var s = '<img align="absmiddle" src="' + srcOver + '" border="0"\>';
        document.write(s);
    }
}
