function mail(){
    var type = "email";
    var sender = $("input[name=sender]").val();
        sender = jQuery.trim(sender);
    var receiver = $("input[name=receiver]").val();
        receiver = jQuery.trim(receiver);

    var regV = /[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}/;

    if (sender == "") {
        alert("Öz E-poçtunuzu qeyd edin...");
    }
    else if (receiver == "") {
        alert("Dostunuzun E-poçtunu qeyd edin...");        
    }
    else if (sender.search(regV) == -1) {
        alert("Lan epoctunu duzqun qeyd et");        
    }
    else if (receiver.search(regV) == -1) {
        alert("Lan dostuvunda epoctun duzqun duzqun qeyd ele");        
    }
    else if (sender == receiver) {
        alert("Yaxsidiki ozun ozuvun dostusan");
    }
    else {
        var mailData = "type="+type+"&receiver="+receiver+"&sender="+sender;
        $(".loader").fadeIn(1000);
        $(".sub").attr("disabled", true);

        $.ajax({
            type:"post",
            data:mailData,
            url:"/ajax.php",
            success: function(result) {
                if (result == "SEND") {
                    $(".loader").fadeOut(-2000);
                    $(".info").html("<font color='#00135E'>Məktubunuz Uqurla Dostunuza Göndərildi</font>");
                }
                else {
                    $(".loader").fadeOut(1000);
                    $(".info").html("<font color='#F60029'>Xəta Baş Verdi Məktubunuz Dostunuza Göndərilmədi</font>");
                }
            }
        });
    }

}





function call() {


    var type = "call";
    var callEmail = $("input[name=callEmail]").val();
        callEmail = jQuery.trim(callEmail);
    var callTelephone = $("input[name=callTelephone]").val();
        callTelephone = jQuery.trim(callTelephone);
    var callName = $("input[name=callName]").val();
        callName = jQuery.trim(callName);
    var callSurname = $("input[name=callSurname]").val();
        callSurname = jQuery.trim(callSurname);
    var regV = /[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}/;

    if (callEmail == "") {
        alert("E-poçtunuzu qeyd edin...");
    }
    else if (callEmail.search(regV) == -1) {
        alert("Lan epoctunu duzqun qeyd et");        
    }
    else if (callTelephone == "") {
        alert("Nomrenizi qeyd edin...");        
    }
    else if (callName == "") {
        alert("Adinizi qeyd edin...");        
    }
    else if (callSurname == "") {
        alert("Soyadinizi qeyd edin...");        
    }
    else {
        var callData = "type="+type+"&callEmail="+callEmail+"&callTelephone="+callTelephone+"&callName="+callName+"&callSurname="+callSurname;
        $(".loader").fadeIn(1000);
        $(".sub").attr("disabled", true);
     
        $.ajax({
            type:"post",
            data:callData,
            url:"/ajax.php",
            success: function(result) {
                if (result == "SEND") {
                    $(".loader").fadeOut(-2000);
                    $(".call h1").text("Tesekurler Qisa zamanda sizinle Elaqe saxlanilacaq");
                }
                else {
                    $(".loader").fadeOut(1000);
                    $(".call h1").text("Xəta Baş Verdi");
                }
            }
        });     
        
    }
    
}




function company() {
    var type = "company";
    var pass = $(".input1").val();
        pass = jQuery.trim(pass);
    var name = $("input[name=login1]").val();
        name = jQuery.trim(name);
    
    if (name == "") {
        alert("İstifadəçi adını qeyd edin");
    }
    else if (pass == "") {
        alert("Şifrənizi qedy edin");
    }
    else {
        $("#close h4 img").fadeIn();

        $.ajax({
            type:"post",
            data:{'type':type, 'pass':pass, 'name':name},
            url:"/ajax.php",
            success: function(result) {
                if (result == "GOOD") {
                    $("#close h4 img").fadeOut(-1000);
                    location="/temp2.php?lang=az&go=company&page=23";
                }
                else {
                    $("#close h4").text("Həta, Şifrə Düzgün Degil.");
                    $("#close h4 img").fadeOut(-1000);
                }
            }
        });
    }
    
}




