﻿	$(function () {
	$('.field').css('opacity',0.7);
	$('.menu li').css('opacity',0.7);
	
	var beg="Търси в сайта...";
	
		$("#str").click(function(){
			if($(this).val()==beg)
			$(this).val("");
			}).blur(function(){
			if($(this).val()=="")
			$(this).val(beg);
		});
	
	$("#img_s").mouseover( function () {
		
		$(this).css('backgroundColor','#323232').mouseout(function () {
		$(this).css('backgroundColor','');
		
		
		});
	});
	$("#cl_r").click (function () {
	
		$(".right").remove();
		$(".delim").remove();
		$(".left").animate({ 
        width: "100%"
		}, 500 );
	
	});
	
	$(".rating li").click (function() {
	
			var no=$(this).attr("class").substring(2);
			var ko=$(this).attr("title");
			
		$.ajax ({
			url: "st_vote.php",
			type: "GET",
			data: "n="+no+"&k="+ko ,
			success: function(res){
			$("#vot").hide().html(res).fadeIn(500);
			}

		});
		
	});
	var mamamia=$(".mylinks li:first").attr('rel');
	
	$(".seenimg").html("<div style=\"background:url("+mamamia+") no-repeat center center;height:157px;width:130px;\"></div>");
	$(".mylinks li").mouseover(function() {
	
		var opalq=$(this).attr('rel');
		$(".seenimg").html("<div style=\"background:url("+opalq+") no-repeat center center;height:157px;width:130px;\"></div>");
	});
	
	$("#predl input:first").focus (function() {
	
	$(this).val("");
		
	});
	
	$("#predl input:last").click (function() {
	
			var no=$("#predl input:first").val();
			//alert(no);
			if (no=="") {
			alert("Празно поле!");
			return false;
			}
		$.ajax ({
			url: "send_vote.php",
			type: "GET",
			data: "n="+no ,
			success: function(res){
			$("#pred").hide().html(res).fadeIn(500);
			}

		});
		return false;
	});
	
	$("#hide").click(function () {
	var sl=$(this).attr("alt");
	
		if (sl==">>") {
		$(".right").hide(500);
		$(".delim").hide(500);
		$(".left").animate({ 
        width: "100%"
		}, 500 );

		$(this).attr("alt","<<");
		$(this).attr("src","img/show.gif");
		}
		else {
		$(".right").show(500);
		$(".delim").show(500);
		$(".left").animate({ 
        width: "60%"
		}, 500 );
		$(this).attr("alt",">>");
		$(this).attr("src","img/hide.gif");
		}
	});
	
	$(".menu li").mouseover(function () {
		$(this).css('opacity',0.9).mouseout(function () {
			$(this).css('opacity',0.7);
		});
		
	});
	
	$(".readme").mouseover(function () {
		$(this).css('opacity',0.8).mouseout(function () {
			$(this).css('opacity',1);
		});
		
	});
	
	$(".links li").mouseover(function () {
		$(this).css('backgroundColor','black').mouseout(function () {
			$(this).css('backgroundColor','');
		});
		
	});
	
	$(".ch_font").click (function() {
	var jump=1;
	var d=$(this).attr("alt");
	var fs=parseInt($(".thistext").css("font-size"));
	if (d=="=")
	fs=14;
	
	if (d=="+")
	fs+=jump;
	
	if (d=="-")
	fs-=jump;
	
	$(".thistext").css("font-size",fs+"px");
	
	});
	
	$("#vote_me input").click(function () {
		
		var st=$(this).val();
		$.ajax ({
			url: "ank_vote.php",
			type: "GET",
			data: "koe="+st ,
			success: function(res){
			$("#vote_me").hide().html(res).fadeIn(500);
			}

		});
	
	});
	
	$("#playlista").change(function() {
	
		var src = $("option:selected", this).val();
		
		$.ajax ({
			url: "m_show.php",
			type: "GET",
			data: "n="+src ,
			success: function(res){
			$("#music").hide().html(res).fadeIn(500);
			}

		});
		
	});
	
	$(".menu li").click(function () {
			var imp=this.id.substring(1);
			if (imp=="1") {
			window.location("home");
			return true;
			}
			var th_t=$(this).attr("title");
		$.ajax ({
			url: "page"+imp+".php",
			type: "GET",
			data: "" ,
			success: function(res){
			$("#show_left").hide().html(res).fadeIn(500);
			}

		});
		$("#show_t").html(th_t);
		return false;
	});
	
	$("#str").focus(function() {
		$(this).css("border","1px solid #7e7e7e");
	}).blur(function(){
		$(this).css("border",0);
	});
	
	$(".more").click(function () {
		var th_tt=$(this).attr("title");
		$.ajax ({
			url: "page"+$(this).attr("rel")+".php",
			type: "GET",
			data: "" ,
			success: function(res){
			$("#show_left").hide().html(res).fadeIn(500);
			}

		});
		$("#show_t").html(th_tt);
			
	});
	
	$("#img_s").click(function () {
			//var imp=this.id.substring(1);
			//var th_t=$(this).attr("title");
			//alert($("#str").val());
		$.ajax ({
			url: "search.php",
			type: "POST",
			data: "string="+$("#str").val() ,
			success: function(res){
			$("#show_left").hide().html(res).fadeIn(500);
			}

		});
		$("#show_t").html("Търсене");
		return false;
	});
	
	$("#ch_l").click(function () {
	$("#langs").slideToggle(200);

	});	
	
	$("#send_c").click(function () {
		$("#showmsg_c").html("само секунда... <img src=\"img/load.gif\" alt=\"\" />");

			$.ajax ({
			url: "sendc.php",
			type: "POST",
			data: "wr="+$("#who_c").val()+"&em="+$("#email_c").val()+"&an="+$("#ans_c").val()+"&te="+$("#text2_c").val()+"&n="+$("#id_c").val()+"&ra="+$("#anss").val() ,
			success: function(res){
			
			$(this).attr('disabled', 'disabled');
			$("#showmsg_c").hide().html(res).fadeIn(500);
			}

		});
		return false;
});
	});