$(document).ready(function () {

    // Solve Z-index problem in Internet Explorer 7
    $(function () {
        var zIndexNumber = 1000;
        $('div span').each(function () {
            $(this).css('zIndex', zIndexNumber);
            zIndexNumber -= 10;
        });
    });

    // Twitter Feed
    getTwitters('tweet-feeds', {
        id: 'nuroute', // add your twitter id here!
        count: 3,  // the count of tweets you want to be shown on the list
        enableLinks: true, // to enable the links
        ignoreReplies: true,
        withFriends: true,
        template: '<div class="tweet-text"><div class="user-name"> <b>%user_screen_name% </b> Says:</div><a class="time" href="http://twitter.com/%user_screen_name%/statuses/%id%">(%time%)</a><div class="text">%text%</div></div>',
        newwindow: true
    });





    // close button
    $('#contact-form .close').click(function () { $('#contact-form').animate({ opacity: "hide" }, "fast") });


    // Show contact form when clicked
    $('.tooltip-links .contact').click(function () { $('#contact-form').animate({ opacity: "show" }, "fast"); });

    // Icon's tooltip
    $(".tooltip-links a").hover(
                function () { $(this).next("em").stop(true, true).animate({ opacity: "show", top: "-50" }, "slow"); },
                function () { $(this).next("em").animate({ opacity: "hide", top: "-60" }, "fast"); });

    // Animate alternative icons in vertical offset
    $(".tooltip-links a").hover(
                function () { $(this).stop(true, true).animate({ bottom: "3px", opacity: 05 }, 200) },
                function () { $(this).animate({ bottom: "0px" }, 200) });


    // contact form
    $("#contact-form .button").click
            (function () {
                $(".field-error").hide();
                var hasError = false;

                // Create Variable Name and checks whether left blank or not.
                var txtNameVal = $("#txtName").val();
                if (txtNameVal == '') {
                    $("#txtName").after('<span class="field-error">Please enter the subject.</span>');
                    hasError = true;
                }


                // Create Variable Email and checks whether left blank or not and checks is Email.
                var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
                var txtEmailVal = $("#txtEmail").val();
                if (txtEmailVal == '') {
                    $("#txtEmail").after('<span class="field-error">Please enter the email address.</span>').show('slow');
                    hasError = true;
                }
                else if (!emailReg.test(txtEmailVal)) {
                    $("#txtEmail").after('<span class="field-error">please enter a valid email address.</span>');
                    hasError = true;
                }


                // Create Variable Subject and checks whether left blank or not.
                var txtSubjectVal = $("#txtSubject").val();
                if (txtSubjectVal == '') {
                    $("#txtSubject").after('<span class="field-error">Please enter the subject.</span>');
                    hasError = true;
                }

                // Create Variable Comment and checks whether left blank or not.
                var txtCommentVal = $("#txtComment").val();
                if (txtCommentVal == '') {
                    $("#txtComment").after('<span class="field-error">Please enter the message.</span>');
                    hasError = true;
                }


                // if above conditions are false will run inside scripts
                if (hasError == false) {
                    $('.contact-submit').fadeOut(50)
                    $("#contact-form .loading").delay(100).fadeIn("slow");
                    $.post("mail.php", { txtName: txtNameVal, txtEmail: txtEmailVal, txtSubject: txtSubjectVal, txtComment: txtCommentVal },
   					             function (data) {


   					                 $("#contact-form .container").delay(2000).fadeOut("slow");
   					                 $("#contact-form .thankyou").delay(3000).fadeIn("slow");
   					                 $("#contact-form").delay(8000).fadeOut("slow");
   					             });

                }
                return false;


            });

    // Submission form
    $("#submission .button").click(function () {

        $(".field-error").hide();
        var hasError = false;
        // Create Variable Email and checks whether left blank or not and checks is Email.
        var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        var txtsubscribeVal = $("#txtsubscribe").val();

        if (!emailReg.test(txtsubscribeVal)) {
            $("#txtsubscribe").val('ENTER A VALID EMAIL ADDRESS.');
            hasError = true;
        }

        if (txtsubscribeVal == '') {
            $("#txtsubscribe").val('ENTER YOUR EMAIL ADDRESS');
            hasError = true;
        }

        $("#txtsubscribe").focus(function () {
            $(this).val("");
        });


        // if above conditions are false will run inside scripts
        if (hasError == false) {

            $("#txtsubscribe").delay(2000).val("PROCCESSING...");
            $.post("subscribe.php", { txtsubscribe: txtsubscribeVal },
            function (data) {

                $("#txtsubscribe").delay(6000).val("THANK YOU");

            });

        }
        return false;


    });



    // Submission form
    $("#subscribe .button").click(function () {

        $(".field-error").hide();
        var hasError = false;
        // Create Variable Email and checks whether left blank or not and checks is Email.
        var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        var txtsubscribeVal = $("#txtsubscribe").val();

        if (!emailReg.test(txtsubscribeVal)) {
            $("#txtsubscribe").val('ENTER A VALID EMAIL ADDRESS.');
            hasError = true;
        }

        if (txtsubscribeVal == '') {
            $("#txtsubscribe").val('ENTER YOUR EMAIL ADDRESS');
            hasError = true;
        }

        $("#txtsubscribe").focus(function () {
            $(this).val("");
        });


        // if above conditions are false will run inside scripts
        if (hasError == false) {

            $("#txtsubscribe").delay(2000).val("PROCCESSING...");
            $.post("subscribe.php", { txtsubscribe: txtsubscribeVal },
            function (data) {

                $("#txtsubscribe").delay(6000).val("THANK YOU");

            });

        }
        return false;


    });


    //This will initialize jquery.pngfix.js and fix the missing PNG-Transparency in Windows Internet Explorer 5.5 & 6. 
    $(document).pngFix();

})


/* Replace all body texts to desired fonts, you can set your 
desired tag name or class or ID value to cufon replace selector! 
** This code shoud be outside of "$(document).ready(function(){****})" **
*/
Cufon.replace('.cufon');