function search() {
    var type = "search";
    var country = $("select[name=country]").val();
    var region = $("select[name=region]").val();
    var consepts = $("select[name=consept]").val();
    var segments = $("select[name=segment]").val();
    var name = $("input[name=hotelname]").val();

    if (name == "" && country == 0) {
        alert("Bolge secin");        
    }
    else {
        var searchData = "type="+type+"&country="+country+"&region="+region+"&consepts="+consepts+"&segments="+segments+"&name="+name;
        
        $.ajax({
            type:"post",
            data:searchData,
            url:"/ajax.php",
            success: function(result) {
                if (result != "ERROR") {
                    $(".loader").fadeOut(-2000);
                    $("#contentRight").html(result);
                    $("body,html").animate({"scrollTop":450});
                }
                else {
                    alert("Heta");
                }
            }
        });
    }
}



function regCompany() {
    var type = "reg";

    var you = $("input[name=you]:checked").val();

    var work_beach = $('input[name="work_beach"]').prop('checked');
    var work_tour = $('input[name="work_tour"]').prop('checked');
    var work_hotel = $('input[name="work_hotel"]').prop('checked');
    var work_avto = $('input[name="work_avto"]').prop('checked');
    var work_cruise = $('input[name="work_cruise"]').prop('checked');
    var work_buisness = $('input[name="work_buisness"]').prop('checked');
    var work_other = $("input[name=work_other]").val();
    
    var info_hotel = $('input[name="info_hotel"]').prop('checked');
    var info_offen = $('input[name="info_offen"]').prop('checked');
    var info_self = $('input[name="info_self"]').prop('checked');
    
    var people = $("input[name=people]").val();
    
    var meet_youoffice = $('input[name="meet_youoffice"]').prop('checked');
    var meet_myoffice = $('input[name="meet_myoffice"]').prop('checked');
    var meet_tourism = $('input[name="meet_tourism"]').prop('checked');
    var meet_other = $('input[name="meet_other"]').val();
    
    var companyname = $("input[name=companyname]").val();
    var face = $("input[name=face]").val();
    var responceble = $("input[name=responceble]").val();
    var adress = $("input[name=adress]").val();
    var telephone = $("input[name=telephone]").val();
    var regemail = $("input[name=regemail]").val();
    
    
    if (you == undefined) {
        alert("Kim oldugunuzu secin");
    }
    else if (work_beach == false && work_tour == false && work_hotel == false && work_avto == false && work_cruise == false && work_buisness == false && work_other == "") {
        alert("Выберите в каких сферах деятельности чотите сотрудничить.");        
    }
    else if (info_hotel == false && info_offen == false && info_self == false) {
        alert("Nə barədə məlumat almaq istərdiniz");
    }
    else if (people == "") {
        alert("Neçə nəfər oldugunuzu qeyd edin");
    }
    else if (meet_youoffice == false && meet_myoffice == false && meet_tourism == false && meet_other == "") {
        alert("Nə barədə məlumat almaq istərdiniz");
    }
    else if (companyname == "") {
        alert("Şirkətin adını qeyd edin.")
    }
    else if (face == "") {
        alert("Məsul şəxs.")
    }
    else if (responceble == "") {
        alert("Öxtəlik.")
    }
    else if (adress == "") {
        alert("Ünvan.")
    }
    else if (telephone == "") {
        alert("Telefon.")
    }
    else if (regemail == "") {
        alert("E-poçtunuz.")
    }
    else {
        $('.loader').fadeIn(200);
        var regData ="type="+type+"&you="+you+"&work_beach="+work_beach+"&work_tour="+work_tour+"&work_hotel="+work_hotel+"&work_avto="+work_avto+"&work_cruise="+work_cruise+"&work_buisness="+work_buisness+"&work_other="+work_other+"&info_hotel="+info_hotel+"&info_offen="+info_offen+"&info_self="+info_self+"&people="+people+"&meet_youoffice="+meet_youoffice+"&meet_myoffice="+meet_myoffice+"&meet_tourism="+meet_tourism+"&meet_other="+meet_other+"&companyname="+companyname+"&face="+face+"&responceble="+responceble+"&adress="+adress+"&telephone="+telephone+"&regemail="+regemail;
        
        $.ajax({
            type:"post",
            data:regData,
            url:"/ajax.php",
            success: function(result) {
                if (result == "GOOD") {
                    $("#regform form").html("<h1>Qeyydiyatınız müvəffəqiyətlə tamamlandı təşəkürlər</h1>");
                    $('.loader').fadeOut(-2000);
                }
                else {
                    alert("Heta");
                    $('.loader').fadeOut(-2000);
                }
            }
        });
    }
    
}













