
var s1 =  new Array('mhs1', 'mps1','mhs2','mhs3' );
var s2 =  new Array('mhs2', 'mps2', 'mhs1','mhs3');
var s3 =  new Array('mhs3', 'mps3', 'mhs1', 'mhs2');
var s4 =  new Array('submit');
var pc = new Array();
var toogle = 0;

var show1 = 0;
var show2 = 0;
var show3 = 0;

function showHide(arr, display) {
	for (x = 0; x < 4; x++) {
	document.getElementById(arr[x]).style.display = display;
	}
}

function showHideEle(arr, display, x) {
	document.getElementById(arr[x]).style.display = display;
}

function start() {
	if (document.getElementById('homesearch').style.display == 'none'){
	document.getElementById('homesearch').style.display = 'block'
	showHide(s1, 'block');
	showHide(s2, 'none');
	showHide(s3, 'none');
	showHideEle(s1, 'block', 0);
	showHideEle(s2, 'block', 0);
	showHideEle(s3, 'block', 0);
	}
}

function start2() {
	showHide(s1, 'block');
}

function toggle_vis1bak() {
	showHide(s1, 'block');
	showHide(s2, 'none');
	showHide(s3, 'none');
	showHideEle(s1, 'block', 0);
	showHideEle(s2, 'block', 0);
	showHideEle(s3, 'block', 0);
	showSubmit(); 
}
function toggle_vis1( str ) {
	showHide(s1, 'none');
	showHide(s3, 'none');
	showHide(s2, 'block');
	showHideEle(s1, 'block', 0)

	if (str == 0) {
		document.getElementById(s1[0]).innerHTML = '1. <a href="#" onclick="toggle_vis1bak();return false;" class="orange">Desktops</a>';
	}
	if (str == 1) {
		document.getElementById(s1[0]).innerHTML = '1. <a href="#" onclick="toggle_vis1bak();return false;" class="orange">Laptops</a>';
	}
	if (str == 2) {
		document.getElementById(s1[0]).innerHTML = '1. <a href="#" onclick="toggle_vis1bak();return false;" class="orange">Desktop + Laptop</a>';
	}
	show1 = 1;
	showSubmit();
		
}

function toggle_vis2price() {
	showHide(s1, 'none');
	showHide(s2, 'none');
	showHide(s3, 'block');
}

function toggle_vis2bakprice() {
	showHide(s1, 'none');
	showHide(s3, 'none');
	showHide(s2, 'block');
	showSubmit();
		
}

function toggle_vis2setprice( str ) {
	showHide(s1, 'none');
	showHide(s2, 'none');
	showHide(s3, 'block');
	var pricename ='';
	if (document.search.price.selectedIndex != 0) {
		if ( str == 1) {
			pricename = '&pound;200-&pound;500';
		}
		if ( str == 2) {
			pricename = '&pound;501-&pound;800';
		}
		if ( str == 3) {
			pricename = '&pound;801-&pound;1500';
		}
		if ( str == 4) {
			pricename = '&pound;1500+';
		}
		if ( str == 5) {
			pricename = 'Any Price';
		}
	}
	else {
		showHide(s1, 'none');
		showHide(s3, 'none');
		showHide(s2, 'block');
	}
	document.getElementById(s2[0]).innerHTML = '2. <a href="#" onclick="toggle_vis2bakprice();return false;" class="orange">'+pricename+'</a>';
	show2 = 1;
	showSubmit();
		
}

function toggle_vis2bakusuage() {
	showHide(s1, 'none');
	showHide(s2, 'none');
	showHide(s3, 'block');
}

function toggle_vis2setusuage( str ) {
	showHide(s1, 'none');
	showHide(s2, 'none');
	showHide(s3, 'block');
	var pricename ='';
	if (document.search.usuage.selectedIndex != 0) {
		if ( str == 1) {
			pricename = 'Office, Internet &amp; E-mail';
		}
		if ( str == 3) {
			pricename = 'Media';
		}
		if ( str == 4) {
			pricename = 'Media Edit';
		}
		if ( str == 5) {
			pricename = 'Gaming &amp; Video Edit';
		}
		if ( str == 6) {
			pricename = 'Any Usage';
		}
		document.getElementById(s3[1]).style.display = 'none';
	}
	else {
		showHide(s1, 'none');
		showHide(s2, 'none');
		showHide(s3, 'block');
	}
	document.getElementById(s3[0]).innerHTML = '3. <a href="#" onclick="toggle_vis2bakusuage();return false;" class="orange">'+pricename+'</a>';
	show3 = 1;
	showSubmit();
	
}

function showSubmit() {
	if (show1 == 1 && show2 == 1 && show3 == 1)
		document.getElementById(s4[0]).style.display = 'block';
}
function toggleText( id ) {
	var link = 'more_'+id;
	var show = 'extra_'+id;
	if (pc[id] != 1) {
		pc[id] = 1; 
		document.getElementById( show ).style.display = 'block';
		document.getElementById( link ).innerHTML = '<u>less...</u>';
	}
	else {
		pc[id] = 0; 
		document.getElementById( show ).style.display = 'none';	
		document.getElementById( link ).innerHTML = '<u>read more...</u>';
	}
}

function makeWin2(url, p_Width, p_Height) {
	params  = GetWindowOpenParams(92, 0, p_Width, p_Height);
	ProcessOpenWindow(url, "Sitelet", params, false);
}
function makeWin3(url, p_Width, p_Height) {
	params  = GetWindowOpenParams(192, 100, p_Width, p_Height);
	ProcessOpenWindow(url, "Sitelet", params, false);
}
function GetWindowOpenParams(top, left, width, height)
{
	params = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,";
	params += "top=" + top + ",";
	params += "left=" + left + ",";
	if (width) {
	 	params += "width=" + width+ ",";
		params += "height=" + height;
	}
	else {
		params += "width=590,height=350";
	}
	return params;
}

function ProcessOpenWindow(url, windowName, params, noCaching)
{
	agent = navigator.userAgent;
	try{
	// close the window to vary the window size
	if (typeof(win) == "object" && !win.closed){win.close();}
	}catch(e){}
	win = OpenWindow(url, windowName, params, noCaching);
	if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) 
	win = OpenWindow(url, windowName, params, noCaching);
	try{
		if (!win.opener) {
			win.opener = window;
		}
	}catch(e){}
  	// bring the window to the front
	try{
		win.focus();	
	}catch(e){}
}

function OpenWindow(url, windowName, params, noCaching)
{
	if (noCaching == true)
		return window.open(url + '&nc=true', windowName , params);
	else
		return window.open(url, windowName , params);
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function checkRadio(ele, value) {
	setCheckedValue(document.forms['search'].elements[ele], value);
	
}