// JavaScript Document

// Get the HTTP Object
function getHTTPObject(){
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) return new XMLHttpRequest();
   else {
      alert("Your browser does not support AJAX.");
      return null;
   }
}

//function clearOutput(){
//        document.getElementById('menuheading').innerHTML = '<h2>Which type of door would you like to view?</h2>';
//}
 
// Change the value of the Inner HTML of the Division

function setOutput(){
    if(httpObject.readyState == 4){
        document.getElementById('menu2').innerHTML = httpObject.responseText;
		document.getElementById('menuheading').innerHTML = '<h2>Please make your selection when prompted</h2>';
		//if (globaltype == 'build your own playsystem'){
     	//topcaption = 'To begin select Towers from the drop down menu';
		//document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
    	//}


            switch (globaltype) {
            case "Create a Playsystem":
                  topcaption = 'To begin select Towers from the drop down menu';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;
            
            case "Pick a Playsystem":
                  topcaption = 'Please select a playsystem';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;

            case "other":
                  topcaption = 'Please select from drop down menu';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;
                        
            case "", "?":
                 default:
                 topcaption = 'Please make your selection when prompted - default';
         }
    }
}
 

function setOutputnew(){
    if(httpObject.readyState == 4){
        document.getElementById('menu2').innerHTML = httpObject.responseText;
		document.getElementById('menuheading').innerHTML = '<h2>Please make your selection when prompted</h2>';

            switch (globaltype) {
            case "Create a Playsystem":
                  topcaption = 'To begin select Towers from the drop down menu';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;
            
            case "Pick a Playsystem":
                  topcaption = 'Please select a playsystem';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;

            case "other":
                  topcaption = 'Please select from drop down menu';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;
                        
            case "", "?":
                 default:
                 topcaption = 'Please make your selection when prompted - default';
         }
    }
}



