function getWidthScreen(){
//   var width = 0, height = 0;
  if(window.innerWidth){
    width = window.innerWidth;
  }
  else if(document.documentElement && document.documentElement.clientWidth){
    width = document.documentElement.clientWidth;
  }
  else if(document.body && document.body.clientWidth){
    width = document.body.clientWidth;
  }
  return width;
}


function cmfCommentAdd(form, url) {
	return cmfAjaxSend(url, { form: form });
}


function cmfLeftMenu(el, isEnd, open) {
	el = el.parentNode;
	if(cmfLeftMenu3(el.id) && open) {
		if($(el).attr('open1')!=1) {			$(el).attr('open1', 1)
			$('li[@level="'+ el.id +'"]', $('#left_nav6')).each(function() {
				if($('a', this).get(0).onclick) $('a', this).get(0).onclick();
			});
			return false;
		}
	}
	var visible = true;
	if(el.vis!=false) {
        visible = false;
	} else {
        visible = true;
	}
	el.vis = visible;
	if(cmfLeftMenu2(el.id, visible)) {		if(!visible) {
	        if(isEnd) el.className = 'linus';
		} else {
	        if(isEnd) el.className = '';
		}		return false;
	}
	return true;
}
function cmfLeftMenu3(id) {
	var i = 0;
	$('li[@level="'+ id +'"]', $('#left_nav6')).each(function() {
		i++;
	});
	return i;
}
function cmfLeftMenu2(id, visible) {
	var i = 0;
	$('li[@level="'+ id +'"]', $('#left_nav6')).each(function() {
		i++;
		if(this.id) cmfLeftMenu2(this.id, visible);
		if(visible) {			$(this).show();
		} else {			$(this).hide();		}
	});
	return i;
}



function cmfCatalogChangeType() {	var cat1 = cmfGetId('isNotwire').checked;
	var cat2 = cmfGetId('isWire').checked;

	if(cat1 == cat2) {
		$('div[@id="catalogisNotwire"]').hide();
		$('div[@id="catalogisWire"]').hide();
		$('div[@id="catalogAll"]').show();
	} else if(cat1) {
		$('div[@id="catalogisNotwire"]').hide();
		$('div[@id="catalogAll"]').hide();
		$('div[@id="catalogisWire"]').show();
	} else if(cat2) {
		$('div[@id="catalogAll"]').hide();
		$('div[@id="catalogisWire"]').hide();
		$('div[@id="catalogisNotwire"]').show();
	}
}




function cmfProductChangeImage(img, count, obj) {
	cmfGetId('productImg').src = img;
	for(var i=0; i<count; i++) {
		cmfGetId('productImgList' + i).disabled='';
	}
	obj.disabled='disabled';
}

function cmfOpenImage(url, width, height) {
	var id = 'image';
	window_top =20+ (screen.height - height) / 2;
	window_left =20+ (screen.width - width) / 2;
	window.open(url, id, 'width='+(width+40)+', height='+(height+20)+', top='+window_top+', left='+window_left+', toolbar=0, statusbar=0, location=0, scrollbars=yes, resizable=0');
	return false;
}






function cmfChangeShop(id, len) {
	cmfAjaxSendCache(cmfBaseUrl + '/mainAjax/shop/shop.php', {id: id, len: len});
}
function cmfContactSity(value, id) {
	cmfAjaxSendCache(cmfBaseUrl + '/mainAjax/user/gorod.php', {id: id, value: value});
}
function cmfContactSityMesto(value, id, id2) {
	cmfAjaxSendCache(cmfBaseUrl + '/mainAjax/user/gorod.php', {id: id, id2: id2, value: value});
}
function cmfContactMesto(value, id2) {
	cmfAjaxSendCache(cmfBaseUrl + '/mainAjax/user/gorod.php', {id2: id2, value: value});
}

function cmfMenuVisible(k) {	cmfVisibleHidden('section'+ k);
}
