// JavaScript Document

/* void show_diagram_links(n)
 Action: shows the relevant links lint on the side according to what the user clicked on the main diagram.
 Params:
  @n - link group div index (1,2,3...).
*/
function show_diagram_links(n)
{
	var msg1=document.getElementById('no_diagrams_picked_yet');
	msg1.style.display='none';


	j=0;
	var side_content=document.getElementById('side_content');
	var divs=side_content.getElementsByTagName("DIV");  
	for (i=0; i<divs.length; i++)
	{
		if(divs[i].className=='hidden_linked_list')
		{
			j++;
			if(j==n)
				divs[i].style.display='block';
			else
				divs[i].style.display='none';
		}
	}
}

/* Replace image src attribute with the "_on" version and vice versa */
function replaceHoverImg(obj)
{
    var s=obj.src;
	var src;

	/* Get the suspected "_on" string */
	var on=s.substr(s.length-7,3);

	/* If the image is NOT the "on" version we turn it to the "on" version */
	if(on!='_on')
	{

		var s1=s.substr(0,s.length-4);
		var s2=s.substr(s.length-4,s.length);
		src=s1+'_on'+s2;

		obj.src=src;
	}
	
	/* If the image is the "on" version we turn it to the NOT "on" version */
	if(on=='_on')
	{
		var s1=s.substr(0,s.length-7);
		var s2=s.substr(s.length-4,s.length);
		src=s1+s2;
		obj.src=src;
	}
}

	function getElementsByClass(node,searchClass,tag) {
		var classElements = new Array();
		var els = node.getElementsByTagName(tag); // use "*" for all elements
		var elsLen = els.length;
		var pattern = new RegExp("\\b"+searchClass+"\\b");
		for (i = 0, j = 0; i < elsLen; i++) {
 		if ( pattern.test(els[i].className) ) {
 		classElements[j] = els[i];
 		j++;
 		}
	}
	return classElements;
	}


	function doOnLoad()
	{
		setLinksStyle();
		setImagesStyle();
	}


	function setImagesStyle()
	{
		var ps=document.getElementById('main_content');
		var imgs=ps.getElementsByTagName("img");
		for (i=0; i<imgs.length; i++)
		{
			if(imgs[i].style.width=='460px')
				imgs[i].style.marginLeft='0px';
		}
	}
			

	/* Set arrow/floppy disk images for inner links. How: create a dummy bdo, inserting whitespaces into it and setting its background. Why not just create a background? - Doesn't work in Hebrew in firefox. */
	function setLinksStyle()
	{
	content=document.getElementById('main_content');				
	anchors=getElementsByClass(content,'internal-link','a');
		for (var i=0; i<anchors.length; i++)
		{
			//alert(anchors[i].href + "," + anchors[i].className + ", " + anchors[i].style.className);
			if(anchors[i].className!='img_russian')
			{
				s=anchors[i].href;					
				len=s.length;
				suffix=s.substr(len-3,3);
				suffix=suffix.toLowerCase();

				a=document.createElement("bdo");
				a.style.backgroundRepeat='no-repeat';
				if(suffix=='doc' || suffix=='pdf')
				{
					paddingChars='\xa0\xa0\xa0\xa0';
					a.style.backgroundImage='url(fileadmin/radion/sys/template/en/images/flopy.gif)';				
					
					a.style.backgroundPosition='left 0px';
				}
				else
				{
					paddingChars='\xa0\xa0\xa0';
					a.style.backgroundImage='url(fileadmin/radion/sys/template/en/images/bodytext_arrow.gif)';				
					a.style.backgroundPosition='left 4px';
				
				}
				var nbsp = document.createTextNode(paddingChars);
				a.appendChild(nbsp);
				p=anchors[i].parentNode;
				a.appendChild(nbsp);
				p.insertBefore(a,anchors[i]);
			}
		}							
	}
	
	function goToPriceQuotePage()
	{  
		url="/index.php?id=544";
		emailCode=document.getElementById("email_code").firstChild.value;
		//alert(emailCode);
		url+="&emailCode="+emailCode;
		window.location.href=url;  
	}
		
/* dr 29.10.2006
	function goToPriceQuotePage()
	{		
		url="/index.php?id=544";
		url+="&emailCode="+emailCode;
		window.location.href=url;		
	}
 */