function setOutput2(){
    if(httpObject.readyState == 4){
        document.getElementById('resultsgohere').innerHTML = httpObject.responseText;

        switch (globalcat) {
            case "Towers":
                 topcaption = 'First choose your Tower(s)';
				 bottomcaption = '<p>Choose the tower(s) you want for your playsystem from this page, then select Add Ons from the drop down menu above.</p>';
				if (globallogin == 'true') {
				 bottomcaption += '<p>Download the instuctions for &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'creating_a_playsystem.pdf\')" title="Creating a Playsystem">creating_a_playsystem.pdf</a></p>';
				 bottomcaption += '<p>Download the &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'playsystem_pricelist.pdf\')" title="Playsystem Price List">playsystem_pricelist.pdf</a></p>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;
                  
            case "Add Ons":
                 topcaption = 'Next choose Add On(s)';
				 bottomcaption = '<p>Choose the add ons you want for your playsystem. Note: there are some limits as to how many add ons you can attach to a tower. Also some are only appropriate with a specific tower etc..</p>';
	   			 if (globallogin == 'true') {
				 bottomcaption += '<p>You may wish to download the booklet &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'swing_sets.pdf\')" title="Swing Sets">swing_sets.pdf</a></p>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "Swing Attachments":
                 if (globalswingset == 'true')
                    {
                      topcaption = 'Next choose Swing Attachment(s)';
					  bottomcaption = 'Choose the swing attachments you want for your playsystem, then select Accessories from the drop down menu.';
                    }
                 else
                    {
                      topcaption = 'Next choose Accessories';
					  bottomcaption = 'NB. You have not selected a swing from Add Ons so you may want to skip Swing Attachments and choose your Accessories or add a swing by selecting Add Ons from the drop down menu.';
                    }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }                 break;
            
            case "Accessories":
                 topcaption = 'Next choose your Accessories, then select Safety Surfacing';
				 bottomcaption = '';
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;
            
            case "Safety Surfacing":
                 topcaption = 'Finally choose some Safety Surfacing';
				 bottomcaption = 'Finally choose Safety Surfacing and your playsystem is complete';
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "Other Complete Systems":
                 topcaption = 'Complete Playsystems';
				 bottomcaption = 'These are systems we have designed and put together for your convenience.<br>If you can not see exactly what you want you can create your own system:</p><p> Choose Create a Playsystem from the drop down menu to begin a system from scratch.</p>';
				 bottomcaption += '<p>Or if you prefer you can start with one of these and add extra accessories etc.. </p>';
                 if (globallogin == 'true') {
				 bottomcaption += '<p>First choose a Playsystem from below then add extra features by selecting Create a Playsystem from the left hand dropdown menu and selecting the additons you want.</p>';
				 bottomcaption += '<p>Download the instuctions for &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'creating_a_playsystem.pdf\')" title="Creating a Playsystem">creating_a_playsystem.pdf</a></p>';
				 bottomcaption += '<p>Download the &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'playsystem_pricelist.pdf\')" title="Playsystem Price List">playsystem_pricelist.pdf</a>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "Most Popular Systems":
                 topcaption = 'Our most Popular Playsystems';
				 bottomcaption = 'These are complete systems our customers buy time and time again. You can start with one of these and add extra accessories etc.. </p>';
				 bottomcaption += '<p>First choose a Playsystem then add extra features by selecting Create a Playsystem from the left hand dropdown menu and selecting the additons you want.</p>';
				 if (globallogin == 'true') {
				 bottomcaption += '<p>Download the instuctions for &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'creating_a_playsystem.pdf\')" title="Creating a Playsystem">creating_a_playsystem.pdf</a></p>';
				 bottomcaption += '<p>Download the &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'playsystem_pricelist.pdf\')" title="Playsystem Price List">playsystem_pricelist.pdf</a>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;
               
            case "Incar Go Karts":
				 bottomcaption = 'With this range of Go-Karts comes ten years of experience and development, they incorporate a lot of new ideas and have improved in every detail. ';
                 bottomcaption += 'The new state of the art design frame is developed with an innovative seating position. This means a better centre of gravity, more comfortable seating and better stability when turning.';
				 if (globallogin == 'true') {
                 topcaption = 'in car go karts topcaption';
	   			 bottomcaption += '</p><p>You may wish to download the booklet &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'go_karts.pdf\')" title="Go Karts">go_karts.pdf</a>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "", "?":
                 default:
                 topcaption = 'Please make your selection when prompted - default';
				 bottomcaption = '';
         }

        document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';		
        if (!bottomcaption == ''){
		   var part2= document.getElementById('resultsgohere').innerHTML;
		   var all = '<div class="results" id="results"><p>'+bottomcaption+'</p></div>'+part2;
		   document.getElementById('resultsgohere').innerHTML = all;
           }
		//document.getElementById('resultsgohere').innerHTML += '<div class="results" id="results"><p>'+bottomcaption+'</p></div>';
    }
 
}

function pdfwindow(pdf) {
new_window = window.open ("booklets/"+pdf, "pdfwindow","scrollbars=yes, resizable=yes, width=650");
}

function setOutputfirstmenu(){
    if(httpObject.readyState == 4){
        document.getElementById('menu1').innerHTML = httpObject.responseText;
    }
}

// Implement business logic
   
function doWork(type){ 
    if (type == 'please select'){
        document.getElementById('menu2').innerHTML = ' ';
        //document.getElementById('resultsgohere').innerHTML = ' ';
       }
    globaltype = type;
	httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "echo_html.php?inputText="+globaltype);
        httpObject.send(null); 
        httpObject.onreadystatechange = setOutput;
    }
}


//function doWork2(cat){ 
	//alert (globaltype + 'after this is collection' + globalcollection);
    //log("This is log message sett " + sett);
//    globalcat = cat;
//    httpObject = getHTTPObject();
//    if (httpObject != null) {
//        httpObject.open("GET", "echo_html2.php?inputText="+globaltype+"&cat="+globalcat, true);
//        httpObject.send(null); 
//        httpObject.onreadystatechange = setOutput2;
//    } 
//}


function doWork2(cat, login){ 
	//alert (globaltype + 'after this is collection' + globalcollection);
    //log("This is log message sett " + sett);
    globalcat = cat;
    globallogin = login;
	//alert(login);
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "echo_html2.php?inputText="+globaltype+"&cat="+globalcat, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = setOutput2;
    } 
}


function doWorkFirstMenu(){
   httpObject = getHTTPObject();
   if (httpObject != null) {
        httpObject.open("GET", "echo_firstmenu.php", true);
        httpObject.send(null); 
        httpObject.onreadystatechange = setOutputfirstmenu;
    } 
}


function doWorkSwingSet(){
   httpObjectSwing = getHTTPObject();
   if (httpObjectSwing != null) {
        httpObjectSwing.open("GET", "echo_swingset.php", true);
        httpObjectSwing.send(null); 
        httpObjectSwing.onreadystatechange = setOutputSwingSet;
    } 
}


function setOutputSwingSet(){
 if(httpObjectSwing.readyState == 4){
        globalswingset = httpObjectSwing.responseText;
		//alert(globalswingset);
	}
}

var httpObject = null;


function log(message) {
    if (!log.window_ || log.window_.closed) {
        var win = window.open("", null, "width=400,height=200," +
                              "scrollbars=yes,resizable=yes,status=no," +
                              "location=no,menubar=no,toolbar=no");
        if (!win) return;
        var doc = win.document;
        doc.write("<html><head><title>Debug Log</title></head>" +
                  "<body></body></html>");
        doc.close();
        log.window_ = win;
    }
    var logLine = log.window_.document.createElement("div");
    logLine.appendChild(log.window_.document.createTextNode(message));
    log.window_.document.body.appendChild(logLine);
}
 
function popup(type, cat, title)
{
testwindow= window.open ("detail.php?type="+type+"&cat="+cat+"&title="+title, "mywindow","scrollbars=yes, resizable=yes, width=650");
<!--testwindow.moveTo(250,50);-->
if (window.focus) {testwindow.focus()}
}


function update_cart(){
    if(httpObject.readyState == 4){
        document.getElementById('cart_contents').innerHTML = httpObject.responseText;
        //alert('In update Cart Function');
    }
 
}

function cart_work(){    
    httpObject = getHTTPObject();
    if (httpObject != null) {
        //httpObject.open("GET", "echo_cart.php", true); //Arny
        httpObject.open("GET", "cart/echo_cart.php", true); //Mark
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    } 
// alert('In Cart Work Function');
}

function delete_item (item_id) {
   // alert(item_id);
   // alert('in delete item');
    httpObject = getHTTPObject();
    if (httpObject != null) {
        //httpObject.open("GET", "unset_item.php?item_id="+item_id, true); // Arny
        httpObject.open("GET", "cart/unset_item.php?item_id="+item_id, true); //Mark
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    }
}

function add_item (item_id) {
    //alert(item_id);
    //alert('in add item');
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "cart/add_item.php?item_id="+item_id, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    }
}

 
function update_item (item_id) {
    // alert(item_id);
    // alert('in update item');
    qty = document.getElementById(item_id).value;
    //alert(qty);
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "cart/update_item.php?item_id="+item_id+"&qty="+qty, true); //Mark
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    }
}

