// JavaScript Document

var product_type = 0 // 0 = importer, 1 = exporter

function get_product()
{
	if (product_type == "0" )
	{get_importer_product();}
	else
	{get_exporter_product();}
	/*get_importer_product();
	get_exporter_product();*/
}

function clear_payment_methods()
{
	document.getElementById('payment_methods').options.length=0
}

function payment_methods_repopulate(type)
{
	var i = 0;
	clear_payment_methods()
	
	document.getElementById('payment_methods').options[i]=new Option("Select Payment Methods", 0, true, false);
	i++;
	document.getElementById('payment_methods').options[i]=new Option("Open Account", 1, false, false);
	i++;
	
	if (type !=2) 
	{
		document.getElementById('payment_methods').options[i]=new Option("Documentary Credit", 2, false, false);
		i++;
		document.getElementById('payment_methods').options[i]=new Option("Advance Payment", 3, false, false);
		i++;
	}
	if (type !=1) 
	{		
		document.getElementById('payment_methods').options[i]=new Option("Documentary Collection", 5, false, false);
		i++;
		document.getElementById('payment_methods').options[i]=new Option("Documentary Payment", 6, false, false);
		i++;
	}
}

function change_style(id, cls)
{
	var prefix_src="/sg/business/tradefinance/Images/"
	var postfix_src= ".gif"
	
	//document.getElementById(id).className = classname;
	switch(cls)
	{
		case 'hide_product':
		{
			src = prefix_src+id+'_h'+postfix_src;
			break;
		}
		case 'over_product':
		{
			src = prefix_src+id+'_o'+postfix_src;
			break;
		}
		default:
		{
			src = prefix_src+id+'_s'+postfix_src;
			break;
		}		
	}
	document.getElementById(id).setAttribute("src", src);
	document.getElementById(id).setAttribute("name", cls);
	//alert(src);
}

function get_importer_product()
{
	//shipment_type = document.getElementById('shipment_stage').options[document.getElementById('shipment_stage').selectedIndex].value;
	shipment_type = 0;
	payment_type = document.getElementById('payment_methods').options[document.getElementById('payment_methods').selectedIndex].value;

	switch (payment_type)
	{
		case '1':
		{				
			switch (shipment_type) 
			{
				case '1':
				{					
					change_style('issuanceofbankersguarantee','show_product');
					change_style('importfinancing','hide_product');
					break;
				}
				case '2':
				{
					change_style('issuanceofbankersguarantee','hide_product');
					change_style('importfinancing','show_product');
					break;
				}
				default:
				{
					change_style('issuanceofbankersguarantee','show_product');
					change_style('importfinancing','show_product');
					break;
				}
			}
			change_style('issuanceofletterofcredit','hide_product');
			//change_style('s013','hide_product');
			change_style('shippingguarantee','hide_product');
			change_style('inwardbillscollection','hide_product');
			change_style('backtobackletterofcredit','hide_product');
			break;
		}
		case '2':
		{
			change_style('issuanceofbankersguarantee','hide_product');
			change_style('issuanceofletterofcredit','show_product');
			//change_style('s013','hide_product');
			change_style('importfinancing','show_product');
			change_style('shippingguarantee','show_product');
			change_style('inwardbillscollection','hide_product');
			change_style('backtobackletterofcredit','show_product');
			break
		}
		case '3':
		{
			change_style('issuanceofbankersguarantee','hide_product');
			change_style('issuanceofletterofcredit','hide_product');
			//change_style('s013','show_product');
			change_style('importfinancing','hide_product');
			change_style('shippingguarantee','hide_product');
			change_style('inwardbillscollection','hide_product');
			change_style('backtobackletterofcredit','hide_product');
			break;
		}
		case '5':
		{
			change_style('issuanceofbankersguarantee','hide_product');
			change_style('issuanceofletterofcredit','hide_product');
			//change_style('s013','hide_product');
			change_style('importfinancing','show_product');
			change_style('shippingguarantee','show_product');
			change_style('inwardbillscollection','show_product');
			change_style('backtobackletterofcredit','hide_product');
			break;
		}
		case '6':
		{
			change_style('issuanceofbankersguarantee','hide_product');
			change_style('issuanceofletterofcredit','hide_product');
			//change_style('s013','hide_product');
			change_style('importfinancing','show_product');
			change_style('shippingguarantee','show_product');
			change_style('inwardbillscollection','hide_product');
			change_style('backtobackletterofcredit','hide_product');
			break;
		}
		default:
		{
			switch (shipment_type) 
			{
				case '1':
				{
					change_style('issuanceofbankersguarantee','show_product');
					change_style('issuanceofletterofcredit','show_product');
					//change_style('s013','show_product');
					change_style('importfinancing','hide_product');
					change_style('shippingguarantee','hide_product');
					change_style('inwardbillscollection','hide_product');
					change_style('backtobackletterofcredit','hide_product');
					break;
				}
				case '2' :
				{
					change_style('issuanceofbankersguarantee','hide_product');
					change_style('issuanceofletterofcredit','hide_product');
					//change_style('s013','hide_product');
					change_style('importfinancing','show_product');
					change_style('shippingguarantee','show_product');
					change_style('inwardbillscollection','show_product');
					change_style('backtobackletterofcredit','hide_product');
					break;
				}
				default:
				{
					change_style('issuanceofbankersguarantee','show_product');
					change_style('issuanceofletterofcredit','show_product');
					//change_style('s013','show_product');
					change_style('importfinancing','show_product');
					change_style('shippingguarantee','show_product');
					change_style('inwardbillscollection','show_product');
					change_style('backtobackletterofcredit','show_product');
					break;
				}
			}				
			break;
		}
	}
}

