function imgOnOff(img, action) {
	
	var s;
	
	if (action == 'on')	{
		s = img.src.replace(/inactive/g, "active");
	} else {
		s = img.src.replace(/active/g, "inactive");
	}
	
	img.src	= s;
	
}
function searchSubmit() {

	skw = document.getElementById('keyword').value;
	
	if (!skw || skw == 'Поиск') {
		
		alert('Пожалуйста, введите поисковый запрос!');
		
	} else {
		
		document.searchForm.submit();
		
	}
	
}

function hideShow(id) {
	if (document.getElementById(id)) {
		obj = document.getElementById(id);
		if (obj.style.display == '') {
			obj.style.display = 'none';
		} else {
			obj.style.display = '';
		}
	}
}

function searchStart() {
	
	obj = document.site_search;
	
	if (!obj.keyword.value || obj.keyword.value == jsText['search']) { alert(jsText['enterKeyWord']); }
	else {
		for (i = 0; i < obj.target.length; i++) {
			if (obj.target[i].checked) { table = obj.target[i].value }
		}
		location.href = http_path + 'index/search/pages/' + obj.keyword.value;
	}
	
}

function searchProj() {
	oForm = document.search_project;
	strLink = getRequestForm(oForm);
	location.href = http_path + 'projects/catalog/' + strLink + '/';
}


function getRequestForm(oForm) {
    var aParams = new Array();
            
	for (var i=0 ; i < oForm.elements.length; i++) {
        var sParam = encodeURIComponent(oForm.elements[i].name);
        if (sParam) {
        	sParam += "/";
        	
        	if (((oForm.elements[i].type != 'checkbox' && oForm.elements[i].type != 'radio') || ((oForm.elements[i].type == 'checkbox' || oForm.elements[i].type == 'radio') && oForm.elements[i].checked)) && oForm.elements[i].value != '') {
	        	sParam += encodeURIComponent(oForm.elements[i].value);
	        	aParams.push(sParam);
	        }
	    	
			
        }
    	
    } 
            
	return aParams.join("/");
			
}


function fixCarouselWidth() {	
	objs = document.getElementsByClassName('horizontal_carousel');
	objsCont = document.getElementsByClassName('container')
	baseWidth = 1000;
	currentWidth = getClientWidth();
	staticKoef = 230 + 60 + 32;	
	staticKoefCont = 230 + 60 + 96;	
	//alert(objs.length);
	if (objs && currentWidth > baseWidth) {		
		for (i = 0; i < objs.length; i++) {
			objs[i].style.width = (currentWidth - staticKoef) + 'px';
			objsCont[i].style.width = (currentWidth - staticKoefCont) + 'px';
		}
	}
	return true;
}

function getClientWidth() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

itemProp = 0;
function prop(count) {
	allProposes = document.getElementsByClassName('proposes');
	//alert(allProposes.length);
	if (allProposes.length > 0) {
		nextProp = itemProp + count;
		if (nextProp < 0) itemProp = allProposes.length - 1;
		else if (nextProp >= allProposes.length) itemProp = 0;
		else itemProp = nextProp;
		$('itempropose').innerHTML = $('propose'+itemProp).innerHTML;
	}
}
