$(document).ready(function(){
    $('.site').click(function(){document.location.href='http://www.phonesexdepot.com';});
    var tempText = "test";
    //$('.menu').html('<a href="advertising_rates.html">Rates/Availability</a><a href="new_account.html">Sign up for an account</a><a href="member_login.html">Member Login</a><a href="contactus.html">Contact Us</a><a href="phonesexdepot_faqs.pdf">FAQS</a>');
    $('.menu').html('<a href="advertising_rates.html">Rates/Availability</a><a href="phonesexdepot_faqs.pdf">FAQS</a>');
    $('.footer').html('Copyright&copy;2011 Phonesexdepot.com&nbsp;&nbsp;&nbsp;Phone:&nbsp;919.421.4068&nbsp;&nbsp;Email:&nbsp;phonesexdepot@gmail.com');
    $('.required').focusout(function(){
        if($(this).val() == "" || $(this).val() == " " || $(this).val() == "  "){
            $(this).prev().children().css({'color':'red','font-weight':'bold'});
            $(this).css({'border':'solid 2px red'});
        }else{
            $(this).removeAttr('style');
        }
    });
    $('#stylized input[type="text"], #stylized input[type="password"]').focusout(function(){
        $(this).prev().children().removeAttr('style');
        $(this).removeAttr('style');
        var msg = $(this).val();
        switch($(this).attr('name')){
            case 'email':
            var answer = isValidEmailAddress(msg);
            if(!answer){
                $(this).prev().children().css({'color':'red','font-weight':'bold'});
                $(this).css({'border':'solid 2px red'});
                //alert('bad email');
            }
            break;
            
            case 'password':
            if(msg.length < 6){
                $(this).prev().children().css({'color':'red','font-weight':'bold'});
                $(this).css({'border':'solid 2px red'});
            }
            break;
        }
        /*tempText = $(this).prev().children().text();*/
    });
    /*
    $('#form').submit(function(){
        
        if ($('input[name="email"]').attr('style')) {//email input
            alert('Please correct errors and then resubmit.');
            return false;
        }
        if ($('input[type="password"]').attr('style')) {//password input
            alert('Please correct errors and then resubmit.');
            return false;
        }
        if($('.required').val() == "" || $('.required').val() == " " || $('.required').val() == "  "){//required fields
            alert('A required field has been left blank.');
            return false;
        }
        var checkbox = $(this).find('input[type="checkbox"]:checked');
        if(!checkbox.length){//TOS checkbox
            alert('You must agree to our terms of service to join.');
            return false;
        }
        //process form
        $.ajax({
            type: "POST",
            url: "scripts/email.php",
            data: "contact="+$('input:eq(0)').val()+"&company="+$('input:eq(1)').val()+"&email="+$('input:eq(2)').val()+"&phone="+$('input:eq(3)').val()+"&password="+$('input:eq(4)').val()+"&webaddress="+$('input:eq(5)').val()+"&bannerurl="+$('input:eq(6)').val()+"&description="+$('textarea').val()+"&position="+"R1"+"&category="+$('option:selected').val(),
            success: function(msg){
                alert( msg );
            }
        });
        return false;
    });*/
    
    //$('.buyCenter, .buySide, .buyFeat').click(function(){
    /*$('.myspace').click(function(){                                          
        var hat;
        var pageHeight = 2200;
        var formHeight = 425;// css height for billingForm
        var pos = $(this).position();
        if((pos.top + (formHeight/2)) >= (pageHeight - 20)){
            var offset = (pos.top + (formHeight/2)) - (pageHeight - 20);
            pos.top -= offset;
	    hat = (pos.top - (formHeight/2));
        }else if((pos.top - (formHeight/2)) <= 20){
            hat = 20;
        }else{
	    hat = (pos.top - (formHeight/2));
        }
        $('div#billingForm').css({'top': + hat + 'px'});
                               
        $('div#billingBox').fadeIn('slow');
        $('div#billing').fadeIn('slow');
    });*/
    
    $('div#billingBox').click(function(){
        //$(this).hide();
        $(this).fadeOut('slow');
        $('div#billing').fadeOut('slow');
    });
    
    function checkValidity(){
        
    }
    
    function isValidEmailAddress(emailAddress) {
        var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
        //alert( pattern.test(emailAddress) );
        return pattern.test(emailAddress);
    };
});
