function withoutSpaces(str){for(var i=0;i<str.length;i++){str=str.replace(' ','');str=str.replace(' ','');}
return str;}

function checkForm(form){var backgorundColor='#FFEAEA';var borderColor='#FFBFBF';var submitForm=true;for(var i in form.elements){var element=form.elements[i];if(element&&element.nodeName&&(element.nodeName=='INPUT'||element.nodeName=='TEXTAREA'||element.nodeName=='SELECT')&&element.getAttribute('check')=='true'){if(!withoutSpaces(element.value)){element.style.backgroundColor=backgorundColor;element.style.border='1px solid '+borderColor;if(element.nodeName=='SELECT'){if(!element.onchange){element.onchange=function(){if(this.value){this.style.border='';this.style.backgroundColor='';}else{this.style.border='1px solid '+borderColor;this.style.backgroundColor=backgorundColor;}}}}else{if(!element.onkeyup){element.onkeyup=function(){if(this.value){this.style.border='';this.style.backgroundColor='';}else{this.style.border='1px solid '+borderColor;this.style.backgroundColor=backgorundColor;}}}}
submitForm=false;}else{element.style.backgroundColor='';element.style.border='';}}}
if(submitForm){form.submit();}}



function sub_menu(obj, act){
	
	var menuDiv = false
	var div = obj.getElementsByTagName("div");
	
	for(var i in div){
		if(div[i] && div[i].nodeName=='DIV' && (div[i].className=='sub_menu_container' || div[i].className=='sub_menu_container2')){
			menuDiv = div[i];
			break;
		}
	}
	
	if(menuDiv!=false){
		
		if(act=="show"){
			
			menuDiv.style.display = '';
			
		}else{
			
			menuDiv.style.display = 'none';
			
		}
	}
}


var boxesPlace;
function showBox(obj, boxId){
	
	if(!boxesPlace){
		boxesPlace = document.getElementById('boxesPlace');
	}
	
	var tds = obj.parentNode.parentNode.cells;
	for(var i in tds){
		if(tds[i] && tds[i].nodeName=='TD' && tds[i].className.substr(0, 6)=='button'){
			tds[i].className = 'button';
		}
	}
	
	obj.parentNode.className = 'button selected';
	
	for(var i in boxesPlace.childNodes){
		
		if(boxesPlace.childNodes[i] && boxesPlace.childNodes[i].nodeName=='DIV'){
			
			boxesPlace.childNodes[i].style.display = boxesPlace.childNodes[i].id==boxId?'':'none';
			
		}
		
	}
	
	return false;
	
}

function showMap(obj){
	
	var totalHeight = 350;
	var stepSize = 3;
	
	var selfRow = obj.parentNode.parentNode;
	var table = selfRow.parentNode.parentNode;
	
	var mapRow = table.rows[parseInt(selfRow.rowIndex)+1];
	mapRow.id = 'mapRow_'+table.id+'_'+mapRow.rowIndex;
	
	var mapAction = mapRow.getAttribute('mapAction')=='close'?'close':'open';
	
	if(mapAction=='open'){
		
		mapRow.cells[0].style.height = '0px';
		mapRow.style.display = '';
		
		for(var i=1;i<Math.round(totalHeight/stepSize);i++){
			
			setTimeout('document.getElementById("'+mapRow.id+'").cells[0].style.height="'+(i*stepSize)+'px"', 3*i);
			
			if(i==Math.round(totalHeight/stepSize)-1){
				setTimeout('document.getElementById("'+mapRow.id+'").cells[0].childNodes[0].style.display="";document.getElementById("'+mapRow.id+'").cells[0].childNodes[0].src="'+obj.href+'";', 3*i);
			}
			
		}
		
	}else{
		
		mapRow.cells[0].childNodes[0].style.display = 'none';
		
		for(var i=Math.round(totalHeight/stepSize);i>0;i--){
			setTimeout('document.getElementById("'+mapRow.id+'").cells[0].style.height="'+(totalHeight-i*stepSize)+'px"', 3*i);
		}
		
	}

	mapRow.setAttribute('mapAction', (mapAction=='close'?'open':'close'));
	
	
	//alert(mapRow.nodeName);
	//alert(mapRow.innerHTML);
	
	return false;
	
}

var menuShadowObj = [];

function allMenuShadows(show){

	var obj, i;

	for(i in menuShadowObj){
		
		obj = document.getElementById(menuShadowObj[i]);
		
		if(obj){
			
			obj.style.display = show?'':'none';
			
			obj.style.width = obj.parentNode.clientWidth+'px';
			obj.style.height = obj.parentNode.clientHeight+'px';
			
		}
		
	}
	
}

