function shop_on()
{
	var img = document.getElementById("shop_cart");
	document.shop_cart.src = "Images/Shopping_Cart2.gif";
}
function shop_off()
{
	var img = document.getElementById("shop_cart");
	document.shop_cart.src = "Images/Shopping_Cart.gif";
}
var last_nav = '';
var last_subnav = '';
var subnav_flag = 0;
function hover(image, navstate, navid, linkid, subnavid, sublinkid) 
{
	// The main navigation tab images are changed, the condition ensures that the code is executed only if an argument is
	// passed so that an error is avoided.
	if (image != '' && linkid != '')
	{
		document.getElementById(linkid).style.backgroundImage = "url("+image+")";
	}
	// The If Statement ensures that an error is avoided if an argument is not passed
	if (navstate != '' && navid != '') 
	{
		// On MouseOver
		if (navstate == 'on') 
		{
			// Close the last nav
			if (last_nav != '' && last_nav != navid)
			{
				document.getElementById(last_nav).style.display = 'none';
			}
			// Find the Y & X positions of the tab to find the placement for the dropdown			
			var pos_y = findPosY(document.getElementById(linkid));
			var pos_x = findPosX(document.getElementById(linkid));
			// Add the height of the tab div so the nav displays at the bottom of the tab
			// alert(pos_y + ' ' + pos_x);
			pos_y += document.getElementById(linkid).clientHeight;
			// IE has a bug where pos_y is off by 10 pixels, so add 10 pixels to pos_y		
			if (navigator.appName == 'Microsoft Internet Explorer')
			{
				if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
					var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
					if (ieversion < 8)
					{
						pos_y += 10;
					}
				}
			}
			// Position the dropdown nav
			pos_y += 'px';
			pos_x += 'px';
			document.getElementById(navid).style.left = pos_x;
			document.getElementById(navid).style.top = pos_y;
			// Show the dropdown nav 
			document.getElementById(navid).style.display = 'block';
			// Change the colour of the tab link text
			document.getElementById(linkid).style.color = '#FF8E38';
			// Store the currently open nav in memory so that when a new nav needs to be open, the last one is not displayed
			last_nav = navid;
			// Close the last subnav 
			if (last_subnav != '' && last_subnav != subnavid && subnav_flag == 0)
			{
				document.getElementById(last_subnav).style.display = 'none';
			}
			// The If statement avoids an error when only the dropdown or the tab are hovered upon i.e. subnav is ''
			if (subnavid != '' & sublinkid != '')
			{
				// Remove the right border
				document.getElementById(sublinkid).style.borderRight = '0';
				// Find the positions of the subnav item
				var sub_pos_y = findPosY(document.getElementById(sublinkid));
				var sub_pos_x = findPosX(document.getElementById(sublinkid));
				// Add the width of the subnav item so that it is displayed to the right of the subnav item
				sub_pos_x += document.getElementById(sublinkid).clientWidth;
				// Position the subnav 
				document.getElementById(subnavid).style.left = sub_pos_x;
				document.getElementById(subnavid).style.top = sub_pos_y;
				// Show the subnav 
				document.getElementById(subnavid).style.display = 'block';
				subnav_flag = 1;
			}
			// Store the currently open subnav in memory so that when a new subnav opens, the last one can be closed
			last_subnav = subnavid;
		}
		// On MouseOut
		else if (navstate == 'off')
		{
			// Change the colour of the tab link text
			document.getElementById(linkid).style.color = '#FFFFFF';
			// Hide the dropdown nav
			document.getElementById(navid).style.display = 'none';
			if (subnavid != '' && sublinkid != '')
			{
				document.getElementById(sublinkid).style.borderRight = '1px solid #4e5a68';
				document.getElementById(subnavid).style.display = 'none';
				subnav_flag = 0;
			}
		}
	}
}
function print_page(divName)
{
	var divHeight = document.getElementById(divName).clientHeight + 60;
	var divWidth = document.getElementById(divName).clientWidth + 25; 
	if (divHeight > 850)
		{
			var scrollbars = 'yes';
			divHeight = 850;
		}
	else if (divHeight < 610)
		{
			var scrollbars = 'no';
			divHeight = 610;
		}
	else
		{
			var scrollbars = 'no';
		}
	var print_setting = 'toolbar=no,menubar=no,status=no,scrollbars=yes,height='+divHeight+',width='+divWidth;
	var content_value = document.getElementById(divName).innerHTML;
	var doc_href = window.location;
	var doc_title = document.title;
	var docprint = window.open(doc_href,'',print_setting);
	var pre_content_text = '<html><head><title>'+doc_title+'</title><link rel="stylesheet" href="css/rp_styles.css">'
	//pre_content_text += '</link></head><body style="margin-left:10px; background-color:#FFFFFF;" onLoad="self.print()">';
	pre_content_text += '</link>';
	pre_content_text += '<style type="text/css">';
	pre_content_text += 'body {text-align: left; color: #364049; font-size: 13px;}';
	pre_content_text += '.AccordionPanelTab {font-weight: bold; color: #364049; font-family: Tahoma; font-size: 13px;}';
	pre_content_text += '.AccordionPanelContent {display: block !important; height: auto !important; color: #364049; font-family: Tahoma; font-size: 13px; margin-bottom: 1em;}';
	pre_content_text += '</style>';
	pre_content_text += '</head><body style="margin-left:10px; margin-right:10px; background-color:#FFFFFF;" onLoad="self.print()"><img src="Images/rp_satcom_logo.jpg" alt="Roadpost Satcom" border="0" style="margin-bottom:12px; margin-top:1px; text-align:right; margin-left:5px;" />';
	if (document.getElementById('tab_div1') != null)
	{
		content_value = content_value.substring(0,content_value.indexOf('tab_div1'));
		var small_div = content_value.lastIndexOf('<div');   
		var big_div = content_value.lastIndexOf('<DIV ');   
		if (content_value.lastIndexOf('div') != -1)    //Code before change: if (content_value.lastIndexOf('<div') != -1 && small_div > big_div)
		{
			content_value = content_value.substring(0,small_div);
		}
		else 
		{
			content_value = content_value.substring(0,big_div);
		}
	}
	
	for (i=1;document.getElementById('tab_div'+i)!=null;i++)
	{
		for (j=1;document.getElementById('tab'+j)!=null;j++)
		{
			content_value += '<h2 class="stat_subhead" style="margin-top:0px; margin-bottom:0px;">'+document.getElementById('tab'+j+'mid').innerHTML+'</h2><br />';  //<p> and <br> for FF browser look
			content_value += document.getElementById('tabcontent'+j).innerHTML + '<br />';
		}
	}
	
	docprint.document.open(); 
	docprint.document.write(pre_content_text);  
	docprint.document.write(content_value);
	docprint.document.write('</div></TD></TBODY></TR></TABLE>'); 
	docprint.document.write('</body></html>'); 
	docprint.document.close(); 
	//docprint.focus();
}
function tab_switch(divName, numDivs)
{
	var divToShow = parseInt(divName.substring(divName.length - 1));
	for (i=1;i<=numDivs;i++)
	{
		var tabName = 'tab'+i;
		var tabLink = 'tab'+i+'_link';
		var tabLeft = 'tab'+i+'left';
		var tabRight = 'tab'+i+'right';
		var tabMid = 'tab'+i+'mid';
		if (i==divToShow)
		{
			document.getElementById(divName).style.display = 'block';
			document.getElementById(tabName).setAttribute("class", "tab_on");
			document.getElementById(tabName).setAttribute("className", "tab_on");
			document.getElementById(tabLink).setAttribute("class", "tab_link_on");
			document.getElementById(tabLink).setAttribute("className", "tab_link_on");		
			document.getElementById(tabLeft).setAttribute("class", "tab_on_left");			
			document.getElementById(tabLeft).setAttribute("className", "tab_on_left");
			document.getElementById(tabRight).setAttribute("class", "tab_on_right");
			document.getElementById(tabRight).setAttribute("className", "tab_on_right");
			document.getElementById(tabMid).setAttribute("class", "tab_on_mid");
			document.getElementById(tabMid).setAttribute("className", "tab_on_mid");
		}
		else 
		{
			var divOther = 'tabcontent'+i;
			document.getElementById(divOther).style.display = 'none';
			document.getElementById(tabName).setAttribute("class", "tab_off");
			document.getElementById(tabName).setAttribute("className", "tab_off");
			document.getElementById(tabLink).setAttribute("class", "tab_link_off");
			document.getElementById(tabLink).setAttribute("className", "tab_link_off");			
			document.getElementById(tabLeft).setAttribute("class", "tab_off_left");		
			document.getElementById(tabLeft).setAttribute("className", "tab_off_left");
			document.getElementById(tabRight).setAttribute("class", "tab_off_right");
			document.getElementById(tabRight).setAttribute("className", "tab_off_right");
			document.getElementById(tabMid).setAttribute("class", "tab_off_mid");
			document.getElementById(tabMid).setAttribute("className", "tab_off_mid");
		}
	}
}
function adjustwidth()
{
	if (document.getElementById('WcBasket1_dgBasketItems__ctl2_lblPrice') != null)
	{
		var	parElement = document.getElementById('WcBasket1_dgBasketItems__ctl2_lblPrice').parentNode;
		var parwidth = parElement.clientWidth;
		document.getElementById('td1').width = parwidth;
		document.getElementById('td2').width = parwidth;	
	}
	else 
	{
		document.getElementById('td1').width = '93px';
		document.getElementById('td2').width = '93px';
	}
}
function findPosX(obj)
{
	var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}
  function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}
var lastQues = '';
var lastAns = '';
function toggle_answer(divQues,divAns)
{
	if (lastAns != divAns)
	{
		document.getElementById(divAns).style.display = 'block';
		
		//slide_timer(divAns + '-' + divAns.substring(divAns.length - 1, divAns.length),document.getElementById(divAns + '-' + divAns.substring(divAns.length - 1, divAns.length)).clientHeight);
		document.getElementById(divQues).style.color = '#ff8d3a';
		if (lastAns != '')
		{
			document.getElementById(lastAns).style.display = 'none';
			document.getElementById(lastQues).style.color = '#587290';
		}
		lastAns = divAns;
		lastQues = divQues;
	}
	else if (lastAns == divAns)
	{
		document.getElementById(lastAns).style.display = 'none';
		document.getElementById(lastQues).style.color = '#587290';
		lastAns = '';
		lastQues = '';
	}
}
function slide_timer(divAnsw, divHeight)
{
	//alert(divAnsw + ' ' + divHeight);
	//alert(divAnsw);
	//alert(document.getElementById(divAnsw).innerHTML);
}