a_pag = new Array
a_prd = new Array
a_img = new Array
a_link = new Array
a_timeline = new Array
var p_cell
var d_title
var d_cell

function i_pg(product_page,product_column,product_group,product_name,product_description)
{
	this.page = product_page
	this.col = product_column
	this.group = product_group
	this.name = product_name
	this.text = product_description
//	this.image = product_image
}

function i_prd(product_group,product_id,product_name,product_description)
{
	this.group = product_group
	this.id = product_id
	this.name = product_name
	this.text = product_description
	//this.image = product_image
}

function i_img(image_group,image_product,image_src)
{
	this.group = image_group
	this.id = image_product
	this.src = image_src
}

function i_link(link_title,link_description,link_image,link_target)
{
	this.title = link_title
	this.text = link_description
	this.src = link_image
	this.target = link_target
}

function i_tline(line_page,line_date,line_detail,line_image)
{
	this.page = line_page
	this.dated = line_date
	this.text = line_detail
	this.src = line_image
}


function show_products(page)
{
	var i
	var j
	var all_table = ''
	var temp_cell = ''
	var option_count = 0
	var options = ''
	var single_option = 0
	var main_image = ''

	all_table = '<table border="0" cellpadding="0" cellspacing="0">'

	for (i=0 ; i<a_pag.length ; i++)
	{
		if (a_pag[i].page == page)
		{
			temp_cell = '<tr>'
			for (j=0 ; j<a_img.length ; j++)
			{
				if (a_img[j].group == a_pag[i].group && a_img[j].id == 0)
				{
					main_image = a_img[j].src
				}
			}
			temp_cell += '<td width="260" valign="top"><img src="images/'+main_image+'" border="0"></td>'
			temp_cell += '<td width="15">&nbsp;</td>'
			temp_cell += '<td width="750" valign="top">'
			temp_cell += '<table border="0" cellpadding="2" cellspacing="0">'
			temp_cell += '<tr><td ><b>'+a_pag[i].name+'</b></td></tr>'
			temp_cell += '<tr><td >&nbsp;</td></tr>'
			temp_cell += '<tr><td >'+a_pag[i].text+'</td></tr>'

			option_count = 0
			single_option = 0
			options = '<select id="group_'+a_pag[i].group+'">'
			for (j=0 ; j<a_prd.length ; j++)
			{
				if (a_prd[j].group == a_pag[i].group)
				{
					options += '<option value="'+a_prd[j].id+'">'+a_prd[j].name+'</option>'
					single_option = a_prd[j].id
					option_count++
				}
			}
			options += '</select>'

			if (option_count > 1)
			{
				temp_cell += '<tr><td >&nbsp;</td></tr>'
				temp_cell += '<tr><td><table border="0" cellpadding="0" cellspacing="0">'
				temp_cell += '<tr><td >Available options :</td>'
				temp_cell += '<td width="10">&nbsp;</td>'
				temp_cell += '<td >'+options+'</td>'
				temp_cell += '<td width="10">&nbsp;</td>'
				temp_cell += '<td ><a href="javascript:v_p('+a_pag[i].group+',0)">View</a></td></tr>'
				temp_cell += '</table></td></tr>'
				//temp_cell += '<td><a href="javascript:v_p('+a_pag[i].group+')">Order</a></td></tr>'
			}
			else
			{
				temp_cell += '<tr><td >&nbsp;</td></tr>'
				temp_cell += '<tr><td ><a href="javascript:v_p('+a_pag[i].group+','+single_option+')">View</a></td></tr>'
			}
			
			temp_cell += '</table>'
			temp_cell += '</td>'
			temp_cell += '</tr>'
			temp_cell += '<tr><td colspan="3" height="30">&nbsp;</td></tr>'

			all_table += temp_cell
		}
	}

//	all_table += '</td></tr>'
	all_table += '</table>'

	p_cell.innerHTML = all_table
}

function v_p(group,detail)
{
	var s_id = document.getElementById('group_'+group)
	var actual_dtl = (detail == 0) ? s_id.options[s_id.selectedIndex].value : detail
	window.open('detail_window.htm?g='+group+'&p='+actual_dtl,'Details','toolbar=0,status=0,scrollbars=1,width=800,height=450')
	
}

