	
	function OpenClose(id){
		
		var obj = document.getElementById(id);
		if(obj.style.display != 'none'){
		obj.style.display = 'none';
		setCookie(id, 'none');
		}else{
		obj.style.display = 'block';
		setCookie(id, 'block');
		}
		
	}
	
	function getLinkStatus(id) {
		var obj = document.getElementById(id);
		if(getCookie(id)) {
			return getCookie(id);
		}
	}
	
	function showOrHidden(id){
		var text = document.getElementById('text_'+id).style;
		var lnk = document.getElementById('link_'+id);
			if(text.display != 'block'){
				text.display =  'block';
				lnk.innerHTML = 'Cвернуть';
			}else{
				text.display =  'none';
				lnk.innerHTML = 'Подробнее';
			}
	}
	
	function IfOpera() {
		var isOpera = ( navigator.userAgent.indexOf("Opera") != -1);
		if(isOpera)
		document.getElementById('footerleft').style.width = "620px";
		else document.getElementById('footerleft').style.width = "622px";
	}
	
	
	
	function setOrderClause(field, mode) {
		
		xajax_setOrderClause(field, mode, 'getCards()');
		
	}
	
	function setSearchClause(field, value) {
		
		xajax_setSearchClause(field, value, 'getCards()');
		
	}
	
	function setParamClause(field, value, index) {
		$("#cards").empty();
		$("#cards").append("<center><img src='/images/load.gif'/></center>");
		$("#cards center").css({width:"100%", height:"218px"});
		$("#cards center img").css({margin: "90px 0"});
		xajax_setParamClause(field, value, index, 'getCards()');
		
	}
	
	function getCards() {
		xajax_getCards("cards", null);
	}
	
	
	function alertMessage(message) {
		alert(message);
	}
	
	function redirect(url) {
		window.location=url;
	}
	
	function redirectConfirm(msg, to) {
		if(confirm(msg)) {
			redirect(to);
		}
	}
	
	function alertMessageAfterAddCart() {
		alertMessage("Элемент удачно добавлен в корзину!");
	}
	
	function addToCart(cardId) {
		xajax_addToCart(cardId, 'alertMessageAfterAddCart()');
	}
	
	function getCarts() {
		xajax_getCarts('carts');
	}
	
	function deleteFromCart(key) {
		
		if(confirm("Вы действительно хотите удалить этот элемент?")) {
			xajax_deleteFromCart(key, "getCarts()");
		}
		
	}
	
	function searchCards() {
		$("#cards").empty();
		$("#cards").append("<center><img src='/images/load.gif'/></center>");
		$("#cards center").css({width:"100%", height:"218px"});
		$("#cards center img").css({margin: "90px 0"});
		var searchField = document.getElementById('searchField');
		var searchValue = document.getElementById('searchValue');
		xajax_setSearchClause(searchField.value, searchValue.value, 'getCards()');
	}
	
	function clearCards() {
		$("#cards").empty();
		$("#cards").append("<center><img src='/images/load.gif'/></center>");
		$("#cards center").css({width:"100%", height:"218px"});
		$("#cards center img").css({margin: "90px 0"});
		xajax_clearCards('getCards()');
	}
	
	function changeQuantity(cardId, quantity) {
		
		xajax_changeQuantity(cardId, quantity, "getCarts()");
		
	}
	
	function setMark(cardId, mark) {
		xajax_setMark(cardId, mark, 'alertMessage("Ваша оценка учтена!")');
	}
	
	
	
	function changeFoto(fotoFile, elementId) {
		
		var element = document.getElementById(elementId);
		var href = '<a href="/images.php?file='+fotoFile+'" target="_blank"><img src="/images.php?file='+fotoFile+'&width=125&height=150" border=0></a>';
		element.innerHTML=href;
		
	}
	
	function hideP (obj) {
		
		if(obj.value=="Тема") {
			obj.value="";
		}
		
	}
	
	function changeBgcolor(obj) {
		if(obj.style.backgroundColor=='transparent' || obj.style.backgroundColor=='' || obj.style.backgroundColor=='transparent') {
			obj.style.backgroundColor='#FFFC00';
		} else {
			obj.style.backgroundColor='transparent';
		}
	}
	

	
	 function getCookie(cookie) {
    	var cookiePair;
    	var cookieName;
    	var cookieValue;
    	
    	var cookieArray = document.cookie.split("; "); 
    	   	for(var count = 0; count<cookieArray.length; count++) {
    	   		cookiePair=cookieArray[count].split("=");
    	   		cookieName=cookiePair[0];
    	   		cookieValue=cookiePair[1];
    	   		
    	   		if(cookieName==cookie) {
    	   			return unescape(cookieValue);
    	   		}
    	   	}
    	   	return null;
    }
    
    function setCookie(name, value) {
    	
    	document.cookie=name+'='+escape(value)+'; path=/';
    	
    }
    
    function showCardInfo(id)
		{
			xajax_getCardInfo(id);
		}
	function hideCardInfo() {
		var element = document.getElementById("conteiner_card_info");
		element.style.display="none";
	}
    function getUniqueVideoCards(page) {
		$("#conteiner_uniquie_video").empty();
		$("#conteiner_uniquie_video").append("<center><img src='/images/load.gif'/></center>");
		$("#conteiner_uniquie_video center").css({width:"100%", height:"218px"});
		$("#conteiner_uniquie_video center img").css({margin: "90px 0"});
    	xajax_getUniqueVideoCards(page);
    }
    function getUniqueAudioCards(page) {
		$("#conteiner_uniquie_audio").empty();
		$("#conteiner_uniquie_audio").append("<center><img src='/images/load.gif'/></center>");
		$("#conteiner_uniquie_audio center").css({width:"100%", height:"218px"});
		$("#conteiner_uniquie_audio center img").css({margin: "90px 0"});		
    	xajax_getUniqueAudioCards(page);
    }
    function getDetailsUniqueCard(cardId) {
    	xajax_getDetailsUniqueCard(cardId);
    }
    function getDetailsUniqueCard2(cardId) {
    	xajax_getDetailsUniqueCard2(cardId);
    	$("span#uniqFotoGal").ready(function() {
			
			$("span#uniqFotoGal a").fancybox({
				'hideOnContentClick': true,
				'overlayShow':	true
			});
			});
    }