function SelectMailDissemination( typeOn ) {
	if ('mail' == typeOn) {
		$("#titleMailOff")[0].style.display = "none";
		$("#titleMailOn")[0].style.display = "block";
		$("#titleDisseminationOn")[0].style.display = "none";
		$("#titleDisseminationOff")[0].style.display = "block";

		$("#blockDissemination")[0].style.display = "none";
		$("#blockMail")[0].style.display = "block";
	}
	else {
		$("#titleMailOff")[0].style.display = "block";
		$("#titleMailOn")[0].style.display = "none";
		$("#titleDisseminationOn")[0].style.display = "block";
		$("#titleDisseminationOff")[0].style.display = "none";

		$("#blockMail")[0].style.display = "none";
		$("#blockDissemination")[0].style.display = "block";
	}
}

function ChangeCategory(type, select) {
	var url = "/" + type + "/";
	if ('testdrive' != type)
		url = url + "list/";

	if (0 != select.value)
		url = url + select.value + "/";
	window.location.href = url;
}

//menu begin
function CatalogMenuShow() {
	cursorOnCatalogMenu = true;
	$("#catalogMenu").fadeIn("fast");
}
function CatalogMenuHideForce() {
	if (!cursorOnCatalogMenu)
		$("#catalogMenu").fadeOut("fast");
}
function CatalogMenuHide(force) {
	cursorOnCatalogMenu = false;
	clearTimeout(catalogMenuTimer);
	catalogMenuTimer = setTimeout('CatalogMenuHideForce()', 5);
}

cursorOnCatalogMenu = false;
catalogMenuTimer = 0;
//menu end


function openHideAllProj(e){
	if ($("#listProjects").is(":hidden")) {
		$("#listProjects").slideDown(1000);
		e.className = "fullOpen";
	}
	else {
		$("#listProjects").slideUp(1000);
		e.className = "fullAllProjects";
	}
}

//search
function SetSearchType( searchType ) {
	try {
		$("#searchType")[0].parentNode.removeChild($("#searchType")[0]);
	}
	catch (e) { }

	$("#searchTypeBlock a").removeClass("searchSelected");

	switch (searchType) {
		case 'web':
			$("#searchForm")[0].action = "http://search.oboz.ua/search.aspx";
			//$("#searchInput")[0].name = "k";
			$("#searchLinkWeb").addClass("searchSelected");
			break;
		case 'price':
			$("#searchForm")[0].action = '/tool/pricesearch.php';
			//$("#searchForm")[0].action = 'http://price.mobilnik.ua/search.php';
			$("#searchForm").append($("<input type='hidden' name='st' value='1' id='searchType'>"));
			//$("#searchInput")[0].name = "q";
			//window.location.href = "http://price.mobilnik.ua/search.php?q=" + encodeURI($("#searchInput")[0].value) + "&st=1";
			$("#searchLinkPrice").addClass("searchSelected");
			break;
		case 'shop':
			$("#searchForm")[0].action = '/tool/pricesearch.php';
			$("#searchForm").append($("<input type='hidden' name='st' value='2' id='searchType'>"));
			//$("#searchInput")[0].name = "q";
			$("#searchLinkShop").addClass("searchSelected");
			break;
		case 'site':
		default:
			$("#searchForm")[0].action = "/search.php";
			//$("#searchInput")[0].name = "k";
			$("#searchLinkSite").addClass("searchSelected");
			break;
	}
}


/* catalog product list open/close */
function ProductListOpenClose( producerId ) {
	if (!currentOpenProducerId) {
		ProductListOpen(producerId);
		return;
	}

	if (currentOpenProducerId == producerId) {
		ProductListClose(producerId);
		return;
	}

	ProductListClose(currentOpenProducerId);
	ProductListOpen(producerId);
}
function ProductListOpen( producerId ) {
	currentOpenProducerId = producerId;
	$("#producerLink" + producerId)[0].className = "producerCurrent1";
	//$("#producerBlock" + producerId)[0].style.display = "block";
	$("#producerBlock" + producerId).show("normal");
	if ($("#producerDot" + producerId)[0])
		$("#producerDot" + producerId)[0].style.display = "none";
}
function ProductListClose( producerId ) {
	currentOpenProducerId = null;
	$("#producerLink" + producerId)[0].className = "";
	//$("#producerBlock" + producerId)[0].style.display = "none";
	$("#producerBlock" + producerId).hide("normal");
	if ($("#producerDot" + producerId)[0])
		$("#producerDot" + producerId)[0].style.display = "inline";
}

function ProductSelectStyle() {
	if (!currentSelectedProductId) {
		return;
	} 
	
	$("#productLink" + currentSelectedProductId)[0].className = "producerCurrent1";
}

function GetCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return (decodeURIComponent(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))).replace(/\%20/g, " ");
}
// name - имя cookie
// [path] - путь, для которого cookie действительно
// [domain] - домен, для которого cookie действительно
function DeleteCookie(name, path, domain) {
        if (GetCookie(name)) {
                document.cookie = name + "=" +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-1970 00:00:01 GMT"
        }
}

function ReplaceChildText(parentEl, newText) {
	while (parentEl.hasChildNodes()) {
		parentEl.removeChild(parentEl.firstChild);
	}
	var newLinkText1 = document.createTextNode(newText);
	parentEl.appendChild(newLinkText1);
}


function catalog_findmodels_category1( page )
{

 var req2 = new JsHttpRequest();
 req2.onreadystatechange = function() {
  if (req2.readyState == 4) {
   document.getElementById('podbor_result').innerHTML = req2.responseJS.res;
  }
 }

 req2.caching = true;
 req2.open("POST", '/tool/catalog_findmodels_category1.php', true);
 req2.send({'page': page, 'form': $("#mobilnik_ua_podbor_form").serialize() });
}

function catalog_findmodels_category8( page )
{

 var req2 = new JsHttpRequest();
 req2.onreadystatechange = function() {
  if (req2.readyState == 4) {
   document.getElementById('podbor_result').innerHTML = req2.responseJS.res;
  }
 }

 req2.caching = true;
 req2.open("POST", '/tool/catalog_findmodels_category8.php', true);
 req2.send({'page': page, 'form': $("#mobilnik_ua_podbor_form").serialize() });
}

