// JavaScript Document

	// Main function which changes color underneathe menu
	function cOnMOMC(id, mode)
	{
		var menuNo = 8; // Static element which defines how many menus we have

		// mode=1 - activate underline
		// mode=2 - deactivate underline

		var elem = null;
		var currPageNo = document.getElementById('pageNo').value;
		
		for (i=1; i<=menuNo; i++)
		{		
			var myColor='#FA1344'; // standard red
			if (i != currPageNo)
			{
				if (i == id)
				{
					myColor='#F19AAD'; // new underline
//					elem = document.getElementById('m_'+i+'_3'); elem.style.backgroundColor=myColor;
				}
				else
				{
					myColor='#000000'; // black
//					elem = document.getElementById('m_'+i+'_3'); elem.style.backgroundColor=myColor;
				}
				
				if (mode == 2) myColor = '#000000'; // black color
				elem = document.getElementById('m_'+i+'_3'); elem.style.backgroundColor=myColor;
				elem = document.getElementById('m_'+i+'_4'); elem.style.backgroundColor=myColor;
			}
		}
	}

	// Function which changes color of menu of the current page
	function changeMC()
	{
		var menuNo = 8; // Static element which defines how many menus we have

		// Get ID of the current page
		id = document.getElementById('pageNo').value;
		var elem = null;
		
		for (i=1; i<=menuNo; i++)
		{
			var myColor = '#FFFFFF'; // white
			var mySecondRowColor= '#000000'; // black
			if (id == i) {myColor = '#FA1344'; mySecondRowColor = '#FA1344'} // standard red 
			elem = document.getElementById('m_'+i+'_1'); elem.style.backgroundColor=myColor;
			elem = document.getElementById('m_'+i+'_2'); elem.style.backgroundColor=myColor;
			elem = document.getElementById('m_'+i+'_3'); elem.style.backgroundColor=mySecondRowColor;
			elem = document.getElementById('m_'+i+'_4'); elem.style.backgroundColor=mySecondRowColor;
			
			
			// Also change picture
			elem = document.getElementById('m_'+i+'_2');

			// Form ALT part depending on the menu
			var myALT = "Sliding Storage London, UK. ";
			var myA = "";
			if (i == 1) {myA="index.htm"; myALT += "Wide range of hinged wardrobes, sliding wardrobes and fitted wardrobes expands storage space in your bedroom. Sliding doors with mirror, steel and wood finishing. Contemporary design, elegant home.";}
			if (i == 2) {myA="aboutus.htm"; myALT += "Contemporary storage design, sliding wardrobes, hinged wardrobes, free quote, free visit";}
			if (i == 3) {myA="features.htm"; myALT += "Sliding wardrobes, fitted wardrobes, optional mirror sliding doors, 'L' shaped wardrobes, optional open-end shelf units, customize sliding wardrobes, various door finishes with lights, belt racks, tie racks";}
			if (i == 4) {myA="sliding_wardrobes.htm"; myALT += "Sliding wardrobes, Comprehensive range of finishes for sliding doors, from colored glass, mirrors and wood, on steel or aluminum frames. Doors can be split into any of these finishes.";}
			if (i == 5) {myA="hinged_wardrobes.htm"; myALT += "Hinged Wardrobes, traditional style, contemporary design, various door finishes";}
			if (i == 6) {myA="gallery.htm"; myALT += "Selection of accessories to for your wardrobe. Numerous wardrobe options available. Door finishes with glass, steel, aluminum or mirror";}
			if (i == 7) {myA="range.htm"; myALT += "Selection of door styles, doors build of mirror, color glass or wood, with frames and decorative stripes. Ultra quiet door wheels.";}
			if (i == 8) {myA="contactus.htm"; myALT += "Contact us via phone or via call back form. Free visit and free quote. Have your sliding storage suit your needs.";}

			if (i == id) 
			{
				elem.innerHTML='<a href="' + myA + '"><img alt="' + myALT + '" src="images/upper_right_corner-red.gif"></a>'
			}
			else
			{
				elem.innerHTML='<a href="' + myA + '"><img alt="' + myALT + '" src="images/upper_right_corner.gif"></a>'
			}
		}
	}

	function goContact()
	{
		var f = document.forms['Contact'];
		
		if (document.all("realname").value == '')
		{
			alert ('Please, enter your name before posting.');
			return;
		}
		else
		{
			if (document.all("email").value == '' && document.all("phone").value == '')
			{
				alert ('Email or phone must be specified before posting!');
				return;
			}
			
			var x = document.all("email").value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!filter.test(x)) 
			{
				alert('Incorrect email address. Please, try again');
				return;
			}
			
			// Now posting
			f.target = '';
			f.action = '/cgi-bin/NMSFormMail.pl';
			f.submit();
		}
		
	}
	
	// PostBack query fetch
	function qs() 
	{
		var query = window.location.search.substring(1);
		var parms = query.split('&');
		for (var i=0; i<parms.length; i++) 
		{
			var pos = parms[i].indexOf('=');
			if (pos > 0) 
			{
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				if (key == 'postback')
				{
					if (val == '1') 
					{
						alert ('Thank you for your enquiry. Your form has been submitted successfully.');
						window.location = 'http://www.slidingstorage.co.uk/contactus.htm';
						return;
					}
					else
					{
						return;	
					}
				}
			}
		}
	}	


	