var butn = '';

function ChangeLamp(idLamp, idButton) {
	
	var refLamp = document.getElementById(idLamp);
	var refButton = document.getElementById(idButton);
	var isOn = false; 
	var buttonUP = true;

	this.turnON = function() {
		if(!isOn) {
			isOn = true;
			refLamp.className = 'lamp_on';
		}
	}
	this.turnOFF = function() {
		if(isOn && !buttonUp) {
			isOn = false;
			refLamp.className = 'lamp_off';
		}
	}
	this.clickMouse = function() {
		if(!isOn) {
			isOn = true;
			refLamp.className = 'lamp_on';
			refButton.className = 'lamp_butn_on';				
			buttonUp = true;
					
		}else {
			isOn = false;
			refLamp.className = 'lamp_off';
			refButton.className = 'lamp_butn_off';
			buttonUp = false;
		}
	}
	this.changeLabel = function(id, label_on, label_off) {
	  var ref = document.getElementById(id);
	  if(ref.firstChild.nodeValue == label_on) ref.innerHTML = label_off;
	  else ref.innerHTML = label_on;
	  
	  
	}
}
/*--------------------------------------------------------
++++++++++++++++++function ScrollNews++++++++++++++++++++++++
---------------------------------------------------------*/
function ScrollNews(id) {
		
	var maxHeight = 0;
	var myId = null;
	var myRef = null;
	var offsetY = 0;
	var step = 15;
	var timeOut = 500;

	if(id)
		myId = id;
	
	if(document.getElementById(myId)) {
		
		myRef = document.getElementById(myId);
		maxHeight = myRef.offsetHeight;
	}
	this.scrollUp = function() {
		if(offsetY < 0 )
			offsetY += step;
		myRef.style.marginTop = offsetY+"px";
		
		
	}
	this.scrollDown= function() {
		if(-offsetY < (maxHeight - 150)) {
			offsetY -= step;
			myRef.style.marginTop = offsetY+"px";
			
		}
	}
}