//close login window
function hidelogin () {
	hideloginmess   = document.getElementById('viewlogin');
	hideloginmess.className = 'hidelogin';
}

//open login window
function viewlogin () {
	viewloginmess   = document.getElementById('viewlogin');
	viewloginmess.className = 'viewlogin';
}

//close register window
function hideregister () {
	hideregistermess = document.getElementById('viewregister');
	hideregistermess.className = 'hideregister';
}

//open register window
function viewregister () {
	viewregistermess = document.getElementById('viewregister');
	viewregistermess.className = 'viewregister';
}

//close cart window
function hidecart () {
	hidecartmessage = document.getElementById('viewcart');
	hidecartmessage.className = 'hidecart';
}

//open cart window
function viewcart () {
	viewcartmessage = document.getElementById('viewcart');
	viewcartmessage.className = 'viewcart';
}

//cart functs


//Arny - cart

function update_cart(){
    if(httpObject.readyState == 4){
        document.getElementById('cart_contents').innerHTML = httpObject.responseText;
        //alert('In update Cart Function');
    }
 
}

function cart_work(){    
    httpObject = getHTTPObject();
    if (httpObject != null) {
        //httpObject.open("GET", "echo_cart.php", true); //Arny
        httpObject.open("GET", "cart/echo_cart.php", true); //Mark
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    } 
// alert('In Cart Work Function');
}

function delete_item (item_id) {
   // alert(item_id);
   // alert('in delete item');
    httpObject = getHTTPObject();
    if (httpObject != null) {
        //httpObject.open("GET", "unset_item.php?item_id="+item_id, true); // Arny
        httpObject.open("GET", "cart/unset_item.php?item_id="+item_id, true); //Mark
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    }
}