function slider(id, sid) {
    $("#s").animate({"marginTop":"-="+id})


    $("#sliderNav span").css({
        backgroundImage:"url(../css/img/navbg.png)",
        backgroundRepeat:"no-repeat",
        backgroundPosition:"1px 6px"
    })


    $("#sliderNav .sid" + sid).css({
        backgroundImage:"url(../css/img/navbg.png)",
        backgroundRepeat:"no-repeat",
        backgroundPosition:"-1px -18px"
    })

}







$(document).ready(function(){
    

    setTimeout('slider("160px", "2")', 3000);
    setTimeout('slider("160px", "3")', 6000);
    setTimeout('slider("160px", "4")', 9000);
    setTimeout('slider("160px", "5")', 12000);
    setTimeout('slider("160px", "6")', 15000);
    setTimeout('slider("160px", "7")', 18000);
    setTimeout('slider("160px", "8")', 21000);


    $("#backtop").hide(-7000);


	$(window).scroll(function () {
		if ($(this).scrollTop() > 150) {
			$('#backtop').fadeIn(1000);
		} else {
			$('#backtop').fadeOut(-7000);
		}
	});

	$('#backtop').click(function () {
		$('body,html').animate({
			scrollTop: 0
		}, 800);
		return false;
	});


    $("select[name=country]").change(function(){
        var type = "select";
        var country = $("select[name=country]").val();
        $(".loader").fadeIn();
        var selectData = "type="+type+"&country="+country;
        $.ajax({
            type:"post",
            data:selectData,
            url:"ajax.php",
            success: function(result) {
                if (result != "ERROR") {
                    $(".loader").fadeOut(-2000);
                    $("select[name=region]").html(result);
                }
                else {
                    alert("df");
                }
            }
        }); 
        
    });







    var countImg = $("#s li").length;
    var heightImg = $("#s li").height();
    var allHeight = countImg * heightImg;
        allHeight = allHeight + "px";
    $("#s").css("height",allHeight);
    
    
    var a = 0;
    var goStart = countImg * heightImg - heightImg + "px";
    
    $("#sliderNav span").click(function() { 
        var id = $(this).attr("id") - 1;
        var old = id;
        
        $("#sliderNav span").css({
            backgroundImage:"url(../css/img/navbg.png)",
            backgroundRepeat:"no-repeat",
            backgroundPosition:"1px 6px"
        })
        
        $(this).css({
            backgroundImage:"url(../css/img/navbg.png)",
            backgroundRepeat:"no-repeat",
            backgroundPosition:"-1px -18px"
        })
        
    
        if (a == countImg-1) {
            $("#s").animate({"marginTop":"+="+goStart})                    
            a = 0;
        }
        else {
            a++;
            $("#s").animate({"marginTop":"-="+heightImg})
        }
    })
    
    function start(){
        $("#s").animate({"marginTop":"-="+heightImg});
    }








    $(".inp").focus(function(){$(this).val('');});
    $(".inp1").focus(function(){$(this).val('');});
    
    $("#emailForm").click(function(){
        $("#email").fadeIn(500);
        
    })


    $(".country").hover(function() {
        $(this).animate({opacity : 1});
    }),function(){
        $(this).animate({opacity : 0.6});
    }
    

    $('.country').hover(
    function(){
        $(this).animate({opacity : 1});
    },
    function(){
        $(this).animate({opacity : 0.7});
    });


    $('.onegallery').hover(
    function(){
        $(this).animate({border:"1px solid black",});
    },
    function(){
        $(this).animate({border:"1px solid black",});
    });











});