function divScrollOver(id) {
	if (window.addEventListener)
        	window.addEventListener('DOMMouseScroll', wheel, false);
	window.onmousewheel = wheel;
}
function divScrollOut(id) {
	if (window.removeEventListener)
		window.removeEventListener('DOMMouseScroll', wheel, false);
}
function handle(delta) {
	if (delta < 0)
		MyScroll.scrollDown();
        else
		MyScroll.scrollUp();
}
function wheel(event){
        var delta = 0;
        if (!event) 
                event = window.event;
        if (event.wheelDelta) { 
                delta = event.wheelDelta/120;
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { 
                delta = -event.detail/3;
        }
        if (delta)
                handle(delta);
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}


var MyBrowser = new Browser();

/*--------------------------------------------------------
++++++++++++++++++function Browser++++++++++++++++++++++++
---------------------------------------------------------*/
function Browser() {
 
  var n = navigator;
  var nameNavigator = navigator.appName;
  var uAgent = n.userAgent;
  var version = parseInt(navigator.appVersion);


  //OS
  var isWindow = (uAgent.indexOf('Win') != -1);
  var isLinux = (uAgent.indexOf('Linux') != -1);
  var isMac = (uAgent.indexOf('Mac') != -1);
 
  //type browser
  var isOpera = (uAgent.indexOf('Opera') != -1);
  var isMoz = (uAgent.indexOf('Gecko') != -1);
  var isIE = (uAgent.indexOf('MSIE') != -1);
  if(isIE)
    version = parseFloat(navigator.appVersion.split("MSIE")[1]);
  var isKonq = (uAgent.indexOf('Konqueror') != -1);
  var isSaf = (uAgent.indexOf('Safari') != -1);
  

  //method OS
  this.isWindow = function() {return isWindow;}
  this.isLinux = function() { return isLinux; }
  this.isMac = function() { return isMac; }

  //method type browser
  this.isOpera = function() { return isOpera; }
  this.isMozilla = function() { return (isMoz && !isKonq); }
  this.isIE = function() { return isIE; }
  this.isKonqueror = function() { return isKonq; }
  this.isSafari = function()  { return isSaf; }
	
/*====----  IE -----======*/
  this.isIE = function()  { return isIE; }
  this.isIE6 = function() { 
    if(isIE && version == 6) return true; return false;
  }
  this.isIE6AndMore = function() { 
    if(isIE && version >= 6) return true; return false;
  }
  this.isIE7 = function() { 
    if(isIE && version == 7) return true; return false;
  }
  this.isIE7AndMore = function() { 
    if(isIE && version >= 7) return true; return false;
  }

}


function hideBlocks(id)
{
	document.getElementById(id).style.color = '#999999';
	for(var i=1; i<=7; i++)
	{
		document.getElementById("h4"+i).style.color='#999999';
		document.getElementById("txt"+i).style.color='#999999';
		document.getElementById("butn"+i).className='butn_more';
		if(i == 7)
		{
			if(MyBrowser.isIE6())
				document.getElementById("butn"+i).className='butn_more bm_style';
			else
				document.getElementById("butn"+i).className='butn_more';
		}
	}
}

var display = '';
function showBlock(num, cls)
{
	document.getElementById("corn"+num).className=cls;
	if(!display)
	{
		document.getElementById("h4"+num).style.color='#000000';
		document.getElementById("txt"+num).style.color='#000000';
		document.getElementById("butn"+num).className='butn_more_act';
		
		if(MyBrowser.isIE6())
		{
			document.getElementById("IEtop"+num).className='f_tt2';
			document.getElementById("IEright"+num).className='f_rr2';
			document.getElementById("IEbottom"+num).className='f_bb2';
			document.getElementById("IEleft"+num).className='f_ll2';
			//if(num == 7) document.getElementById("butn"+num).className='butn_more_act bm_style';
		}
		else
		{			
			document.getElementById("top"+num).style.background='url(img/hint_t3.png) no-repeat left top';
			document.getElementById("right"+num).style.background='url(img/hint_r3.png) no-repeat right top';
			document.getElementById("bottom"+num).style.background='url(img/hint_b3.png) no-repeat right bottom';
			document.getElementById("left"+num).style.background='url(img/hint_l3.png) no-repeat left bottom';
		}
		display = num;
	}
	else
	{	
		document.getElementById("h4"+num).style.color='#999999';
		document.getElementById("txt"+num).style.color='#999999';
		document.getElementById("butn"+num).className='butn_more';

		if(MyBrowser.isIE6())
		{
			document.getElementById("IEtop"+num).className='f_tt';
			document.getElementById("IEright"+num).className='f_rr';
			document.getElementById("IEbottom"+num).className='f_bb';
			document.getElementById("IEleft"+num).className='f_ll';
			//if(num == 7) document.getElementById("butn"+num).className='butn_more bm_style';
		}
		else
		{
			document.getElementById("top"+num).style.background='url(img/hint_t2.png) no-repeat left top';
			document.getElementById("right"+num).style.background='url(img/hint_r2.png) no-repeat right top';
			document.getElementById("bottom"+num).style.background='url(img/hint_b2.png) no-repeat right bottom';
			document.getElementById("left"+num).style.background='url(img/hint_l2.png) no-repeat left bottom';
		}
		display = '';
	}
}

var newStr = '';
function fieldFocus(obj, str)
{
	if(obj.value == str) obj.value = '';
	newStr = str;
}

function fieldBlur(obj)
{
	if(!obj.value) obj.value = newStr;
}


function enter(obj, cls)
{
	obj.className='enter_'+cls;
	document.getElementById("entxt").className='enter_txt_'+cls;
}

function changeButton(obj, cls)
{
	obj.className=cls;
}

var state = '';
function showForm(div)
{
	if(!state)
	{
		document.getElementById(div).style.display='block';
		state = div;
	}
	else
	{
		document.getElementById(div).style.display='none';
		state = '';
	}
}

function showWindow(windId)
{	
	var h = document.getElementById("mainblock").offsetHeight;
	var windId = document.getElementById(windId);
	
	windId.style.position = 'absolute';
	windId.style.height = h+'px';
	windId.style.width = '100%';
	windId.style.zIndex='4';
	windId.style.backgroundColor = '#ffffff';
	windId.style.opacity = 0.6;
	windId.style.filter = 'alpha(opacity=60)';
	if(MyBrowser.isMozilla()) windId.style.height = 60+h+'px';
}

function hideSelect()
{
	if(MyBrowser.isIE6()) {
		document.getElementById("sel").style.visibility='hidden';
		document.getElementById("curPr").style.visibility='hidden';
	}
}

function hideWindow(id1, id2)
{
	document.getElementById(id1).style.display='none'; 
	document.getElementById(id2).style.display='none'; 
	if(MyBrowser.isIE6()) {
		document.getElementById('curPr').style.visibility='visible'; 
		document.getElementById('sel').style.visibility='visible';
	}
}


function checkHeight(cont)
{
	var scr = screen.height;
	var h = document.getElementById("mainBlock").clientHeight;
	var dif = scr - h;
	var c = document.getElementById("copy");
	var entBack = document.getElementById("midBlock");

	if(scr <= 960)
	{
		if(cont)
		{
			var contBlock = document.getElementById("contBlock");
			c.style.position = 'relative';
			c.style.top = dif+'px';
			contBlock.style.marginTop='-20px';
		}
		else
		{
			c.style.position = 'relative';
			c.style.top = dif+40+'px';
			if(MyBrowser.isMozilla()) c.style.top = dif-100+'px';
			if(MyBrowser.isIE6()) c.style.top = dif+20+'px';
			entBack.style.marginTop = '3%';
		}
	}	
}


function hidePyramidBlocks()
{
	for(var i=1; i<=9; i++)
	{
		document.getElementById('hc'+i).style.color = '#c0e7f8';
		document.getElementById('sp'+i).style.color = '#bbbbbb';
		document.getElementById('txtc'+i).style.color = '#bbbbbb';
		document.getElementById('a'+i).style.color = '#bbbbbb';
		document.getElementById('color'+i).style.opacity = 0.8;
		document.getElementById('color'+i).style.filter = 'alpha(opacity=80)';
	}
}

var obj = '';
function showPyramidBlock(num)
{
	var top = document.getElementById('topc'+num);
	var bottom = document.getElementById('bottomc'+num);
	var left = document.getElementById('leftc'+num);
	var right = document.getElementById('rightc'+num);
	var h5 = document.getElementById('hc'+num);
	var span = document.getElementById('sp'+num);
	var p = document.getElementById('txtc'+num);
	var a = document.getElementById('a'+num);
	var color = document.getElementById('color'+num);
	
	var topIE = document.getElementById("IEtopc"+num);
	var bottomIE = document.getElementById("IEbottomc"+num);
	var leftIE = document.getElementById("IEleftc"+num);
	var rightIE = document.getElementById("IErightc"+num);
	
	var src = 'img/hintC_';
		
	if(!obj)
	{
		if(MyBrowser.isIE6())
		{
			topIE.className='f_tt_'+num;
			bottomIE.className='f_bb_'+num;
			leftIE.className='f_ll_'+num;
			rightIE.className='f_rr_'+num;
		}
		else
		{
			top.style.background = 'url('+src+'t_'+num+'.png) no-repeat top left';
			bottom.style.background = 'url('+src+'b_'+num+'.png) no-repeat bottom right';
			left.style.background = 'url('+src+'l_'+num+'.png) no-repeat bottom left';
			right.style.background = 'url('+src+'r_'+num+'.png) no-repeat top right';
		}
		
		h5.style.color = '#14b1f2';
		span.style.color = '#000000';
		p.style.color = '#010000';
		a.style.color = '#000000';
		color.style.opacity = 0.8;
		color.style.filter = 'alpha(opacity=80)';
		
		obj = num;
	}
	else
	{
		if(MyBrowser.isIE6())
		{
			topIE.className='f_tt';
			bottomIE.className='f_bb';
			leftIE.className='f_ll';
			rightIE.className='f_rr';
		}
		else
		{
			top.style.background = 'url('+src+'t5'+'.png) no-repeat top left';
			bottom.style.background = 'url('+src+'b5'+'.png) no-repeat bottom right';
			left.style.background = 'url('+src+'l5'+'.png) no-repeat bottom left';
			right.style.background = 'url('+src+'r5'+'.png) no-repeat top right';
		}
		
		h5.style.color = '#c0e7f8';
		span.style.color = '#bbbbbb';
		p.style.color = '#bbbbbb';
		a.style.color = '#bbbbbb';
		color.style.opacity = 1;
		color.style.filter = 'alpha(opacity=100)';
		obj = '';
	}
}

var promptState = '';
function changePrompt()
{
	var top = document.getElementById('ptop1');
	var bottom = document.getElementById('pbottom1');
	var left = document.getElementById('pleft1');
	var right = document.getElementById('pright1');
	
	var topIE = document.getElementById('pIEtop1');
	var bottomIE = document.getElementById('pIEbottom1');
	var leftIE = document.getElementById('pIEleft1');
	var rightIE = document.getElementById('pIEright1');
	
	var p = document.getElementById('pr1');
	var corn = document.getElementById('corner1');
	
	if (!promptState)
	{
		if(MyBrowser.isIE6())
		{
			topIE.className='f_tt2';
			bottomIE.className='f_bb2';
			leftIE.className='f_ll2';
			rightIE.className='f_rr2';
		}
		else
		{
			top.style.background='url(img/hint_t3.png) no-repeat left top';
			right.style.background='url(img/hint_r3.png) no-repeat right top';
			bottom.style.background='url(img/hint_b3.png) no-repeat right bottom';
			left.style.background='url(img/hint_l3.png) no-repeat left bottom';
		}
		p.style.color = '#000000';
		corn.className='c7_mo';
		promptState = 1;
	}
	else
	{
		if(MyBrowser.isIE6())
		{
			topIE.className='f_tt';
			bottomIE.className='f_bb';
			leftIE.className='f_ll';
			rightIE.className='f_rr';
		}
		else
		{
			top.style.background='url(img/hint_t2.png) no-repeat left top';
			right.style.background='url(img/hint_r2.png) no-repeat right top';
			bottom.style.background='url(img/hint_b2.png) no-repeat right bottom';
			left.style.background='url(img/hint_l2.png) no-repeat left bottom';
		}
		p.style.color = '#999999';
		corn.className='c7';
		promptState = '';
	}
}

function changeColor(pId, txt, linkId, uptime)
{
	for(var i=1; i<=9; i++)
	{
		if(pId) document.getElementById(pId+i).style.color='#cccccc';
		if(txt) document.getElementById(txt+i).style.color='#cccccc';
		if(linkId) document.getElementById(linkId+i).style.color='#bbbbbb';
		if(uptime) document.getElementById(uptime+i).style.color='#bbbbbb';
	}
}

var blockState = '';
function showPortfolioBlock(num, uptime, price)
{
	if(!blockState)
	{
		document.getElementById('prev'+num).className = 'empBack_mo';
		document.getElementById('ptxt'+num).style.color = '#000000';
		document.getElementById('link'+num).style.color = '#008fc5';
		if(price)
		{
			document.getElementById('prBack'+num).className = 'price_back2_mo';
			document.getElementById('price'+num).style.color = '#008fc5';
		}
		if(uptime) document.getElementById(uptime+num).style.color='#000000';
		blockState = num;
	}
	else
	{
		document.getElementById('prev'+num).className = 'empBack';
		document.getElementById('ptxt'+num).style.color = '#999999';
		document.getElementById('link'+num).style.color = '#bbbbbb';
		if(price)
		{
			document.getElementById('prBack'+num).className = 'price_back2';
			document.getElementById('price'+num).style.color = '#cccccc';
		}
		if(uptime) document.getElementById(uptime+num).style.color='#bbbbbb';
		blockState = '';
	}
}

var field = '';
function showField()
{
	var area = document.getElementById("ar");
	var input = document.getElementById("inp");
	var h = document.getElementById("hdln");
	if (!field)
	{
		area.style.display = 'block';
		input.style.display = 'block';
		h.innerHTML = 'close form';
		field = 1;
	}
	else
	{
		area.style.display = 'none';
		input.style.display = 'none';
		h.innerHTML = 'add comment';
		field = '';
	}
}

var butn = '';
function showComments()
{
	var leftCol = document.getElementById("leftCol");
	var rounded = document.getElementById("rounded-box-5");
	var vline = document.getElementById("vline");
	var butnValue = document.getElementById("showButn");
	var line = document.getElementById("line");
	var navDiv = document.getElementById("navDiv");
	var rightCol = document.getElementById("rightCol");
	if(!butn)
	{
		leftCol.style.display = 'none';
		vline.style.display = 'none';
		butnValue.value = 'close all comments';
		rightCol.style.width = '934px';

		rounded.style.width = '630px';
		line.style.width = '630px';
		navDiv.style.marginLeft = '230px';
		for(var i=1; i<=5; i++)
		{
			document.getElementById("com"+i).style.width = '600px';
			document.getElementById("comDiv"+i).style.width = '500px';
		}
		butn = 1;
	}
	else
	{
		leftCol.style.display = 'block';
		rounded.style.width = '401px';
		vline.style.display = 'block';
		butnValue.value = 'show all comments';
		line.style.width = '400px';
		navDiv.style.marginLeft = 'auto';
		rightCol.style.width = '700px';
		for(var i=1; i<=5; i++)
		{
			document.getElementById("com"+i).style.width = '373px';
			document.getElementById("comDiv"+i).style.width = '280px';
		}
		butn = '';
	}
}


function changeMapButn(num)
{
	if(num == 1)
	{
		document.getElementById('mapId').src = 'img/map0.png'; 
		document.getElementById('butnPlus').src = 'img/butn_smaller_mo.jpg';
		document.getElementById('butnMinus').src = 'img/butn_larger.jpg';
	}
	else if(num == 0)
	{
		document.getElementById('mapId').src = 'img/map1.png'; 
		document.getElementById('butnPlus').src = 'img/butn_smaller.jpg';
		document.getElementById('butnMinus').src = 'img/butn_larger_mo.jpg';
	}
}