function add_item (item_id) {
    //alert(item_id);
    //alert('in add item');
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "cart/add_item.php?item_id="+item_id, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    }
}


function update_item (item_id) {
    // alert(item_id);
    // alert('in update item');
    qty = document.getElementById(item_id).value;
    //alert(qty);
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "cart/update_item.php?item_id="+item_id+"&qty="+qty, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = update_cart;
    }
}

function update_register(){
    if(httpObject.readyState == 4){
        document.getElementById('viewregister').innerHTML = httpObject.responseText;
        //alert('In update Register Function');
    }
	if (document.getElementById('errors').value == 'false'){
		clearallfields();
	}
}

function register() {
    email = document.getElementById('email').value;
    firstname = document.getElementById('firstname').value;
    lastname = document.getElementById('lastname').value;
    address = document.getElementById('address').value;
    postcode = document.getElementById('postcode').value;
    company = document.getElementById('company').value;
    password = document.getElementById('password').value;
    confirmpassword = document.getElementById('confirmpassword').value;
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "join.php?email="+email+"&firstname="+firstname+"&lastname="+lastname+"&address="+address+"&postcode="+postcode+"&company="+company+"&password="+password+"&confirmpassword="+confirmpassword, true); //Mark
        httpObject.send(null); 
        httpObject.onreadystatechange = update_register;
    }
}

function clearfield(field){
if(field.value == 'Please enter')
  {
    field.value = '';
  }
}

function clearallfields(){
  document.getElementById('email').value = '';
  document.getElementById('firstname').value = '';
  document.getElementById('lastname').value = '';
  document.getElementById('address').value = '';
  document.getElementById('postcode').value = '';
  document.getElementById('company').value = '';
  document.getElementById('password').value = '';
  document.getElementById('confirmpassword').value = '';
}

//check email address
function checkEmailAddress() {
var email = document.getElementById('email').value;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email)) 
   {
	 document.form2.Submit.disabled=true;
	 document.getElementById('loginheader').innerHTML = '<div class="red" id="red"><h3>Enter Valid Email</h3></div>';
	 document.getElementById('email').value = '';
	 document.getElementById('email').focus();
   }
else
   {
     document.form2.Submit.disabled=false;
	 document.getElementById('loginheader').innerHTML = '<h2>Register</h2>';
   }
}

function get_cart_items(items){
  globalitems=items;
  alert(globalitems);
}



function allImagesLoaded(){
   alert('in all imagesloaded function');
   // return variable
   var imagesloaded = 1;
        
   // All images are saved in an array called document.images. Very usefull
   var images = document.images;
   alert(images);
   alert(images.length);

do{

    // Loop through all the images
    for (var i = 0;i<images.length;i++)
        {
          // If the image isnt loaded we set the return varible to 0
          if (images[i].complete == false) {
                 imagesloaded = 0;
                 alert(imagesloaded);
             }
        }
        
    // This will return 0 if one or more images are not loaded and 1 if all images are loaded.
    //return imagesloaded;
    alert(imagesloaded);
    //inspiration = document.getElementById("Inspiration");

    if (imagesloaded == '0'){
	    //alert(inspiration);
	    alert('images not loaded');
	    document.getElementById("Inspiration").setAttribute("href","#");
	    document.getElementById("Inspiration").setAttribute("rel","temp");
	    document.getElementById("ImageInspiration").setAttribute("src","images/loading.gif");
	  }
   else
      {
		//alert(inspiration);
		alert('images loaded = true');
		document.getElementById("ImageInspiration").setAttribute("rel","lyteshow[vacation]");
		document.getElementById("Inspiration").setAttribute("href","slide_show/slides/1.jpg");
		document.getElementById("ImageInspiration").setAttribute("src","slide_show/slides/1.jpg");

	  }
 }
while(imagesloaded == 0); 

 }
 
// custom dynamic menu


function setOutputFirstCustomMenu(){
    if(navigationhttpObject.readyState == 4){
        document.getElementById('menu_contents').innerHTML = navigationhttpObject.responseText;
    }
		if (globaltype !== 'none'){
		showtype(globaltype);
		processtype();
		}
}

//close navigation window
function hidenavigation() {
	navigation   = document.getElementById('viewnavigation');
	navigation.className = 'hidenavigation';
}

