$(document).ready(function () {

$("#sbmcatf1 select").change(function(){
$("#sbmcatf1").submit();
})

if (parseInt($('#content').height()) < parseInt($('#leftbar').height())) {
	$('#content').css('height',$('#leftbar').height()+'px');
}

$(document).pngFix();

$(".morefile #addfile").click(function(){
var count=1;
$("#manyfiles .element").each(function(){
if($(this).css("display")!="none"){count++;}
});
//alert(count);
if(count<=5){
$("#manyfiles #felement"+count).css("display", "block"); 
if(count>=5){$(".morefile").remove();}
}
});

$('#arrowright').click(function () {
	if (parseInt($('#framescont').css('left')) <= -parseInt($('#framescont').css('width'))+615) return;
	$('#framescont').animate({
		left: '-=164'
	});
});

$('#arrowleft').click(function () {
	if (parseInt($('#framescont').css('left')) >= 0) return;
	$('#framescont').animate({
		left: '+=164'
	});
});
$('#arrowright2').click(function () {
	if (parseInt($('.topnews2').css('left')) <= -parseInt($('.topnews2').css('width'))+950) return;
	$('.topnews2').animate({
		left: '-=950'
	});
});
$('#arrowleft2').click(function () {
	if (parseInt($('.topnews2').css('left')) >= 0) return;
	$('.topnews2').animate({
		left: '+=950'
	});
});
$('#framescont div').click(function () {
	$('#gallery .main img').attr('src','/'+$(this).attr('full'));
	$('#gallery .description').text($(this).attr('title'));
	$('#framescont div').removeClass('active');
	$(this).addClass('active');
	$(".bulets span").removeClass('active');
	$(".bulets span[full="+$(this).attr('full')+"]").addClass('active');
});
$('.bulets span').click(function () {
$('#framescont div[full='+$(this).attr('full')+']').trigger("click");
});
if ($('#framescont')) {
	$('#framescont').css('width',$('#framescont').children('div').length*164+'px');
	$('#framescont div:first-child').trigger('click');
}
$("select.selectproject").change(function(){
window.location.href=$(this).val();
})
$('#poll form').submit(function () {
	if ($('#poll form input[name=answer]:checked').length == 0) return false;
	var answer = $('#poll form input[name=answer]:checked').val();
	var group = $('#poll form input[name=group]').val();
	$.get(
		'/assets/templates/default/poll.php?answer='+answer+'&group='+group,
		function (data) {
			$('#poll div').not('.shadow').html(data);
		}
	);
	return false;
});

$('form#search input.query').focus(function () {
	$(this).val('');
	$(this).addClass('focus');
});

$(".howworkdiv .td1").hover(function(){
var tt=$(this).find("img");
$(tt).attr("src", $(tt).attr("src2"))
$(this).addClass("active");
},function(){
var tt=$(this).find("img");
$(tt).attr("src", $(tt).attr("src1"))
$(this).removeClass("active");
})

$(".dopbut1").click(function(){
$("#howworkdiv2").hide();
$("#howworkdiv3").hide();
if($("#howworkdiv1").css("display")=="none"){
$("#howworkdiv1").css("display", "block");
$(".closeopen").addClass("closeopeno");
$(".closeopen").html("Закрыть")
}else {
$("#howworkdiv1").css("display", "none")
$(".closeopen").removeClass("closeopeno");
$(".closeopen").html("Открыть")
}
})
$(".dopbut2").click(function(){
$("#howworkdiv1").hide();
$("#howworkdiv3").hide();
if($("#howworkdiv2").css("display")=="none"){
$("#howworkdiv2").css("display", "block");
$(".closeopen").addClass("closeopeno");
$(".closeopen").html("Закрыть")
}else {
$("#howworkdiv2").css("display", "none")
$(".closeopen").removeClass("closeopeno");
$(".closeopen").html("Открыть")
}
})
$(".dopbut3").click(function(){
$("#howworkdiv2").hide();
$("#howworkdiv1").hide();
if($("#howworkdiv3").css("display")=="none"){
$("#howworkdiv3").css("display", "block");
$(".closeopen").addClass("closeopeno");
$(".closeopen").html("Закрыть")
}else {
$("#howworkdiv3").css("display", "none")
$(".closeopen").removeClass("closeopeno");
$(".closeopen").html("Открыть")
}
})
$(".closeopen").click(function(){
if($(this).html()=="Открыть"){
$("#howworkdiv1").show();
$(this).addClass("closeopeno");
$(this).html("Закрыть")
}
else{
$("#howworkdiv3").hide();
$("#howworkdiv2").hide();
$("#howworkdiv1").hide();
$(this).removeClass("closeopeno");
$(this).html("Открыть")
}
})
$('form#search input.query').blur(function () {
	$(this).removeClass('focus');
});
$(".headerzaya a").click(function(){
$(".headerzaya a").removeClass("active");
$(this).addClass("active");
});
$(".headerzaya .svernutz").click(function(){
$("#divzav").slideToggle();
if($(this).html()=="посмотреть заявки")$(this).html("свернуть заявки");else $(this).html("посмотреть заявки");
})
$(".alldizdiv p").click(function(){
$("#designers").slideToggle();
})
$(".divoklick a").click(function(){
$("#oklickform").slideToggle();
})
var i=0;
$(".listproject").each(function(){
if(i!=0 && i%3==0){$(this).before("<div class='separpr'></div>")}
i++;
})

$("form .newstardiv").hover(
function(){
//alert(parseInt($(this).attr("id")));
var t=$(this).attr("attr1");
$("form .newstardiv").each(function(){
if($(this).attr("attr1")<=t)
	{
		$(this).addClass("active");
	}
});
},
function(){
var t=$(this).attr("attr1");
$("form .newstardiv").each(function(){
if($(this).attr("attr1")<=t)
	{
		$(this).removeClass("active");

	}
});
}
);

$("form .newstardiv").click(function(){
$(".inp-"+$(this).attr("id")).attr("checked","checked");
$(".kartpoldiv form").submit();
});

});
function sendmain1(t, t2)
{
//$("#divzav").show();
if(t2=="/ajax-ispolniteli"){
     $("#designers").html("Идёт загрузка...");
	 }else {$("#divzav").html("Идёт загрузка...");}

$.get(t2, { start: t }, function(data){
if(t2=="/ajax-ispolniteli"){
     $("#designers").html(data);
	 }else {$("#divzav").html(data);}
   });
}

function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}
 
function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}
