function link(link){
	document.location.href = link;
	return false;
}

$(document).ready(function($){
	// alert('test');
	$('.minus , .plus').each(function(){
		//replace(this);
		$(this).click(function(){
			replace(this);
		});
	})
	add_target();
});

function replace(a_obj){
	//alert($(a_obj).html());
	
	answer = $(a_obj).parent().parent().find('div.answer');
	//alert(answer.html());
	if( answer.css('display') == 'none' ){
		answer.show('slow');
		$(a_obj).removeClass('plus');
		$(a_obj).addClass('minus');
	}else{
		answer.hide('slow');
		$(a_obj).removeClass('minus');
		$(a_obj).addClass('plus');
	}
}

function add_target(){
	$('a').each(function(){
		if($(this).attr('href') && ($(this).attr('href').indexOf('netcat_files/File/price') > 0 )) {
			$(this).attr('target','_blank');
		}
	})
}



function getCatalog(folders){
	$('#test').append('<div id="catalogue"></div>');
	$('#catalogue').css('display','none');

	$('#catalogue').load('http://' + document.location.host + '/prices/ajax/catalogue.php?folders=' + folders, '', function(){
	
	
	$('#catalogue').show('slow');
	imgInit();	
	});
	
}


var globalPriceCount = 0;
function getPriceBox(priceParams, number){
	$(document).ready(function($){
		globalPriceCount ++;
		$.ajax({
			type: "POST",
			url: "http://mkfasady.ru/prices/ajax/catalogue.php",
			data: 'params=' + priceParams,
			success: function(html){
				$('#pb_' + number).html(html);
			}
		});

	});
}

function getPriceBoxNew(priceParams, number){
	$(document).ready(function($){
		$.ajax({
			type: "POST",
			url: "http://mkfasady.ru/prices/ajax/catalogue.php",
			data: 'params=' + priceParams,
			success: function(html){
				$('#pb_' + number).html(html);
			}
		});

	});
}

/*
function getPriceBox(price, number){
	$(document).ready(function($){
		globalPriceCount ++;
		var html = '<h3>Öåíû:</h3>';
		var getParam = '';
		for(i=0; i < price.length; i++){
			var loadParams = price[i].split('@');
			
			html = html + '<p>' + loadParams[0] + ': <span class="price" id="pr' + globalPriceCount + '_' + i + '"> ... </span></p>';
			if(i==0){
				getParam = 'params=' + loadParams[0];  
			}else {
				getParam = getParam  + '@' + loadParams[0];  
			}
			
			//$('#pr' + globalPriceCount + '_' + i).load('http://mkfasady.ru/prices/ajax/catalogue.php' + getParam);
			//alert('#pr' + globalPriceCount + '_' + i);
		}
		//alert(html);
		$('#pb_' + number).html(html);
		$.ajax({
			type: "GET",
			url: "http://mkfasady.ru/prices/ajax/catalogue.php",
			data: getParam,
			success: function(msg){
				var arrayMsg = msg.split('@');
				for(i=0; i < price.length; i++){
					$('#pr' + globalPriceCount + '_' + i).html(arrayMsg[i]);
				}
			}
		});

	});
}
*/