//find current product
var current_page = top.location.href.split("/");
var current_page_url = decodeURI(current_page[current_page.length-1].split(".")[0]);
var current_product_section = current_page[current_page.length-3];
var related_title = '';
var related_location_prefix = '';
var related_url = '';
var found = false;
var debug = false;
var build_search_results = false;
var search_title_added = false;
var file_ext = (top.location.href.indexOf("http://www.samsung.com") != -1) ? '.htm' : '.asp?id=modem';
var counter = 0;

//array construct
//[0] = current product page url
//[1] = related product display title
//[2] = related product location prefix
//[3] = related product page url
//[4] = related product description
var related = [
//colour printers
    new Array("clp-650_and_clp-650n","ML-4551N/ ML-4551ND","printers/black_and_white","ml-4551n_and_ml-4551nd_(and_ml-4550)","High speed workgroup printer, powerful enough for the most demanding print environments"),
    new Array("clp-610nd_and_clp-660nd","ML-4551N/ ML-4551ND","printers/black_and_white","ml-4551n_and_ml-4551nd_(and_ml-4550)","High speed workgroup printer, powerful enough for the most demanding print environments"),
    new Array("clp-600_and_clp-600n","CLP-650/ CLP-650N","printers/colour","clp-650_and_clp-650n","High speed workgroup colour printer for professional applications"),
    new Array("clp-550_and_clp-550n","CLP-600/ CLP-600N","printers/colour","clp-600_and_clp-600n","High speed workgroup colour printer for high volume environments"),
    new Array("clp-510_and_clp-510n","CLP-600/ CLP-600N","printers/colour","clp-600_and_clp-600n","High speed workgroup colour printer for high volume environments"),
    new Array("clp-350n","CLP-300/ CLP-300N","printers/colour","clp-300_and_clp-300n","World's smallest colour laser printer, ideal for small office or home office use"),
    new Array("clp-300_and_clp-300n","CLP-350N","printers/colour","clp-350n","Compact colour laser printer, ideal for small office or home office use"),
//black and white printers
    new Array("ml-4551n_and_ml-4551nd_(and_ml-4550)","CLP-650/ CLP-650N","printers/colour","clp-650_and_clp-650n","High speed workgroup colour printer for professional applications"),
    new Array("ml-4050n","ML-4551N/ ML-4551ND","printers/black_and_white","ml-4551n_and_ml-4551nd_(and_ml-4550)","High speed workgroup printer, powerful enough for the most demanding print environments"),
    new Array("ml-3470d_and_ml-3471nd","ML-4551N/ ML-4551ND","printers/black_and_white","ml-4551n_and_ml-4551nd_(and_ml-4550)","High speed workgroup printer, powerful enough for the most demanding print environments"),
    new Array("ml-3561n_and_ml-3561nd_(and_ml-3560)","ML-4551N/ ML-4551ND","printers/black_and_white","ml-4551n_and_ml-4551nd_(and_ml-4550)","High speed workgroup printer, powerful enough for the most demanding print environments"),
    new Array("ml-3051n_and_ml-3051nd_(and_ml-3050)","ML-3561N/ ML-3561ND","printers/black_and_white","ml-3561n_and_ml-3561nd_(and_ml-3560)","Fast and dependable workgroup printer for shared use in large office environments"),
    new Array("ml-2571n_and_ml-2570_(and_ml-2510)","ML-3561N/ ML-3561ND","printers/black_and_white","ml-3561n_and_ml-3561nd_(and_ml-3560)","Fast and dependable workgroup printer for shared use in large office environments"),
    new Array("ml-2551n_and_ml-2550","ML-3051N/ ML-3051ND","printers/black_and_white","ml-3051n_and_ml-3051nd_(and_ml-3050)","Efficient and flexible workgroup printer for shared use in office environments"),
    new Array("ml-2010","ML-2571N/ ML-2570","printers/black_and_white","ml-2571n_and_ml-2570_(and_ml-2510)","Fast and dependable mono devices for personal or shared use in small office environments"),
    new Array("ml-1630","ML-2571N/ ML-2570","printers/black_and_white","ml-2571n_and_ml-2570_(and_ml-2510)","Fast and dependable mono devices for personal or shared use in small office environments"),
//multifunctional printers
    new Array("scx-6345n","SCX-6322DN/ SCX-6122FN","printers/multifunctional","scx-6322dn_and_scx-6122fn","High speed mono MFP with advanced features for shared use in busy office environments"),
    new Array("scx-6322dn_and_scx-6122fn","CLX-3160N/ CLX-3160FN","printers/multifunctional","clx-3160n_and_clx-3160fn","Colour multifunctional device ideal for shared use in office environments"),
    new Array("scx-5530_and_scx-5330n","SCX-6322DN/ SCX-6122FN","printers/multifunctional","scx-6322dn_and_scx-6122fn","High speed mono MFP with advanced features for shared use in busy office environments"),
    new Array("clx-2160n","CLX-3160N/ CLX-3160FN","printers/multifunctional","clx-3160n_and_clx-3160fn","Colour multifunctional device ideal for shared use in office environments"),
    new Array("clx-3160n_and_clx-3160fn","SCX-6322DN/ SCX-6122FN","printers/multifunctional","scx-6322dn_and_scx-6122fn","High speed mono MFP with advanced features for shared use in busy office environments"),
    new Array("scx-4725fn","CLX-3160N/ CLX-3160FN","printers/multifunctional","clx-3160n_and_clx-3160fn","Colour multifunctional device ideal for shared use in office environments"),
    new Array("scx-4520","SCX-4725FN","printers/multifunctional","scx-4725fn","4 in 1 multifunctional device for shared use in small office environments"),
    new Array("scx4500","CLX-3160N/ CLX-3160FN","printers/multifunctional","clx-3160n_and_clx-3160fn","Colour multifunctional device ideal for shared use in office environments"),
    new Array("scx-4321_and_scx-4521f","CLX-3160N/ CLX-3160FN","printers/multifunctional","clx-3160n_and_clx-3160fn","Colour multifunctional device ideal for shared use in office environments"),
    new Array("scx-4200","CLX-3160N/ CLX-3160FN","printers/multifunctional","clx-3160n_and_clx-3160fn","Colour multifunctional device ideal for shared use in office environments"),
//ultra mobile notebooks
    new Array("q1","Q1 Ultra","notebooks/ultra_mobile","q1_ultra","NEW Ultra Mobile PC combining all the features of a tablet PC, PDA and multimedia device"),
    new Array("q1_ultra","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("q40","Q1","notebooks/ultra_mobile","q1","Revolutionary mobile device that combines the capabilities of a PDA, MP3 / PMP, and tablet PC"),
    new Array("q45","Q1 Ultra","notebooks/ultra_mobile","q1_ultra","NEW Ultra Mobile PC combining all the features of a tablet PC, PDA and multimedia device"),
    new Array("q35","Q40","notebooks/ultra_mobile","q40","Reinforcing its technology leadership with Q40 - a HSDPA (Mobile Broadband) enabled mobile computer"),
//business class notebooks
    new Array("q70","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("r40plus","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("r70","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("x60plus","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("p50","X60","notebooks/business_class","x60plus","High performance computing with an elegant thin and light design and the latest cutting-edge technology"),
    new Array("x22","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("x11","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("r65","X11","notebooks/business_class","x11","High performance computing with an elegant thin and light design and the latest cutting-edge technology"),
    new Array("r40","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
    new Array("r20","Q45","notebooks/ultra_mobile","q45","Weighing in at a mere 1.86kg, the Q45 delivers the optimal balance of mobility and performance, including an impressive multimedia capability, that will enhance the productivity of even the most demanding and agile business users"),
//small and home office faxes
    new Array("sf-360_and_sf-365tp","SF-560","faxes/small_and_medium_businesses","sf-560","High speed, multipurpose device for shared use in busy offices"),
//small and medium business faxes
    new Array("sf-560","SF-365TP","faxes/small_and_home_office","sf-360_and_sf-365tp","Economical and reliable inkjet faxes for home and small office use"),
//desktop displays
    new Array("sm932gw","SM206BW/ SM226BW","displays/professional","sm206bw_226bw","New Windows Vista&trade; Certified widescreen monitors, ideal for multimedia entertainment and business multi-tasking"),
    new Array("sm932mw","SM932GW/ SM2032BW/ SM2232BW","displays/desktops","sm932gw","New Windows Vista&trade; Certified widescreen monitors, ideal for multimedia entertainment and business multi-tasking"),
    new Array("sm940ux","SM206BW/ SM226BW","displays/professional","sm206bw_226bw","New Windows Vista&trade; Certified widescreen monitors, ideal for multimedia entertainment and business multi-tasking"),
    new Array("sm971p","SM205BW/ SM215TW/ SM225BW","displays/professional","sm205bw_and_sm215tw_and_sm225bw","High resolution widescreen desktop monitors for multimedia content"),
    new Array("sm931c","SM305T","displays/professional","sm305t","Powerful, high resolution desktop monitor for professional applications"),
    new Array("sm713bm_and_sm913tm","SM205BW/ SM215TW/ SM225BW","displays/professional","sm205bw_and_sm215tw_and_sm225bw","High resolution widescreen desktop monitors for multimedia content"),
    new Array("sm242mp","SM305T","displays/professional","sm305t","Powerful, high resolution desktop monitor for professional applications"),
    new Array("sm940mw","SM932MW/ SM2032MW","displays/desktops","sm932mw","New LCD TV monitors, combining the functionality of a monitor with an HD ready LCD TV"),
    new Array("sm741mp_and_sm941mp","SM940MW","displays/desktops","sm940mw","Widescreen display compatible with data and video signals, with integrated TV tuner"),
    new Array("sm940bw","SM205BW/ SM215TW/ SM225BW","displays/professional","sm205bw_and_sm215tw_and_sm225bw","High resolution widescreen desktop monitors for multimedia content"),
    new Array("sm740t_and_sm940t","SM203B/ SM204B/ SM214T","displays/professional","sm203b_and_sm204b_and_sm214t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm740n_and_sm940n","SM203B/ SM204B/ SM214T","displays/professional","sm203b_and_sm204b_and_sm214t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm720n_and_sm920n","SM203B/ SM204B/ SM214T","displays/professional","sm203b_and_sm204b_and_sm214t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm720td","Q1","notebooks/ultra_mobile","q1","Revolutionary mobile device that combines the capabilities of a PDA, MP3 / PMP, and tablet PC"),
    new Array("sm940fn","SM203B/ SM204B/ SM214T","displays/professional","sm203b_and_sm204b_and_sm214t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm710ntxt","Q1","notebooks/ultra_mobile","q1","Revolutionary mobile device that combines the capabilities of a PDA, MP3 / PMP, and tablet PC"),
//professional displays
    new Array("sm225uw","SM305T","displays/professional","sm305t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm305t","SM203B/ SM204B/ SM214T","displays/professional","sm203b_and_sm204b_and_sm214t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm244t","SM305T","displays/professional","sm305t","Powerful, high resolution desktop monitor for professional applications"),
    new Array("sm206bw_226bw","SM203B/ SM204B/ SM214T","displays/professional","sm203b_and_sm204b_and_sm214t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm205bw_and_sm215tw_and_sm225bw","SM305T/ SM275T/ SM245T","displays/professional","sm305t","Large screen desktop monitors for multi-document viewing"),
    new Array("sm203b_and_sm204b_and_sm214t","SM205BW/ SM215TW/ SM225BW","displays/professional","sm205bw_and_sm215tw_and_sm225bw","High resolution widescreen desktop monitors for multimedia content"),
    new Array("xl20","SM305T/ SM275T/ SM245T","displays/professional","sm305t","Large screen desktop monitors for multi-document viewing"),
//public displays
    new Array("570","PPM50M6HSX/ PPM63M5HSX/ PPM42M6HSX","displays/public_displays","ppm50m6hsx_and_ppm63m5hsx_and_ppm42m6hsx","Versatile high resolution plasma displays for use in public spaces "),
    new Array("sm400pxn_and_sm460pn","PPM50M6HSX/ PPM63M5HSX/ PPM42M6HSX","displays/public_displays","ppm50m6hsx_and_ppm63m5hsx_and_ppm42m6hsx","Versatile high resolution plasma displays for use in public spaces "),
    new Array("sm320p_and_sm400px_and_sm460p","SM400PXN/ SM460PN","displays/public_displays","sm400pxn_and_sm460pn","Networkable large format TFT displays for digital signage and point of information applications"),
    new Array("sm711nd","SM400PXN/ SM460PN","displays/public_displays","sm400pxn_and_sm460pn","Networkable large format TFT displays for digital signage and point of information applications"),
    new Array("ppm50m6hsx_and_ppm63m5hsx_and_ppm42m6hsx","SM320P/ SM400PX/ SM460PX","displays/public_displays","sm320p_and_sm400px_and_sm460p","Large format TFT displays for digital signage and point of information applications"),
    new Array("ppm42m6ssx","PPM50M6HSX/ PPM63M5HSX/ PPM42M6HSX","displays/public_displays","ppm50m6hsx_and_ppm63m5hsx_and_ppm42m6hsx","Versatile high resolution plasma displays for use in public spaces"),
//projector displays
    new Array("p300","Q35","notebooks/ultra_mobile","q35","The Q35 delivers the on-demand performance, reliability and AV functions designed to keep professionals mobile and productive"),
//unrelated products
//printers
    new Array("","P300","displays/projector","p300","Revolutionary micro projector featuring LED and DLP technology. Perfect for mobile working"),
    new Array("","CLP-510/ CLP-510N","printers/colour","clp-510_and_clp-510n","Economical colour laser printer with duplex function for shared office use"),
    new Array("","CLP-300/ CLP-300N","printers/colour","clp-300_and_clp-300n","World's smallest colour laser printer, ideal for small office or home office use"),
    new Array("","ML-2551/ ML-2550","printers/black_and_white","ml-2551n_and_ml-2550","Fast and dependable workgroup printer for shared use in large office environments"),
    new Array("","ML-2010","printers/black_and_white","ml-2010","Compact mono laser printer for personal use in small or home offices"),
    new Array("","SCX-6345N","printers/multifunctional","scx-6345n","High speed multifunctional device for the most demanding workgroup environments. Includes advanced document handling and finishing capabilities"),
    new Array("","SCX-4520","printers/multifunctional","scx-4520","Integrated digital copier, scanner and printer for personal use in the small office"),
    new Array("","SCX-4200","printers/multifunctional","scx-4200","3 in 1 Personal multifunctional device for the home office"),
//notebooks
    new Array("","P50","notebooks/business_class","p50","High performance computing featuring the latest cutting-edge security features"),
    new Array("","R40","notebooks/business_class","r40","Affordbable mobile computing without compromising performance"),
    new Array("","SM971P","displays/desktops","sm971p","Fully featured TFT monitor, with unrivalled image quality"),
    new Array("","SM931C","displays/desktops","sm931c","High performance TFT monitor able to reprodcue a wider range of colours with improved colour accuracy"),
//displays
    new Array("","SM713BM/ SM913TM","displays/desktops","sm713bm_and_sm913tm","TFT displays with inbuilt speakers for multimedia content"),
    new Array("","SM741MP/ SM941MP","displays/desktops","sm741mp_and_sm941mp","Data and video compatible TFT monitors with TV tuner for desktop use"),
    new Array("","SM940BW","displays/desktops","sm940bw","Widescreen TFT display for desktop use in an office environment"),
    new Array("","SM740T/ SM940T","displays/desktops","sm740t_and_sm940t","Digital TFT displays delivering high quality images for business applications"),
    new Array("","SM740N/ SM940N","displays/desktops","sm740n_and_sm940n","Height adjustable TFT displays for desktop use in the office"),
    new Array("","SM720N/ SM920N","displays/desktops","sm720n_and_sm920n","Affordable TFT monitors. Ideal replacements for legacy CRT monitors"),
    new Array("","SM720TD","displays/desktops","sm720td","Touch screen display and pen enabling digital annotation. Ideal for education or training applications"),
    new Array("","SM940FN","displays/desktops","sm940fn","High performance TFT monitor designed for trading floor use and finance applications"),
    new Array("","SM710NTXT","displays/desktops","sm710ntxt","TFT Monitors for server based computing. Each acts as a fully fledged PC harnessing the power of the server"),
    new Array("","SM711ND","displays/public_displays","sm711nd","Networked TFT display for digital signage and point of sale purposes"),
    new Array("","PPM50M6HSX/ PPM63M5HSX/ PPM42M6HSX","displays/public_displays","ppm50m6hsx_and_ppm63m5hsx_and_ppm42m6hsx","Cost effective plasma display for office or point of information use"),
    new Array("","SM206BW/ 226BW","displays/public_displays","sm206bw_226bw","NEW SM206BW and SM226BW Windows Vista™ Certified Widescreen Monitors")
];

function build_related_products_tool(){
	//dropdown population
	related_products_1 = document.getElementById("related_products_1");
	
	//build first dropdown
	add_option(related_products_1,"Please select an option","");
	
	for(i=1; i<=dropdown_content.length; i++){
		add_option(related_products_1,dropdown_content[i-1],i);
	}
}

function add_option(obj,text,value){
	var obj_option = new Option(text,value)
	var obj_length = obj.options.length
	
	obj.options[obj_length] = obj_option;
}

function delete_option(obj,obj_position){
	if(obj.options.length != 0){
		obj.options[obj_position] = null;
	}
}

function show_loading(){
	search_title_added = false;
	
	//remove any previous search results
	document.getElementById("search_results").innerHTML = '';
	
	display_type(document.getElementById("search_results"),'none');
	display_type(document.getElementById("search_loading"),'block');
}

function format_product_name(product){
	var related_similar = product.toUpperCase();
	
	//check to see if product code needs third product element removing
	if(related_similar.indexOf("_(AND_") > -1){
		var new_related_product = '';
		
		for(i=0; i<=related_similar.indexOf("_(AND_")-1; i++){
			new_related_product += related_similar.charAt(i);
		}
		
		related_similar = new_related_product;
	}
	
	related_similar = related_similar.replace(/_/g, ' ');
	related_similar = related_similar.replace(/AND/g, '&');
	related_similar = related_similar.replace(/\+/g, '');	
	
	return related_similar;
}

function search_related_products(){
	var combination_check;
	var search_results = document.getElementById('search_results');
	var search_loading = document.getElementById('search_loading');
	var you_searched_for = document.getElementById('youSearchedFor');
	var product_left = document.getElementById('productLeft');
	var product_right = document.getElementById('productRight');
	var obj_related_products = document.getElementById("related_products");
	var current_selection = related_products_1.options[related_products_1.selectedIndex];
	var current_selection_text = current_selection.text;
	
	current_selection = current_selection.value;
	
	if(current_selection.length == 0){
		alert('Please select an option');
		return false;
	}
	else{
		//reset record match counter
		counter = 0;
		
		display_type(product_left,'block');
		display_type(product_right,'block');
		search_results.style.width = '285px';
		product_right.style.paddingLeft = '10px';
		product_right.style.backgroundImage = 'url(/uk/business/b2b/images/global/dotted_repeater_vertical.gif)';
		you_searched_for.innerHTML = 'You searched for the <strong>' + format_product_name(current_page_url) + '</strong> with <strong>' + current_selection_text + '</strong>';

		for(var i=0; i<=related_products.length-1; i++){
			//alert('related: ' + related_products[i][0] + '\ncurrent page: ' + current_page_url);
			if(related_products[i][0] == current_page_url){
				//alert('matched: ' + related_products[i][0]);				
				for(var x=0; x<=related_products[i][1].length-1; x++){
					combination_check = related_products[i][1][x].split("=")[0];
					if(combination_check == '[OPT' + current_selection + ']'){
						//alert('Match found: ' + related_products[i][1][x].split("=")[1]);
					
						//check if the matched record has more than one related product for the comparison criteria
						var matched_record = related_products[i][1][x].split("=")[1];
						var matched_multi_results = matched_record.split("[#NEW]");

						if(matched_record.length == 0){
							product_left.style.display = 'none';
							product_right.style.paddingLeft = '0px';
							product_right.style.backgroundImage = 'none';
							search_results.style.width = '595px';							
							search_results.innerHTML = 'Your search has returned no results, this may be for a number of reasons:<ul id="relatedError"><li>This product is best in class for this range</li><li>This product has this feature as standard</li></ul><br />Please select an alternative feature';
							search_results.style.display = 'block';
							break;
						}
						else{
							if(matched_record.indexOf("[#NEW]") > -1){
								for(var y=0; y<=matched_multi_results.length-1; y++){
									counter++;
									lookup_related_product(matched_multi_results[y],true,y+1);
								}
							}
							else{
								//search criteria only returned 1 search result
								lookup_related_product(related_products[i][1][x].split("=")[1],true,1);
								counter = 1;
							}							
						}
						break;
					}					
				}
				break;
			}
		}
		
		if(counter == 1){
			display_type(product_right,'none');
		}

		display_type(search_loading,'none');
		display_type(search_results,'block');
	}
	
	return false;
}

function button_state(mode){
	var obj = document.getElementById('related_submit');
	
	switch(mode){
		case 'enabled':
			obj.disabled = false;	
			break;
		default:
			obj.disabled = true;
			break
	}
}

function display_type(element,mode){
	element.style.display = mode;
}

function lookup_related_product(page_url,search,record_position){
	if(search && !search_title_added){
		document.getElementById('related_products').getElementsByTagName("P")[0].style.display = 'block';
		document.getElementById('search_results').innerHTML += '<strong>You may also be interested in:</strong><br /><br />';
		search_title_added = true;
	}
	
	for(i=0; i<=related.length-1; i++){
		if(!search){
			//show related product information
			if(related[i][0] == page_url.toLowerCase()){
				var related_title = related[i][1];
				var related_location_prefix = related[i][2];
				var related_url = related[i][3];
				var related_info = related[i][4];
				
				//add lead-in product text
				var related_similar = format_product_name(page_url);
											
				document.getElementById("relatedSimilar").innerHTML = 'Similar to the <strong>' + related_similar + '</strong> but with:';
				
				found = true;
				break;
			}
		}
		else{
			//show actual product data
			if(related[i][3] == page_url.toLowerCase()){
				var related_title = related[i][1];
				var related_location_prefix = related[i][2];
				var related_url = related[i][3];
				var related_info = related[i][4];
				
				found = true;

				if(record_position == 1){
					build_search_results = false;
				}
				else{
					build_search_results = true;
				}
				break;
			}
		}
	}
	
	if(found){
		var entire_url = '/uk/business/b2b/products/' + related_location_prefix + '/' + related_url + file_ext;
		var entire_img_src = '/uk/business/b2b/images/related_products/' + related_location_prefix + '/' + related_url + '.jpg';
		
		if(build_search_results){
			obj_search_result = new search_result();
			
			obj_search_result.product_image = entire_img_src;
			obj_search_result.product_title = related_title;
			obj_search_result.product_description = related_info;
			obj_search_result.product_url = entire_url;
			obj_search_result.product_id = related_url;
			obj_search_result.build();
		}
		else{
			var objLink = document.getElementById("related_products").getElementsByTagName("A");
			var objImg = document.getElementById("related_products").getElementsByTagName("IMG");
			var objDetail = document.getElementById("details").getElementsByTagName("P");
			
			objLink[0].href = entire_url;
			objImg[0].src = entire_img_src;
			objImg[0].title = related_title;
			objDetail[0].innerHTML = '<a href="' + entire_url + '">' + related_title + '</a>';
			objDetail[1].innerHTML = related_info;
		}
		
		if(debug){
			var related_details = '';
			
			related_details += 'Matched: ' + related[i][0] + '\n\n';
			related_details += 'related product display title: ' + related[i][1] + '\n';
			related_details += 'related product location prefix: ' + related[i][2] + '\n';
			related_details += 'related product page url: ' + related[i][3];
			
			alert(related_details);
		}		
	}
}

function search_result(){
	this.product_image;
	this.product_title;
	this.product_description;
	this.product_url;
	this.product_id;
	this.build = display_search;
}

function display_search(){	
	var str_result = '';
	
	//str_result += '<div class="resultsContainer">';	
	//str_result += '	<p class="productTitle"><a href="javascript:toggle_layer(\'div' + this.product_id + '\',\'img' + this.product_id + '\',\'/uk/business/b2b/images/global/related_products/expanded.gif\',\'/uk/business/b2b/images/global/related_products/contracted.gif\')"><img id="img' + this.product_id + '" src="/uk/business/b2b/images/global/related_products/contracted.gif" border="0"></a><strong><a href="' + this.product_url + '" title="' + this.product_title + '">' + this.product_title + '</a></strong></p>';
	//str_result += '	<div class="contentContainer" id="div' + this.product_id + '" style="display:none">';
	//str_result += '		<a href="' + this.product_url + '"><img src="' + this.product_image + '" alt="" title="' + this.product_title + '" border="0" style="float:left;width:68px;margin-right:10px;"></a>';
	//str_result += '		<p class="productDescription">' + this.product_description + '</p>';
	//str_result += '		<div class="clearBoth"></div>';
	//str_result += '	</div>';
	//str_result += '</div>';
	
	str_result += '<div class="resultsContainer">';	
	str_result += '	<p class="productTitle"><strong><a href="' + this.product_url + '" title="' + this.product_title + '">' + this.product_title + '</a></strong></p>';
	str_result += '	<p>' + this.product_description + '</p>';
	str_result += '</div>';
	
	search_results.innerHTML += str_result;
}

function load_related_products(){
	image_roll(document.getElementById('products'),'over','images/global/top_navigation/');
	toggle_tabs(document.getElementById('tabs').getElementsByTagName("UL")[0],0);
					
	//load current products single related product
	lookup_related_product(current_page_url,false);
	build_related_products_tool();
}

function toggle_layer(obj_id,obj_image_id,expanded_image,contracted_image){
	obj = document.getElementById(obj_id);
											        
	if((obj.style.display == "block") || (obj.style.display == "") || (obj.style.display == null)){
		target_display = "none";
	}
	else{
		target_display = "block";
	}

	obj.style.display = target_display ;
	
	if(obj_image_id != undefined){
		obj_image = document.getElementById(obj_image_id);
							
		if (target_display == "block"){
			obj_image.src = expanded_image;
		}
		else{
			obj_image.src = contracted_image;
		}
	}
}