function v_p_win(group,detail)
{
	//var s_id = document.getElementById('group_'+group)
	var d_cell = document.getElementById('dtl_cell')
	//var d_title = document.getElementById('dtl_title')
	var i
	var j
	var temp_cell = ''
	var group_title = ''
	var group_text = ''
	//var detail_check = detail //(detail == 0) ? s_id.options[s_id.selectedIndex].value : detail

	for (i=0 ; i<a_pag.length ; i++)
	{
		if (a_pag[i].group == group)
		{
			group_title = a_pag[i].name
			group_text = a_pag[i].text
			break
		}
	}

	for (i=0 ; i<a_prd.length ; i++)
	{
		if (a_prd[i].group == group && a_prd[i].id == detail)
		{
			document.title = ((group_title == a_prd[i].name) ? group_title : group_title+' : '+a_prd[i].name)
			temp_cell = '<table border="0" cellpadding="5" cellspacing="0">'
			temp_cell += '<tr>'
			temp_cell += '<td width="510" valign="top" align="center">'
			temp_cell += '<table border="0" cellpadding="2" cellspacing="0">'
			for (j=0 ; j<a_img.length ; j++)
			{
				if (a_img[j].group == group && a_img[j].id == detail)
				{
					temp_cell += '<tr>'
					temp_cell += '<td><img src="images/'+a_img[j].src+'" border="0"></td>'
					temp_cell += '</tr>'
					temp_cell += '<tr><td height="15">&nbsp;</td></tr>'
				}
			}
			temp_cell += '</table>'
			temp_cell += '</td>'
			temp_cell += '<td width="15">&nbsp;</td>'
			temp_cell += '<td width="250" valign="top">'
			temp_cell += '<table border="0" cellpadding="2" cellspacing="0">'
			temp_cell += '<tr><td><b>'+a_prd[i].name+'</b></td></tr>'
			temp_cell += '<tr><td >&nbsp;</td></tr>'
			temp_cell += '<tr><td >'+ ((a_prd[i].text == "") ? group_text : a_prd[i].text) +'</td></tr>'
			temp_cell += '</td>'
			temp_cell += '</tr>'
			temp_cell += '</table>'
			break
		}
	}
	
			
	d_cell.innerHTML = temp_cell
	//show_span(true)
}

function show_links()
{
	var i
	var j
	var all_table = ''
	var temp_cell = ''

	all_table = '<table border="0" cellpadding="0" cellspacing="0">'

	for (i=0 ; i<a_link.length ; i++)
	{
			temp_cell = '<tr>'
			temp_cell += '<td width="260" valign="top">'
			if (a_link[i].src != "")
			{
				temp_cell += '<a href="http://'+a_link[i].target+'" target="_blank">'
				temp_cell += '<img src="images/'+a_link[i].src+'" border="0">'
				temp_cell += '</a>'
			}
			else
			{
				temp_cell += '&nbsp;'
			}
			temp_cell += '</td>'
			temp_cell += '<td width="15">&nbsp;</td>'
			temp_cell += '<td width="750" valign="top">'
			temp_cell += '<table border="0" cellpadding="2" cellspacing="0">'
			temp_cell += '<tr><td ><a href="http://'+a_link[i].target+'" target="_blank"><b>'+a_link[i].title+'</b></a></td></tr>'
			temp_cell += '<tr><td >&nbsp;</td></tr>'
			temp_cell += '<tr><td >'+a_link[i].text+'</td></tr>'
			temp_cell += '</table>'
			temp_cell += '</td>'
			temp_cell += '</tr>'
			temp_cell += '<tr><td colspan="3" height="30">&nbsp;</td></tr>'

			all_table += temp_cell
	}

//	all_table += '</td></tr>'
	all_table += '</table>'

	l_cell.innerHTML = all_table
}

function show_timeline(page)
{
	var i
	var j
	var all_table = ''
	var temp_cell = ''

	all_table = '<table border="0" cellpadding="0" cellspacing="0">'

	for (i=a_timeline.length-1 ; i>=0 ; i--)
	{
		if (a_timeline[i].page == page)
		{
			temp_cell = '<tr>'
			temp_cell += '<td width="260" valign="top">'
			if (a_timeline[i].src != "")
			{
//				temp_cell += '<a href="http://'+a_link[i].target+'" target="_blank">'
				temp_cell += '<img src="images/'+a_timeline[i].src+'" border="0">'
//				temp_cell += '</a>'
			}
			else
			{
				temp_cell += '&nbsp;'
			}
			temp_cell += '</td>'
			temp_cell += '<td width="15">&nbsp;</td>'
			temp_cell += '<td width="750" valign="top">'
			temp_cell += '<table border="0" cellpadding="2" cellspacing="0">'
//			temp_cell += '<tr><td ><a href="http://'+a_link[i].target+'" target="_blank"><b>'+a_link[i].title+'</b></a></td></tr>'
			temp_cell += '<tr><td ><b>'+a_timeline[i].dated+'</b></td></tr>'
			temp_cell += '<tr><td >&nbsp;</td></tr>'
			temp_cell += '<tr><td >'+a_timeline[i].text+'</td></tr>'
			temp_cell += '</table>'
			temp_cell += '</td>'
			temp_cell += '</tr>'
			temp_cell += '<tr><td colspan="3" height="30">&nbsp;</td></tr>'

			all_table += temp_cell
		}
	}

//	all_table += '</td></tr>'
	all_table += '</table>'

	r_cell.innerHTML = all_table
}