var $$=jQuery.noConflict();
$$(document).ready(function()
{
	$$('.blank').attr('target','_blank');
    $$("button").show();
    $$(".submit").hide();
    
      $$(function() {
        var zIndexNumber=1000;
        $$('div').each(function(){
            $$(this).css('zIndex', zIndexNumber);
            zIndexNumber-=10;
        });
    });
    
    $$("input:text, textarea").each(function() 
    { 
        this.defaultText = this.value; 
        $$(this).focus(function() 
        { 
            if (this.value == this.defaultText) this.value = "";
        })
        $$(this).blur(function() 
        { 
            if (this.value == "" && this.defaultText) this.value = this.defaultText; 
        });    
    });
    
    
    $$("#dialog-enquiry").dialog({modal:true, title:'Enquiry',autoOpen:false,draggable: false,modal: true,width: 300,height: 300,resizable: false});
    $$("#dialog-webmail").dialog({modal:true, title:'Webmail',autoOpen:false,draggable: false,modal: true,width: 300,height: 300,resizable: false});
    $$("#dialog-newsletter").dialog({modal:true, title:'Newsletter',autoOpen:false,draggable: false,modal: true,width: 300,height: 300,resizable: false});
    $$("#dialog-login").dialog({modal:true, title:'Login',autoOpen:false,draggable: false,modal: true,width: 300,height: 300,resizable: false});

    $$('.webmail').click(function() {

            $$("#dialog-webmail").show();
            $$("#dialog-webmail").dialog('open');}
    );
    
    $$('#dialog-webmail a').click(function() {

             window.location.href = 'https://webmailcluster.1and1.co.uk';
    });
    
    
    $$('#form-enquiry-button').click(function() {
    $$.ajax({
        
        type: "POST",
        url: "includes/php/php-actions.php",
        data: ({
                    script : "on", 
                    action : "enquiry", 
                    "form-enquiry-office" : $$('#form-enquiry-office').val(),
                    "form-enquiry-name" : $$('#form-enquiry-name').val(), 
                    "form-enquiry-email" : $$('#form-enquiry-email').val(), 
                    "form-enquiry-telephone" : $$('#form-enquiry-telephone').val(), 
                    "form-enquiry-budget" : $$('#form-enquiry-budget').val(),
                    "form-enquiry-message" : $$('#form-enquiry-message').val(), 
                    "form-enquiry-captcha" : $$('#form-enquiry-captcha').val()}), 
                    cache: false,
                    success: function(result)
                    {
                        
                        if (result=="Thank you very much for your enquiry, we will contact you by telephone or email within three working days.<br /><br />Please close this box to return to our website.")
                        {
                            $$("#dialog-enquiry").dialog('open');
                            $$("#dialog-enquiry").html(result);
                        }
                        else
                        {
                            $$("#dialog-enquiry").dialog('open');
                            $$("#dialog-enquiry").html(result);
                        }
  
                    }
            });
            }
    );

    $$('#form-newsletter-button').click(function() {
    $$.ajax({
        
        type: "POST",
        url: "includes/php/php-actions.php",
        data: ({
                    script : "on", action : "newsletter", 
                    "form-newsletter-email" : $$('#form-newsletter-email').val()}),
                    cache: false,
                    success: function(result)
        {
            $$("#dialog-newsletter").html(result);
        }
            
    });
    $$("#dialog-newsletter").dialog('open');}
    );
    
    
     
     
    $$('#form-login-button').click(function() {
    $$.ajax({
        
        type: "POST",
        url: "includes/php/php-actions.php",
        data: ({
                    script : "on", 
                    action : "login", 
                    "form-login-email" : $$('#form-login-email').val(), 
                    "form-login-password" : $$('#form-login-password').val()}), 
                    cache: false,
                    success: function(result)
        {
            
            if (result=="logging in")
            {
                window.location.href = 'cms/index.php';
            }
            else
            {
                $$("#dialog-login").html(result);
            }
        }
            
    });
    $$("#dialog-login").dialog('open');}
    );
    
    


    
    

    $$('.slideshow-inner')
    .before('<div class="slideshow-navigation">') 
    .cycle({ 
        
        fx: 'fade', 
        timeout: 5000, 
        pager:  '.slideshow-navigation' 
        
    });
    
    $$('.testimonials-inner')
    .cycle({ 
        
        fx: 'fade', 
        timeout: 10000    
    });
    
    
    


    
 
});