function get_exporter_product()
{
	//shipment_type = change_style('shipment_stage').options[change_style('shipment_stage').selectedIndex].value;
	shipment_type = 0;
	payment_type = document.getElementById('payment_methods').options[document.getElementById('payment_methods').selectedIndex].value;

	switch (payment_type)
	{
		case '1':
		{	
			/*if (shipment_type == 2)
			{
				change_style('openaccount','show_product";
			}
			else
			{
				change_style('openaccount','hide_product');
			}*/
			change_style('openaccount','show_product');
			change_style('advisingofletterofcredit','hide_product');
			change_style('confirmationofletterofcredit','hide_product');
			change_style('packingloan','hide_product');
			change_style('transferletterofcredit','hide_product');
			//change_style('backtobackletterofcredit','hide_product');
			change_style('bankersguarantee_export','hide_product');
							
			change_style('exportbills','hide_product');
			change_style('outwardbillscollection','hide_product');
			change_style('negotiationofletterofcredit','hide_product');
			break;
		}
		case '2':
		{
			change_style('advisingofletterofcredit','show_product');
			change_style('confirmationofletterofcredit','show_product');
			change_style('packingloan','show_product');
			change_style('transferletterofcredit','show_product');
			//change_style('backtobackletterofcredit','show_product');
			change_style('bankersguarantee_export','hide_product');
			
			change_style('openaccount','hide_product');
			change_style('exportbills','hide_product');
			change_style('outwardbillscollection','hide_product');
			change_style('negotiationofletterofcredit','show_product');
			break
		}
		case '3':
		{
			change_style('advisingofletterofcredit','hide_product');
			change_style('confirmationofletterofcredit','hide_product');
			change_style('packingloan','hide_product');
			change_style('transferletterofcredit','hide_product');
			//change_style('backtobackletterofcredit','hide_product');
			change_style('bankersguarantee_export','show_product');
			
			change_style('openaccount','hide_product');
			change_style('exportbills','hide_product');
			change_style('outwardbillscollection','hide_product');
			change_style('negotiationofletterofcredit','hide_product');
			break;
		}
		case '5':
		{
			change_style('advisingofletterofcredit','hide_product');
			change_style('confirmationofletterofcredit','hide_product');
			change_style('packingloan','hide_product');
			change_style('transferletterofcredit','hide_product');
			//change_style('backtobackletterofcredit','hide_product');
			change_style('bankersguarantee_export','hide_product');
			
			change_style('openaccount','hide_product');
			change_style('exportbills','show_product');
			change_style('outwardbillscollection','show_product');
			change_style('negotiationofletterofcredit','hide_product');
			break;
		}
		case '6':
		{
			change_style('advisingofletterofcredit','hide_product');
			change_style('confirmationofletterofcredit','hide_product');
			change_style('packingloan','hide_product');
			change_style('transferletterofcredit','hide_product');
			//change_style('backtobackletterofcredit','hide_product');
			change_style('bankersguarantee_export','hide_product');
			
			change_style('openaccount','hide_product');
			change_style('exportbills','hide_product');
			change_style('outwardbillscollection','hide_product');
			change_style('negotiationofletterofcredit','show_product');
			break;
		}
		default:
		{
			switch (shipment_type) 
			{
				case '1':
				{
					change_style('advisingofletterofcredit','show_product');
					change_style('confirmationofletterofcredit','show_product');
					change_style('packingloan','show_product');
					change_style('transferletterofcredit','show_product');
					//change_style('backtobackletterofcredit','show_product');
					change_style('bankersguarantee_export','show_product');
					
					change_style('openaccount','hide_product');
					change_style('exportbills','hide_product');
					change_style('outwardbillscollection','hide_product');
					change_style('negotiationofletterofcredit','hide_product');
					break;
				}
				case '2' :
				{
					change_style('advisingofletterofcredit','hide_product');
					change_style('confirmationofletterofcredit','hide_product');
					change_style('packingloan','hide_product');
					change_style('transferletterofcredit','hide_product');
					//change_style('backtobackletterofcredit','hide_product');
					change_style('bankersguarantee_export','hide_product');
					
					change_style('openaccount','show_product');
					change_style('exportbills','show_product');
					change_style('outwardbillscollection','show_product');
					change_style('negotiationofletterofcredit','show_product');
					break;
				}
				default:
				{
					change_style('advisingofletterofcredit','show_product');
					change_style('confirmationofletterofcredit','show_product');
					change_style('packingloan','show_product');
					change_style('transferletterofcredit','show_product');
					//change_style('backtobackletterofcredit','show_product');
					change_style('bankersguarantee_export','show_product');
					
					change_style('openaccount','show_product');
					change_style('exportbills','show_product');
					change_style('outwardbillscollection','show_product');
					change_style('negotiationofletterofcredit','show_product');
					break;
				}
			}				
			break;
		}
	}
}


