$(document).ready(function () {

    // Twitter Feed
    $('#tool-bar .twitter').click(function () {
        $('#twitter').animate({ "height": "toggle", "bottom": "45" }, "slow");
        getTwitters('tweet-feeds', {
            id: 'artbees_design', // add your twitter id here!
            count: 4,  // the count of tweets you want to be shown on the list
            enableLinks: true, // to enable the links
            ignoreReplies: true, 
            template: '<div class="tweet-text"><span class="user-name"> <b>%user_screen_name% </b> Says:<a class="time" href="http://twitter.com/%user_screen_name%/statuses/%id%">(%time%)</a></span><br/>%text%</div>',
            newwindow: true
        });
        return false;
    });


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



    // close button
    $('#contact-form .close').click(function () { $('#contact-form').animate({ height: "toggle", "bottom": "40" }, "slow"); return false; });


    // Show contact form when clicked
    $('#tool-bar .contact').click(function () { $('#contact-form').animate({ "height": "toggle", "bottom": "45" }, "slow"); return false; });

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



    // 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("ppls.php", { txtName: txtNameVal, txtEmail: txtEmailVal, txtSubject: txtSubjectVal, txtComment: txtCommentVal },
   					             function (data) {
   					                 $("#contact-form .container-inner").delay(2000).fadeOut("slow");
   					                 $("#contact-form .thankyou").delay(3000).fadeIn("slow");
   					                 $("#contact-form").delay(6000).animate({ height: "toggle", "bottom": 45 });
   					             });

        }
        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, YOUR EMAIL LISTED");

            });

        }
        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');
Cufon.replace('.copyright', { textShadow: '#5d5d5d 1px 1px' });
Cufon.replace('#twitter .header', { textShadow: '#58d6ff 0px 1px' });
Cufon.replace('#contact-form .header', { textShadow: '#c9ae00 0px 1px' });
