function hideTrailer(){
	$('#trailer').hide();
	$('#trailer1').hide();
}

function	showTrailer(id){
	$('#trailer').show();
	$('#trailer1').show();

	$('#tr_container').html($('#tr_'+id).html());

	$("#tr_container").css('top',$(window).height()/2+$(window).scrollTop());
}

function	showDisc(id){
		el = $('#disc_'+id);
		show = el.attr('show');

		if (show==0){
			show = 1;
		}else{
			show = 0;
		}

		el.attr('show',show);
		el.html('<div class="loading border_top">загрузка...</div>');

		el.load('/void/ajax/showdisc.php?id='+id+'&show='+show,'');
	}

function	putCart(id,pod_zakaz){
		$('#orders').load('/void/ajax/putcart.php?pod_zakaz='+pod_zakaz+'&id='+id,'',function(){alert('Товар добавлен в корзину');});
	}

function add_favor(id) {
 title = $('#'+id).attr('title');
 url = location.href;

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
		}
  return false;
 }

function	sh_window(wid1,wid2){
		$('#'+wid1+'1').css('display',$('#'+wid1+'1').css('display')=='none'?'block':'none');
		$('#'+wid1+'2').css('display',$('#'+wid1+'2').css('display')=='none'?'block':'none');
	    $('#'+wid2).css('display',$('#'+wid2).css('display')=='none'?'block':'none');
}

function swap(id){
	lowpic = document.getElementById(id);
	bigpic = document.getElementById('bigPic');
	fn=bigpic.src.dirname()+"/"+$(lowpic).attr("name");
    bigpic.src=fn;

    return false;
}

function chViewForm(){
	$('#cre_n_topic').hide();
	$('#new_top').show();
	return false;
}

function viewAttach(id,spid){
	if(spid==0){ additive='d';} else{additive='';}
	obj = document.getElementById('at'+additive+id);

	if ($(obj).attr('opened')==0){
		obj.setAttribute('opened','1');
		$('#at'+additive+id).show();
		addAttach(id,spid,additive);
	}else{
		obj.setAttribute('opened','0');
		$('#at'+additive+id).hide();
	}
	return false;
}

function addAttach(id){
	j=id*10;
	for(i=j; i<j+10; i++){
		if(i!=j){			ddt = document.getElementById('attach'+(i-1));
			if (ddt.value==''){
				alert('Please choose previous attachment first!');
				return true;
			}		}

		ddd = document.getElementById('n'+i);
		if (ddd.innerHTML==''){			add=$('<p><input name="attach'+i+'" type="file" id="attach'+i+'" value="" style="height:20px;"><a href="" onClick="removeAtt('+i+'); return false;"><img src="img/remove.jpg"></a></p>');
			add.appendTo('#n'+i);
			return true;		}	}}

function removeAtt(numAtt){;
	$('#n'+numAtt).html('');}

function viewComment(id){	comm = document.getElementById('com'+id);
	sh = document.getElementById('sh'+id);

	if ($(comm).attr('opened')==0){        sh.innerHTML='-';
        comm.setAttribute('opened','1');
		$('#com'+id).show();
	}else{		sh.innerHTML='+';
		comm.setAttribute('opened','0');
		$('#com'+id).hide();
	}
	return false;}

function showTopic(id,aURI){    sh = document.getElementById('sh'+id);
	top1 = document.getElementById('tc'+id);

	if (top1.getAttribute('opened')==0){
		//show item
        sh.innerHTML='-';
        top1.setAttribute('opened','1');
		$('#tc'+id).show();

		//set readed comments
		$.get('/frag/setcomm.php?id='+id+'&url='+aURI);
	}else{
		sh.innerHTML='+';
		top1.setAttribute('opened','0');
		$('#tc'+id).hide();
	}
	return false;
}

//login
function	enterVal(el,val){
		if (el.val()==val){
				el.val('');
			}
	}

function	outVal(el,val){
		if (el.val()==""){
				el.val(val);
			}
	}

function	login1(log,psw){
		var re=/[^\s]+/i;

		if (!re.test($('#login').val()) || $('#login').val()==''){
			 alert(log);
			 $('#login').focus();
			 return false;
		}

		if (!re.test($('#pwd').val()) || $('#pwd').val()==''){
			 alert(psw);
			 $('#pwd').focus();
			 return false;
		}

		$('#log_form').submit();

		return true;
	}

$('.login').focus(function(){
	enterVal($(this),$(this).attr('def'));
});

$('.login').blur(function(){
	outVal($(this),$(this).attr('def'));
});