function main_over(id,cls)
{	
	if (cls == 'show_product')
	{
		change_style(id,'over_product');
		//document.getElementById(id).className = "over_product";
	}
}

function main_show(id,cls)
{
	if (cls == 'over_product')
	{
		change_style(id,'show_product');
		//document.getElementById(id).className = "show_product";
	}
}

function switch_tab(i)
{
	product_type = i;
	//document.getElementById('payment_methods').selectedIndex = 0;
	get_product();
	if (i == '0')
	{
		document.getElementById("div_importer").style.display = '';
		document.getElementById("div_exporter").style.display = 'none';
		document.getElementById("import_tab").setAttribute("src", "/sg/business/tradefinance/Images/importer_o.gif");
		document.getElementById("export_tab").setAttribute("src", "/sg/business/tradefinance/Images/exporter.gif");
	}
	else
	{
		document.getElementById("div_importer").style.display = 'none';
		document.getElementById("div_exporter").style.display = '';
		document.getElementById("import_tab").setAttribute("src", "/sg/business/tradefinance/Images/importer.gif");
		document.getElementById("export_tab").setAttribute("src", "/sg/business/tradefinance/Images/exporter_o.gif");
	}
	
}

//--------------------------------------------- Pricing Guide ------------------------------------------------//
function hide_all_pricing_guide()
{
	var i=1;
	var el;
	for (i=1;i<=7;i++) {
		el = "PricingGuide"+i
		document.getElementById(el).style.display = 'none';
	}
}

function show_pricingguide(id)
{
	hide_all_pricing_guide();
	if (id != '0')
	{
		el = "PricingGuide"+id
		document.getElementById(el).style.display = '';
	}
}
//--------------------------------------------- End Pricing Guide ------------------------------------------------//

function apply_show_detail(id)
{
	var title = "step_" + id;
	var detail = "step_"+id+"_o";
	
	document.getElementById(detail).style.display = '';
	document.getElementById(title).style.display = 'none';
}
function apply_hide_detail(id)
{
	var title = "step_" + id;
	var detail = "step_"+id+"_o";
	
	document.getElementById(title).style.display = '';
	document.getElementById(detail).style.display = 'none';
}

function dropdown_methods_display(act)
{
	try{document.getElementById("payment_methods").style.display = act;}catch(err) {}
	try{document.getElementById("sel_pricing_guide").style.display = act;}catch(err) {}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
}
