$(document).ready(function() {

    $(img).load(function () {
        //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
        $(this).hide();
        $('#mainPicture').removeClass('loading').append(this);
        $(this).fadeIn();
    }).error(function () {
        // notify the user that the image could not be loaded
    }).attr('src', 'images/banners/home1.png');
    
	var text = '<span class=highlight>Please complete this form for News, Tips and Updates</span><br><br>';
	var firstname = '<label for="firstname">First Name : </label><input class="js" type="text" id="firstname" name="firstname" value="" size="40"/><br/>';
	var surname = '<label for="surname">Surname : </label><input class="js" type="text" id="surname" name="surname" value="" size="40"/><br/>';
	var email = '<label for="email">Email : </label><input class="js" type="text" id="email" name="email" value="" size="40"/><br/>';
	var txt2=text+firstname+surname+email;
	
	function mysubmitfunc2(v,m,f){
			  if(v==0) $.prompt.close();
			  else {
				  

			      var email=$('#email').val();
			      var firstname=$('#firstname').val();
			      var surname=$('#surname').val();

			      an = m.children('#email');
			      if(email == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      an = m.children('#firstname');
			      if(firstname == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      an = m.children('#surname');
			      if(surname == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      var urlIn = "submit_register.php?email="+email+"&firstname="+firstname+"&surname="+surname;
				  	 
					 $.ajax({
					   type: "POST",
					   url: urlIn,
					   dataType: "html",
			  				success: function(html) { 
							alert(html);									  
						  }
					 });
			      return true;
			  }
		}

		
	$("#rightevents").click(function(){	
		
		$.prompt(txt2,{								     
		      submit: mysubmitfunc2,
		      prefix: 'colsJqi',
		      buttons: { Submit:true , Cancel: false }
		});
	});	
    
	var text = '<span class=highlight>Please complete this form and we will contact you as soon as possible</span><br><br>';
	var firstname = '<label for="firstname">First Name : </label><input class="js" type="text" id="firstname" name="firstname" value="" size="40"/><br/>';
	var surname = '<label for="surname">Surname : </label><input class="js" type="text" id="surname" name="surname" value="" size="40"/><br/>';
	var companyname = '<label for="companyname">Company Name : </label><input class="js" type="text" id="companyname" name="companyname" value="" size="40"/><br/>';
	var direct = '<label for="direct">Telephone Number : </label><input class="js" type="text" id="direct" name="direct" value="" size="20"/><br/>';
	var txt=text+firstname+surname+companyname+direct;
	
	function mysubmitfunc(v,m,f){
			  if(v==0) $.prompt.close();
			  else {
				  
				  var firstname=$('#firstname').val();
			      var surname=$('#surname').val();
			      var direct=$('#direct').val();
			      var companyname=$('#companyname').val();
			      an = m.children('#firstname');
			      if(firstname == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      an = m.children('#surname');
			      if(surname == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      an = m.children('#direct');
			      if(direct == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      an = m.children('#companyname');
			      if(companyname == ""){
			            an.css("border","solid #ff0000 1px");
			            return false;
			      }
			      var urlIn = "submit_callback.php?firstname="+firstname+"&surname="+surname+"&direct="+direct+"&companyname="+companyname;
				  	 
					 $.ajax({
					   type: "POST",
					   url: urlIn,
					   dataType: "html",
			  				success: function(html) { 
							alert(html);									  
						  }
					 });
			      return true;
			  }
		}

		
	$("#rightcallback").click(function(){	
		
		$.prompt(txt,{								     
		      submit: mysubmitfunc,
		      prefix: 'colsJqi',
		      buttons: { Submit:true , Cancel: false }
		});
			$('#contactname').focus();
	});	


	$.ajaxSettings.cache = false;
    $("#topic2").hide();
    $("#topic3").hide();
    $("#topic4").hide();
    $("#list4").hide();
    $("#list5").hide();
    $("#mainPicture2").hide();
    $("#mainPicture3").hide();

    $("#business-solutions").click(function () { 
	      $("#topic").hide();
	      $("#topic2").fadeIn();
	      $("#topic3").hide();
	      $("#topic4").hide();
	      $("#list3").fadeIn();
	      $("#list4").hide();	      	       
	      $("#list5").hide();	      	       
 			refreshContent('HTML/BS_landing.php');       
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#mainPicture').removeClass('loading').append(this);
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', 'images/banners/business-communication-solutions.png');	      	       
	    
	    });

	$("#products").click(function () { 
	      $("#topic").hide();
	      $("#topic2").hide();
	      $("#topic3").fadeIn();
	      $("#topic4").hide();
	      $("#list3").hide();
	      $("#list4").fadeIn();	      	       
	      $("#list5").hide();	       
			refreshContent('HTML/P_Products_main_text.php');
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#mainPicture').removeClass('loading').append(this);
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', 'images/banners/products.png');	      	       

	    });
	$("#services").click(function () { 
	      $("#topic").hide();
	      $("#topic2").hide();
	      $("#topic3").hide();
	      $("#topic4").fadeIn();
	      $("#list3").hide();
	      $("#list4").hide();	      	       
	      $("#list5").fadeIn();	       
			refreshContent('HTML/S_Services_main_text.php'); 
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#mainPicture').removeClass('loading').append(this);
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', 'images/banners/services.png');	      	       
	    });
	$("#broadband").click(function () { 
       
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#mainPicture').removeClass('loading').append(this);
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', 'images/banners/broadband.png');	      	       
	    });

	jQuery('#list3').accordion({
		header: 'div.title',
		active: false,
		alwaysOpen: false,
		animated: false,
		autoheight: false
	});
	jQuery('#list4').accordion({
		header: 'div.title',
		active: false,
		alwaysOpen: false,
		animated: false,
		autoheight: false
	});
	jQuery('#list5').accordion({
		header: 'div.title',
		active: false,
		alwaysOpen: false,
		animated: false,
		autoheight: false
	});
	
// IMAGES	
	$("#cabling").click(function () { 
      	refreshImage('images/banners/calbing.png');       
    });
	$("#low_rate_calls").click(function () { 
      	refreshImage('images/banners/low-rate-calls.png');       
    });
	$("#non-geo").click(function () { 
      	refreshImage('images/banners/non-geographic-numbers.png');       
    });
	$("#competitive-ip").click(function () { 
      	refreshImage('images/banners/competitive-ip-tariffs.png');       
    });
	$("#telephone-systems").click(function () { 
      	refreshImage('images/banners/telephone-systems.png');       
    });
	$("#broadband").click(function () { 
      	refreshImage('images/banners/broadband.png');       
    });
	$("#private-leased").click(function () { 
      	refreshImage('images/banners/private-leased-circuits.png');       
    });
	$("#ethernet-for-wan").click(function () { 
      	refreshImage('images/banners/Ethernet-for-WAN.png');       
    });
	$("#data-solutions").click(function () { 
      	refreshImage('images/banners/data-connectivity.png');       
    });
	$("#mobile-solutions").click(function () { 
      	refreshImage('images/banners/mobile-solutions.png');       
    });
	$("#it-solutions").click(function () { 
      	refreshImage('images/banners/it-solutions.png');       
    });
	$("#telephone-system").click(function () { 
      	refreshImage('images/banners/telephone-systems.png');       
    });
	$("#it-consultancy").click(function () { 
      	refreshImage('images/banners/it-consultancy.png');       
    });
	$("#line-rental").click(function () { 
      	refreshImage('images/banners/line-rental.png');       
    });
	$("#account-management").click(function () { 
      	refreshImage('images/banners/account-management.png');       
    });
	$("#business-communication").click(function () { 
      	refreshImage('images/banners/business-communication-solutions.png');       
    });
	$("#careers").click(function () { 
      	refreshImage('images/banners/Careers.png');       
    });
	$("#contact-us").click(function () { 
      	refreshImage('images/banners/contact-us.png');       
    });
	$("#disaster-recovery").click(function () { 
      	refreshImage('images/banners/disaster-recovery.png');       
    });
	$("#homeband").click(function () { 
      	refreshImage('images/banners/homeband.png');       
    });
	$("#internet-security").click(function () { 
      	refreshImage('images/banners/Internet-Security.png');       
    });
	$("#ip-telephony").click(function () { 
      	refreshImage('images/banners/ip-telephony-products.png');       
    });
	$("#large-enterprise").click(function () { 
      	refreshImage('images/banners/large-enterprise.png');       
    });
	$("#medium-business").click(function () { 
      	refreshImage('images/banners/medium-sized-business.png');       
    });
	$("#mitel").click(function () { 
      	refreshImage('images/banners/mitel.png');       
    });
	$("#mobile-data").click(function () { 
      	refreshImage('images/banners/mobile-data-solutions.png');       
    });
	$("#mobile-products").click(function () { 
      	refreshImage('images/banners/mobile-products.png');       
    });
	$("#mobile-networks").click(function () { 
      	refreshImage('images/banners/mobiles-and-networks.png');       
    });
	$("#mobile-tracking").click(function () { 
      	refreshImage('images/banners/mobile-tracking-devices.png');       
    });
	$("#industry-solutions").click(function () { 
      	refreshImage('images/banners/industry-solutions.png');       
    });
	$("#networks").click(function () { 
      	refreshImage('images/banners/networks.png');       
    });
	$("#panasonic").click(function () { 
      	refreshImage('images/banners/panasonic.png');       
    });
	$("#remote-working").click(function () { 
      	refreshImage('images/banners/remote-working.png');       
    });
	$("#small-and-home").click(function () { 
      	refreshImage('images/banners/small-and-home-office.png');       
    });
	$("#mobile-software").click(function () { 
      	refreshImage('images/banners/software.png');       
    });
	$("#splicecom").click(function () { 
      	refreshImage('images/banners/splicecom.png');       
    });
	$("#technology").click(function () { 
      	refreshImage('images/banners/technology-advice.png');       
    });
	$("#training").click(function () { 
      	refreshImage('images/banners/training.png');       
    });
	$("#unified-messaging").click(function () { 
      	refreshImage('images/banners/unified-messaging.png');       
    });
	$("#website-hosting").click(function () { 
      	refreshImage('images/banners/website-and-email-hosting.png');       
    });
	$("#business-telephone-solutions").click(function () { 
      	refreshImage('images/banners/telephone-solutions.png');       
    });
	$("#mobiles-and-networks").click(function () { 
      	refreshImage('images/banners/mobiles-and-networks.png');       
    });
	$("#maintenance").click(function () { 
      	refreshImage('images/banners/maintenance.png');       
    });
	$("#network-infrastructure").click(function () { 
      	refreshImage('images/banners/Network-infrastructure.png');       
    });
	$("#cabling-solutions").click(function () { 
      	refreshImage('images/banners/calbing.png');       
    });
	$("#privacy").click(function () { 
      	refreshImage('images/banners/home1.png');       
    });
	$("#unified-communications").click(function () { 
      	refreshImage('images/banners/unified-communications.png');       
    });
	$("#read-more").click(function () { 
      	refreshImage('images/banners/news.png');       
    });
	$("#it-services").click(function () { 
      	refreshImage('images/banners/it-services.png');       
    });
	$("#IP-Telephony").click(function () { 
      	refreshImage('images/banners/ip-telephony-products.png');       
    });
	$("#sip-trunking").click(function () { 
      	refreshImage('images/banners/sip1.png');       
    });
	$("#video-conferencing").click(function () { 
      	refreshImage('images/banners/sip2.png');       
    });				
					
		
}); 

var img = new Image();
function refreshImage(imglocation)	{

	$(img).load(function () {
		//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
        $(this).hide();
        $('#mainPicture').removeClass('loading').append(this);
        $(this).fadeIn();
    }).error(function () {
        // notify the user that the image could not be loaded
    }).attr('src', imglocation);
}

function refreshContent(urlIn) {

$("#copy-middle").fadeOut("normal", function(){
     $("#copy-middle").load(urlIn,false, function() {
            $("#copy-middle").fadeIn("normal");
        });
    })
    return false;
}