//open navigation window
function viewnavigation(type) {
	globaltype = removeSpaces(type);
    //document.getElementById('menu_contents2').innerHTML = '';
var object = document.getElementById('viewnavigation').style;
	object.opacity = (70 / 100);	
	object.KhtmlOpacity = (70 / 100);
	object.MozOpacity = (70 / 100);
	object.filter = "alpha(opacity=" + (70 + 10) + ")";
	navigation = document.getElementById('viewnavigation');
	navigation.className = 'viewnavigation';
	navigationhttpObject = getHTTPObject();
	if (navigationhttpObject != null) {
        navigationhttpObject.open("GET", "echo_FirstCustomMenu.php", true);
        navigationhttpObject.send(null); 
        navigationhttpObject.onreadystatechange = setOutputFirstCustomMenu;
    } 
}

function setOutputSecondCustomMenu(){
    if(processtypehttpObject.readyState == 4){
        //document.getElementById('menu_contents2').innerHTML = processtypehttpObject.responseText;
		document.getElementById('menuheading').innerHTML = '<h2>Please make your selection when prompted</h2>';
		//if (globaltype == 'build your own playsystem'){
     	//topcaption = 'To begin select Towers from the drop down menu';
		//document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
    	//}


            switch (globaltype) {
            case "Create a Playsystem":
                  topcaption = 'To begin select Towers from the drop down menu';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;
            
            case "Pick a Playsystem":
                  topcaption = 'Please select a playsystem';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;

            case "other":
                  topcaption = 'Please select from drop down menu';
		          document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';
                  break;
                        
            case "", "?":
                 default:
                 topcaption = 'Please make your selection when prompted - default';
         }
    }
}
 