var lastSelectedMenu = 0;
function menuShadow(id){
	
	var obj;
	
	if(lastSelectedMenu!=id){
		
		lastSelectedMenu = id;
		allMenuShadows(true);
		
		obj = document.getElementById(id);
		obj.style.display = 'none';
		
	}
	
}

function menuShadowCatch(){
	
	lastSelectedMenu = 0;
	
	setTimeout(function(){
		
		if(!lastSelectedMenu){
			allMenuShadows(false);
		}
		
	}, 500);
	
	
}


function actCheckbox(obj){
	
	var input = obj.getElementsByTagName('input')[0];
	
	input.checked = input.checked?false:true;
	obj.className = input.checked?'formInpBoxCheck checkCheck':'formInpBoxCheck';
	

}



function ChangeMenuIfFlashDetected(){
	
	var topMenuGrid = document.getElementById('topMenuGrid');
	var headerPlace = document.getElementById('headerPlace');
	
	if(topMenuGrid && headerPlace){
		
		var html = headerPlace.innerHTML;
		
		if(html.indexOf('.swf')!=-1){
			
			var div = topMenuGrid.getElementsByTagName('div');
				
				for(var i in div){
					
					if(div[i] && div[i].nodeName=='DIV'){
						
						if(div[i].className=='sub_menu_container2'){
							div[i].className = 'sub_menu_container';
						}else if(div[i].className=='sub_menu2'){
							div[i].className = 'sub_menu';
						}
						
					}
					
				}
				
			
			var table = topMenuGrid.getElementsByTagName('table');
				
				for(var i in table){
					
					if(table[i] && table[i].nodeName=='TABLE' && table[i].className=='sub_menu2'){
						
						table[i].className = 'sub_menu';
						
					}
					
				}
				
			
		}
		
	}
	
}

var itemsGalleryClass = function(){
	
	var maskWidth;
	var gridWidth;
	
	var itemsMask;
	var itemsGrid;
	
	var leftArrow;
	var rightArrow;
	
	var leftArrowEffect;
	var rightArrowEffect;
	var itemsGridEffect;
	
	var leftArrowVisible = true;
	var rightArrowVisible = true;
	
	var selfObj = this;
	
	this.init = function(){
		
		if(!document.getElementById('itemsMask')){return false;}
		
		leftArrow = document.getElementById('leftArrow');
		rightArrow = document.getElementById('rightArrow');
		
		itemsMask = document.getElementById('itemsMask');
		itemsGrid = document.getElementById('itemsGrid');
		
		maskWidth = parseInt(itemsMask.clientWidth);
		gridWidth = parseInt(itemsGrid.clientWidth);
		
		leftArrow.onclick = function(){selfObj.moveItems('left');return false;}
		rightArrow.onclick = function(){selfObj.moveItems('right');return false;}
		
		leftArrowEffect = new Fx.Styles(leftArrow, {duration: 400});
		rightArrowEffect = new Fx.Styles(rightArrow, {duration: 400});
		itemsGridEffect = new Fx.Styles(itemsGrid, {duration: 800});
		
		itemsGrid.style.left = 0;
		
		selfObj.moveItems('left');
		
	}
	
	this.moveItems = function(direction){
		
		var moveFrom = parseInt(itemsGrid.style.left);
		
		if(direction=='left'){
			var moveTo = moveFrom + maskWidth;
			moveTo = moveTo>0?0:moveTo;
		}else{
			var moveTo = moveFrom - maskWidth;
			moveTo = (moveTo<maskWidth-gridWidth)?(maskWidth-gridWidth):moveTo;
		}
		
		if(moveTo>=0 && leftArrowVisible){
			leftArrowVisible = false;
			leftArrowEffect.custom({'opacity': [1, 0.3]});
		}else if(direction=='right' && !leftArrowVisible){
			leftArrowVisible = true;
			leftArrowEffect.custom({'opacity': [0.3, 1]});
		}
		
		if(moveTo<=maskWidth-gridWidth && rightArrowVisible){
			rightArrowVisible = false;
			rightArrowEffect.custom({'opacity': [1, 0.3]});
		}else if(direction=='left' && !rightArrowVisible){
			rightArrowVisible = true;
			rightArrowEffect.custom({'opacity': [0.3, 1]});
		}
		
		itemsGridEffect.custom({'left': [moveFrom, moveTo]});
		
	}
	
}

var itemsGallery = new itemsGalleryClass();




