function Basket(id, action, color, count) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
             document.getElementById('basket').innerHTML = req.responseText;
         } 
    }
    req.open(null, '/open_scripts/basket.php', true);
    req.send( { id: id, action: action, color: color, count: count } );
    if (action == 'add') {
    	setTimeout("basket_window('/open_scripts/basket_window.php', '')", 1000);
    }
}

function newWinVideo(file_foto,file_video)
{
	document.getElementById('photo_view').innerHTML = "<p id=\"player_v\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Установите Flash Player</a></p>";
	var s1 = new SWFObject("/js/player/mediaplayer.swf","single","400","320","7");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("file",file_video);
	s1.addVariable("image",file_foto);
	s1.addVariable("width","400");
	s1.addVariable("height","320");
	s1.write("player_v");
}
  
function newWinPhoto(file_foto)
{
  document.getElementById('photo_view').innerHTML = '<img src="'+file_foto+'" width="400" height="300" class="img_photo" id="photo_big" />';
}
 
function newWinAudio(file_audio)
{
	document.getElementById('photo_view').innerHTML = "<p id=\"player_a\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Установите Flash Player</a></p>";
	var s3 = new SWFObject("/js/player/mp3player.swf", "line", "400", "320", "7");
	s3.addVariable("file",file_audio);
	s3.addVariable("image","http://www.sk-des.ru/themes/images/audio_big.jpg");
	s3.addVariable("repeat","true");
	s3.addVariable("showdigits","true");
	s3.addVariable("showdownload","true");
	s3.addVariable("width","400");
	s3.addVariable("height","320");
	s3.write("player_a");
}

/**
 * Example: inputPlaceholder( document.getElementById('my_input_element') )
 * @param {Element} input
 * @param {String} [color='#AAA']
 * @return {Element} input
 */
function inputPlaceholder (input, color) {

	if (!input) return null;

	// Do nothing if placeholder supported by the browser (Webkit, Firefox 3.7)
	if (input.placeholder && 'placeholder' in document.createElement(input.tagName)) return input;

	color = color || '#AAA';
	var default_color = input.style.color;
	var placeholder = input.getAttribute('placeholder');

	if (input.value === '' || input.value == placeholder) {
		input.value = placeholder;
		input.style.color = color;
		input.setAttribute('data-placeholder-visible', 'true');
	}

	var add_event = /*@cc_on'attachEvent'||@*/'addEventListener';

	input[add_event](/*@cc_on'on'+@*/'focus', function(){
	 input.style.color = default_color;
	 if (input.getAttribute('data-placeholder-visible')) {
		 input.setAttribute('data-placeholder-visible', '');
		 input.value = '';
	 }
	}, false);

	input[add_event](/*@cc_on'on'+@*/'blur', function(){
		if (input.value === '') {
			input.setAttribute('data-placeholder-visible', 'true');
			input.value = placeholder;
			input.style.color = color;
		} else {
			input.style.color = default_color;
			input.setAttribute('data-placeholder-visible', '');
		}
	}, false);

	input.form && input.form[add_event](/*@cc_on'on'+@*/'submit', function(){
		if (input.getAttribute('data-placeholder-visible')) {
			input.value = '';
		}
	}, false);

	return input;
}
 
function CatalogSet(cat_id, id) {
		var req = new JsHttpRequest();
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				document.getElementById('CatalogSet').innerHTML = req.responseText;
			} 
		}
		req.open(null, '/furniture/'+cat_id+'/'+id+'/set/', true);
		req.send( { } );
	}
 
function CatalogAcc(cat_id, id, select) {
	var req = new JsHttpRequest();
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			document.getElementById('CatalogAcc').innerHTML = req.responseText;
		} 
	}
	req.open(null, '/furniture/'+cat_id+'/element/'+id+'/'+select+'/', true);
	req.send( { } );
}