function setOutputOnPage(){
    if(processcathttpObject.readyState == 4){
        document.getElementById('resultsgohere').innerHTML = processcathttpObject.responseText;

        switch (globalcat) {
            case "Towers":
                 topcaption = 'First choose your Tower(s)';
				 bottomcaption = '<p>Choose the tower(s) you want for your playsystem from this page, then select Add Ons from the drop down menu above.</p>';
				if (globallogin == 'true') {
				 bottomcaption += '<p>Download the instuctions for &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'creating_a_playsystem.pdf\')" title="Creating a Playsystem">creating_a_playsystem.pdf</a></p>';
				 bottomcaption += '<p>Download the &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'playsystem_pricelist.pdf\')" title="Playsystem Price List">playsystem_pricelist.pdf</a></p>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;
                  
            case "Add Ons":
                 topcaption = 'Next choose Add On(s)';
				 bottomcaption = '<p>Choose the add ons you want for your playsystem. Note: there are some limits as to how many add ons you can attach to a tower. Also some are only appropriate with a specific tower etc..</p>';
	   			 if (globallogin == 'true') {
				 bottomcaption += '<p>You may wish to download the booklet &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'swing_sets.pdf\')" title="Swing Sets">swing_sets.pdf</a></p>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "Swing Attachments":
                 if (globalswingset == 'true')
                    {
                      topcaption = 'Next choose Swing Attachment(s)';
					  bottomcaption = 'Choose the swing attachments you want for your playsystem, then select Accessories from the drop down menu.';
                    }
                 else
                    {
                      topcaption = 'Next choose Accessories';
					  bottomcaption = 'NB. You have not selected a swing from Add Ons so you may want to skip Swing Attachments and choose your Accessories or add a swing by selecting Add Ons from the drop down menu.';
                    }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }                 break;
            
            case "Accessories":
                 topcaption = 'Next choose your Accessories, then select Safety Surfacing';
				 bottomcaption = '';
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;
            
            case "Safety Surfacing":
                 topcaption = 'Finally choose some Safety Surfacing';
				 bottomcaption = 'Finally choose Safety Surfacing and your playsystem is complete';
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "Other Complete Systems":
                 topcaption = 'Complete Playsystems';
				 bottomcaption = 'These are systems we have designed and put together for your convenience.<br>If you can not see exactly what you want you can create your own system:</p><p> Choose Create a Playsystem from the drop down menu to begin a system from scratch.</p>';
				 bottomcaption += '<p>Or if you prefer you can start with one of these and add extra accessories etc.. </p>';
                 if (globallogin == 'true') {
				 bottomcaption += '<p>First choose a Playsystem from below then add extra features by selecting Create a Playsystem from the left hand dropdown menu and selecting the additons you want.</p>';
				 bottomcaption += '<p>Download the instuctions for &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'creating_a_playsystem.pdf\')" title="Creating a Playsystem">creating_a_playsystem.pdf</a></p>';
				 bottomcaption += '<p>Download the &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'playsystem_pricelist.pdf\')" title="Playsystem Price List">playsystem_pricelist.pdf</a>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "Most Popular Systems":
                 topcaption = 'Our most Popular Playsystems';
				 bottomcaption = 'These are complete systems our customers buy time and time again. You can start with one of these and add extra accessories etc.. </p>';
				 bottomcaption += '<p>First choose a Playsystem then add extra features by selecting Create a Playsystem from the left hand dropdown menu and selecting the additons you want.</p>';
				 if (globallogin == 'true') {
				 bottomcaption += '<p>Download the instuctions for &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'creating_a_playsystem.pdf\')" title="Creating a Playsystem">creating_a_playsystem.pdf</a></p>';
				 bottomcaption += '<p>Download the &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'playsystem_pricelist.pdf\')" title="Playsystem Price List">playsystem_pricelist.pdf</a>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;
               
            case "Incar Go Karts":
				 bottomcaption = 'With this range of Go-Karts comes ten years of experience and development, they incorporate a lot of new ideas and have improved in every detail. ';
                 bottomcaption += 'The new state of the art design frame is developed with an innovative seating position. This means a better centre of gravity, more comfortable seating and better stability when turning.';
				 if (globallogin == 'true') {
                 topcaption = 'in car go karts topcaption';
	   			 bottomcaption += '</p><p>You may wish to download the booklet &#8212; &nbsp;<a href="#" onClick="pdfwindow(\'go_karts.pdf\')" title="Go Karts">go_karts.pdf</a>';
				 }
                 if (globallogin == 'false') {
				 bottomcaption += '<p><b><em>You have not logged in. Registering only takes a few seconds and once registered you can login to view prices, download product brochures and add your selections.</em></b></p>';
				 }
				 break;

            case "", "?":
                 default:
                 topcaption = 'Please make your selection when prompted - default';
				 bottomcaption = '';
         }

        document.getElementById('menuheading').innerHTML = '<h2>'+topcaption+'</h2>';		
        if (!bottomcaption == ''){
		   var part2= document.getElementById('resultsgohere').innerHTML;
		   var all = '<div class="results" id="results"><p>'+bottomcaption+'</p></div>'+part2;
		   document.getElementById('resultsgohere').innerHTML = all;
           }
		//document.getElementById('resultsgohere').innerHTML += '<div class="results" id="results"><p>'+bottomcaption+'</p></div>';
    }
 
}

function processtype(){ 
    //globaltype = type;
	//alert('in process type');
	processtypehttpObject = getHTTPObject();
    if (processtypehttpObject != null) {
        //processtypehttpObject.open("GET", "echo_html.php?inputText="+globaltype);
        processtypehttpObject.open("GET", "echo_processtype.php?inputText="+globaltype);
        processtypehttpObject.send(null); 
        processtypehttpObject.onreadystatechange = setOutputSecondCustomMenu;
    }
}


function processcat(cat, login){ 
	//alert (globaltype + 'after this is collection' + globalcollection);
    //log("This is log message sett " + sett);
    globalcat = cat;
    globallogin = login;
	//alert(login);
    processcathttpObject = getHTTPObject();
    if (processcathttpObject != null) {
        processcathttpObject.open("GET", "echo_processcat.php?inputText="+globaltype+"&cat="+globalcat, true);
        processcathttpObject.send(null); 
        processcathttpObject.onreadystatechange = setOutputOnPage;
    } 
}

function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

function showtype(globaltype){
	//alert(globaltype);
	//var tag = 'p';
	//var tag = globaltype;
	//var doc = document.getElementsByName(globaltype); // by name
	//var doc = document.getElementsByTagName("special");
	//var doc = document.getElementsByTagName("CreateaPlaysystem");
	//var doc = document.getElementsByTagName(tag)
	//id = document.getElementById(globaltype);
	//var doc = document.getElementById("CreateaPlaysystem");
	//var doc = document.getElementById(globaltype);
	//doc.className = "display";
	//alert(id.length);
		//for (var i = 0; i < doc.length; i++){
		var main = document.getElementById(globaltype);
		//var main = document.getElementById('CreateaPlaysystem0');
  		var collection = main.getElementsByTagName('div');
 	 	var output1 = collection.length;
		//alert(collection.length);
  	 	//var output2 = collection[0].firstChild.nodeValue;
		for (var i = 0; i < collection.length; i++){
	   //Do Work on doc[i], this sets the border of the Div black
		   //doc[i].style.display = "list-item";
		  // doc[i].style.marginLeft = "20px";
		  //var newglobaltype=globaltype+i;
		  //alert(newglobaltype);
		  if ((newglobaltype !== null) || (i == 0)) {
		  var newglobaltype=globaltype+i;
		  if (newglobaltype == null){
			  break;
		  }
		  var doc = document.getElementById(newglobaltype);
		  doc.className = "display";
		  }
		}
}

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="The code and images on this site are under copyright protection.";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

// Price functions
function is_int(value){
  //if(((parseFloat(value) == parseInt(value)) && !isNaN(parseInt(value))){
  if(parseFloat(value) == parseInt(value)){
      return true;
    } 
  else 
    {
      return false;
    }
}

function customPrice(){
 var total=0;
 var num=0;
 var cost=0;
 //var price = document.radiobuttonsform.price.value;
 for (i=0; i<document.radiobuttonsform.tower.length; i++)
     {
        num = parseInt(document.radiobuttonsform.tower[i].value);
        cost = parseInt(document.radiobuttonsform.tower[i].id);
         if((num != "" ) && !isNaN(num))
           { 
             total += num*cost; 
           }
      }
document.radiobuttonsform.price.value=total;
}

function customPrice2(){
//alert('In custom price function');
 var total=0;
 var num=0;
 var cost=0;
 //var price = document.radiobuttonsform.price.value;
 for (i=0; i<document.radiobuttonsform.numof.length; i++)
     {
        //alert('IN for Loop');
        num = parseInt(document.radiobuttonsform.numof[i].value);
        var checkboxValue = document.radiobuttonsform.numof[i].name;
        var splitResult = checkboxValue.split(":");
        cost = parseInt(splitResult[1]*1);
         if((num != "" ) && !isNaN(num))
           { 
             total += num*cost; 
           }
      }
document.radiobuttonsform.price.value=total;
document.getElementById('totalprice').innerHTML = '<p>Total Price : &pound;'+total+'</p>';
}

function customPrice3(orgprice){
//alert('In custom price function');
 var total=0;
 var num=0;
 var cost=0;
 //var price = parseInt(document.checkboxform.price.value);
 for (i=0; i<document.checkboxform.numof.length; i++)
     {
        //alert('IN for Loop');
        num = parseInt(document.checkboxform.numof[i].value);
        
        var checkboxValue = document.checkboxform.numof[i].name;
        var splitResult = checkboxValue.split(":");
        //cost = parseInt(document.checkboxform.numof[i].id);
        cost = parseInt(splitResult[1]*1);
         if((num != "" ) && !isNaN(num))
           { 
             total += num*cost; 
           }
      }
total += orgprice;
document.checkboxform.price.value=total;
document.getElementById('totalprice').innerHTML = '<p>Total Price : &pound;'+total+'</p>';
}


function addprice(){
var price = document.checkboxform.price.value;
var totalprice = 0;
for (i=0; i<document.checkboxform.checkgroup.length; i++){
     if (document.checkboxform.checkgroup[i].checked==true){
         checkboxValue = document.checkboxform.checkgroup[i].value;
         //alert('add : '+checkboxValue);
         addtotal
         //var SplitResult = checkboxValue.split(":");
         //alert(SplitResult[1]);
         //totalprice = parseInt(totalprice) + parseInt(SplitResult[1]*1);
         //alert('totalprice : ' + totalprice);
         }
     else
        {
          checkboxValue = document.checkboxform.checkgroup[i].value;
          //alert('subtract : '+checkboxValue)
          subtotal
          //totalprice = totalprice - parseInt(SplitResult[1]*1);
        }  
    }
totalprice = totalprice + parseInt(price);
//alert(totalprice);
document.checkboxform.price.value=totalprice;
}



function addprice2(orgprice){
//alert('orgprice : '+orgprice);
var total = 0;
var price = document.checkboxform.price.value;
  for (i=0; i<document.checkboxform.checkgroup.length; i++){
      
      if(document.checkboxform.checkgroup[i].checked==true) { 
          var checkboxValue = document.checkboxform.checkgroup[i].name;
          var splitResult = checkboxValue.split(":");
          //total += parseInt(document.checkboxform.checkgroup[i].value);
          total += parseInt(splitResult[1]*1);
          //alert(total);
        }
      }
document.getElementById('totalprice').innerHTML = '<p>Total Price : &pound;'+parseInt(orgprice+total)+'</p>';
document.checkboxform.price.value=orgprice+total;
}


function calculateprice() {
if (document.radiobuttonsform.tower1) 
   {
     chosen1 = "0:0";
     len1 = document.radiobuttonsform.tower1.length;

     for (i = 0; i <len1; i++) 
         {
           if (document.radiobuttonsform.tower1[i].checked) 
              {
                 chosen1 = document.radiobuttonsform.tower1[i].value;
              }  
         }
  }
else
  {
    chosen1 = "0:0";
  }

if (document.radiobuttonsform.tower2) 
   {
     chosen2 = "0:0";
     len2 = document.radiobuttonsform.tower2.length;

     for (j = 0; j <len2; j++) 
         {
            if (document.radiobuttonsform.tower2[j].checked) 
               {
                  chosen2 = document.radiobuttonsform.tower2[j].value;
                }
         }
   }
else
  {
    chosen2 = "0:0";
  }

if (document.radiobuttonsform.swing) 
   {
      chosen3 = "0:0";
      len3 = document.radiobuttonsform.swing.length;

      for (k = 0; k <len3; k++) 
          {
             if (document.radiobuttonsform.swing[k].checked) 
                {
                   chosen3 = document.radiobuttonsform.swing[k].value;
                }
          }
   }
else
  {
    chosen3 = "0:0";
  }


if (document.radiobuttonsform.bridge) 
   {
	  chosen4 = "0:0"; 
	  if (document.radiobuttonsform.bridge.checked) 
		 {
		    chosen4 = document.radiobuttonsform.bridge.value;
		 }
   }
else
  {
    chosen4 = "0:0";
  }

if (document.radiobuttonsform.monkeycombo) 
   {
	  chosen5 = "0:0";
	  if (document.radiobuttonsform.monkeycombo.checked) 
	     {
	        chosen5 = document.radiobuttonsform.monkeycombo.value;
	     }
   }
else
  {
    chosen5 = "0:0";
  }

var mySplitResult1 = chosen1.split(":");
var mySplitResult2 = chosen2.split(":");
var mySplitResult3 = chosen3.split(":");
var mySplitResult4 = chosen4.split(":");
var mySplitResult5 = chosen5.split(":");

//alert('Price : '+parseInt(mySplitResult1[1]));

var totalprice = (mySplitResult1[1]*1) + (mySplitResult2[1]*1) + (mySplitResult3[1]*1) + (mySplitResult4[1]*1) + (mySplitResult5[1]*1);
//alert('Total Price : '+totalprice);

//document.getElementById('price').value=totalprice;
document.radiobuttonsform.price.value=totalprice;
document.getElementById('totalprice').innerHTML = '<p>Total Price : &pound;'+totalprice+'</p>';
}

function sendpassword(){
if(document.getElementById('myusername').value)	
location.href="resendpassword.php?email="+document.getElementById('myusername').value;
else
alert('Please enter your email address');
}

document.oncontextmenu=new Function("alert(message);return false")

function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}

function follow(evt) {if (document.getElementById) {var obj = document.getElementById(divName).style; //obj.visibility = 'visible';
obj.left = (parseInt(mouseX(evt))+offX) + 'px';
obj.top = (parseInt(mouseY(evt))+offY) + 'px';}}
document.onmousemove = follow;

function show(id) {
	element = document.getElementById(id).style;
	element.display = "block";
	element.visibility = "visible";
}

function hide(id) {
	element = document.getElementById(id).style;
	element.display = "none";
}


function doTooltip(event, tid){
	image = document.getElementById('tooltipimage');
	image.innerHTML = '<img src="'+messages[tid][0]+'" />';
	element = document.getElementById('tooltiptitle');
	element.innerHTML = messages[tid][1];
	element2 = document.getElementById('tooltipdescription');
	element2.innerHTML = messages[tid][2];
	show('tooltip');
}

function hideTip(){
	hide('tooltip');
}