function show_cloud(i)
{
    var data = new Array("<h4 class='violet bold'>Strategic Marketing Consultancy</h4>Providing a complete marketing consultancy service at a strategic level for small, medium and large organisations.",
                         "<h4 class='violet bold'>Brand Development</h4>From creation of new brands to the revitalisation of existing brands, We have the experience to support your most valuable asset.",
                         "<h4 class='violet bold'>Integrated Marketing</h4>Creatively combining marketing disciplines to deliver campaigns that achieve objectives and maximise return on investment.",
                         "<h4 class='violet bold'>Advertising and Media Planning</h4>Delivering proposition, differentiation and response through off and on-line advertising and media planning.",
                         "<h4 class='violet bold'>Digital Services</h4>Cutting edge digital strategy, design and implementation to provide interaction and information dissemination through a complete range of digital media including corporate web sites, tactical web sites, eDM and on-line marketing.",
                         "<h4 class='violet bold'>Social Marketing</h4>A complete social marketing service utilising all aspects of social media, to build awareness and exposure with both business and consumer audiences.",
                         "<h4 class='violet bold'>Direct Response</h4>Whether on or off-line, we create effective tagetted campaigns that drive response.",
                         "<h4 class='violet bold'>Design Services</h4>Creating and designing a range of marketing material, including literature, point-of-sale and exhibition graphics, to ensure that your company portrays the right impression.",
                         "<h4 class='violet bold'>Experiential Marketing</h4>Engaging customers face to face through a range of activities that allow products and sevices to be experienced."
                        );
    var pos = $("#list_"+i).offset();
    $("#cloud").css({top: pos.top-58, left: pos.left-315});
    $("#cloud").show();
    $("#cloud_label").html(data[i]);
}

function mail_box(action,name)
{
    if($("#customer_"+name).val() == 'Email' || 
       $("#customer_"+name).val() == 'Name'
       && action=="empty")
    {
        $("#customer_"+name).val('');
        $("#customer_"+name).css({color: '#000000'});
    }
    if($("#customer_"+name).val() == '' && action=="fill")
    {
        if(name=='name') $("#customer_"+name).val('Name');
        else $("#customer_"+name).val('Email');
        $("#customer_"+name).css({color: '#bbbbbb'});
    }
}

function register_email()
{
    if(!$("#customer_name").val() || $("#customer_name").val()=='Enter your name'){
        alert('Please fill in your name.');
        return 0;
    }
    
    if(validate_email($("#customer_email").val()))
    {
        $.ajax({ 
			   type: "POST", 
			   url: BASE_URI+'newsletters/subscribe', 
			   data: "btnSignup=bt&email="+$("#customer_email").val()+"&name="+$("#customer_name").val(), 
			   success: function(msg){
	               //_gaq.push(['_trackPageview', '/virtual/newsletter-thanks']);
	               alert("Thanks! You have successfully subscribed to the latest thinking from BallantyneTaylor."); 
                },
                error: function(obj,msg){
                    alert("Oops, your details didn't come through.\r\nYou might already be subscribed or there's a temporary error.");
                }
        });

        
        /*$.post(BASE_URI+'newsletter/subscribe/', { btnSignup: "bt", email: $("#customer_mail").val() }, 
            function(data){ 
                _gaq.push(['_trackPageview', '/virtual/newsletter-thanks']);
                alert("Thanks! You have successfully subscribed to BallantyneTaylor newsletter."); 
        });*/

    }
}

function validate_email(address) 
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }
   return true;
}

function show_label(id,object)
{
    $(id,object).slideDown();
}

function hide_label(id,object)
{
    $(id,object).slideUp();
}

function send_email()
{
    if(!$("#subject").val())
    {
        alert('Please fill the Subject.');
        return 0;
    }
    if(!$("#body").val())
    {
        alert('Please fill the email message.');
        return 0;
    }
    if(validate_email($("#email").val()))
    {
        $.post(BASE_URI+'contact_email/', {  subject: $("#subject").val(), 
                                     body: $("#body").val(),
                                     email: $("#email").val(),
                                     to: $("#to").val()
                                    }, 
            function(data){ 
                
                person_name = person_name.length ? person_name : 'Someone'; 
                
                if(data.match(/86483264873264/))
                {
                    $("#email_inner").html('<script type="text/javascript">_gaq.push([\'_trackPageview\', \'/virtual/contact-us-thanks/'+person_name+'\']);</script>'
                                            +'<h2 class="h2_special">Thanks for the message.<br/>'
                                            +person_name+' will be in touch with you shortly.</h2>'
                                            +'<a onclick="parent.$.fancybox.close()" class="pointer bold">&#171; BACK</a>'
                                            );
                }
                else
                {
                    $("#email_inner").html('<h2>Unknown error. Please try again.</h2>');
                }
        });
    }
}

function share_box()
{
    if($('#share').is(':hidden'))
    {
        $('#share').slideDown('slow', function() {
            $.fancybox.resize();
        });
    }
    else
    {
        $('#share').slideUp('slow', function() {
            $.fancybox.resize();
        });
    }
}

function dump(arr,level) {
    var dumped_text = "";
    if(!level) level = 0;
    
    //The padding given at the beginning of the line.
    var level_padding = "";
    for(var j=0;j<level+1;j++) level_padding += "    ";
    
    if(typeof(arr) == 'object') { //Array/Hashes/Objects 
        for(var item in arr) {
            var value = arr[item];
            
            if(typeof(value) == 'object') { //If it is an array,
                dumped_text += level_padding + "'" + item + "' ...\n";
                dumped_text += dump(value,level+1);
            } else {
                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
            }
        }
    } else { //Stings/Chars/Numbers etc.
        dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
    }
    return dumped_text;
}
