function swapImage (img, dest)
{
		img.src = dest.src;
}

function centerPopup (width, height)
{
	var xt = (screen.width - width)/2;
	var yt = (screen.height - height)/2;
	window.moveTo(xt, yt);
	window.resizeTo(width, height);
}

function popWindow(url)
{
	day = new Date();
	id = day.getTime();
	winFeatures="'status=no,location=no,toolbar=no,scrollbars=1,resizable=1";
	showcase=window.open(url, id, winFeatures);
	showcase.focus();	
}

function popJobWindow(str)
{
	url = 'jobs.html?' + str;
	id = 'jobwindow';
	winFeatures="'status=no,location=no,toolbar=no,scrollbars=1,resizable=1";
	showcase=window.open(url, id, winFeatures);
	showcase.focus();	
}

function getQueryVariable (variable) 
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
    	var pair = vars[i].split("=");
    	if (pair[0] == variable) {
      		return pair[1];
    	}
  	} 
	return '';
}

function writeHeader (page)
{
	var header = '';
	if (page == 'main') {
		document.write('<img src="images/main_header_v2.gif" width="770" height="167">');
	} else {
		header += '<table width="770" border="0" cellspacing="0" cellpadding="0">' +
		'<tr><td style="border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000;"></td>' +
		'<td class="navTextSmall" style="border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000;" align="right">' +
		'<a href="../index.html" class="navTextSmall">Home</a>|' +
		'<a href="../corporate/sitemap.html" class="navTextSmall">Sitemap</a>|' +
		'<a href="../corporate/careers.html" class="navTextSmall">Careers</a>|' +
		'<a href="../corporate/contact.html" class="navTextSmall">Contact Info</a>|' +
		'<a href="../corporate/enquiry.html" class="navTextSmall">Inquiry Form</a></td></tr>' +
		'</table>' +
		'<table width="770" border="0" cellspacing="0" cellpadding="0">' +
		'  <tr>' +
		'	<td height="167" style="background-image:url(\'images/header_img.gif\');">' +
		'<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'  <tr>' +
		'	<td width="228" height="128">&nbsp;</td>' +
		'	<td width="90" height="128"></td>' +
		'	<td width="81" height="128">&nbsp;</td>' +
		'	<td width="71" height="128">&nbsp;</td>' +
		'	<td width="99" height="128">&nbsp;</td>' +
		'	<td width="201" height="128">&nbsp;</td>' +
		'  </tr>' +
		'  <tr>' +
		'	<td width="228" height="28">&nbsp;</td>' +
		'	<td width="90" height="28"><a href="javascript:;" onClick="swapImage(corporate, corporateOn); MM_showMenu(window.mm_menu_corporate,0,30,null,\'corporate\');" onMouseOut="swapImage(corporate, corporateOff); MM_startTimeout();"><img src="../images/corporate_off.gif" name="corporate" width="90" height="28" id="corporate" border="0"></a></td>' +
		'	<td width="81" height="28"><a href="javascript:;" onClick="swapImage(products, productsOn); MM_showMenu(window.mm_menu_products,0,30,null,\'products\');" onMouseOut="swapImage(products, productsOff); MM_startTimeout();"><img src="../images/products_off.gif" name="products" width="81" height="28" id="products" border="0"></a></td>' +
		'	<td width="71" height="28"><a href="javascript:;" onClick="swapImage(services, servicesOn); MM_showMenu(window.mm_menu_services,0,30,null,\'services\');" onMouseOut="swapImage(services, servicesOff); MM_startTimeout();"><img src="../images/services_off.gif" name="services" width="71" height="28" id="services" border="0"></a></td>' +
		'	<td width="99" height="28"><a href="javascript:;" onClick="swapImage(applications, applicationsOn); MM_showMenu(window.mm_menu_applications,0,30,null,\'applications\');" onMouseOut="swapImage(applications, applicationsOff); MM_startTimeout();"><img src="../images/applications_off.gif" name="applications" width="99" height="28" id="applications" border="0"></a></td>' +
		'	<td width="201" height="28"><a href="javascript:;" onClick="swapImage(faclocs, faclocsOn); MM_showMenu(window.mm_menu_faclocs,0,30,null,\'faclocs\');" onMouseOut="swapImage(faclocs, faclocsOff); MM_startTimeout();"><img src="../images/faclocs_off.gif" name="faclocs" width="201" height="28" id="faclocs" border="0"></a></td>' +
		'  </tr>' +
		'  <tr>' +
		'	<td height="11"></td>' +
		'	<td height="11"></td>' +
		'	<td height="11"></td>' +
		'	<td height="11"></td>' +
		'	<td height="11"></td>' +
		'	<td height="11"></td>' +
		'  </tr>' +
		'</table>' +
		'	</td>' +
		'  </tr>' +
		'</table>';
		document.write (header);
	}
}

function writeFooter (level)
{
	document.write ('<table width="100%" border="0" cellpadding="0" cellspacing="0">');
	document.write ('<tr>');
	document.write ('<td height="2" colspan="2" align="left" valign="top" bgcolor="#0051A5"></td>');
	document.write ('</tr>');
	document.write ('<tr bgcolor="#FF7900">');
	document.write ('<td height="4" colspan="2" align="left" valign="top"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td width="53%" align="left" valign="middle" bgcolor="#FFFFFF" class="copyrightCell">Copyright 2004 &copy; by Crescendas MEC Group </td>');
	if (level == 'main')
		document.write ('<td width="47%" align="right" valign="middle" class="copyrightCell">A member of the <a href="http://www.crescendas.com"><img src="images/cgrouplogo.jpg" width="74" height="16" border="0"></a></td>');
	else
		document.write ('<td width="47%" align="right" valign="middle" class="copyrightCell">A member of the <a href="http://www.crescendas.com"><img src="../images/cgrouplogo.jpg" width="74" height="16" border="0"></a></td>');
	document.write ('</tr>');
	document.write ('<tr bgcolor="#08045A">');
	document.write ('<td height="14" colspan="2" align="left" valign="top"></td>');
	document.write ('</tr>');
	document.write ('</table>');
}

function writeCorpMenu (page)
{
	labels = new Array ('Company Profile', 'Quality Policy', 'Awards &amp; Certifications', 'Computer Systems', 'Our Business Partners', 'Contact Info', 'Inquiry Form', 'Career Opportunities');
	links = new Array('profile.html', 'quality.html', 'awards.html', 'computer.html', 'partners.html', 'contact.html', 'enquiry.html', 'careers.html');
	
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header.jpg" width="174" height="30"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	document.write ('</tr>');
	
	for (i=0; i<8; i++) {
		document.write ('<tr>');
		if (page == links[i])
			document.write ('<td background="images/navbg_active.jpg" bgcolor="#EFEBDE" class="navTextCorpActive">' + labels[i] + '</td>');
		else
			document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE" class="navTextCorp"><a href="' + links[i] + '" class="navTextLinkCorp">' + labels[i] + '</a></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#333333" height="1"></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#FFFFFF" height="1"></td>');
		document.write ('</tr>');
	}
    
	document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('</table>');
}

function writeProductsMenu (page)
{
	labels = new Array ('Products Overview', 'Wire Harnesses', 'Ribbon (Flat) Cables', 'Overmolded Cables', 'PCB Assemblies', 'Value Added Assemblies', 'Custom Solutions', 'Distribution');
	links = new Array('index.html', 'wire.html', 'ribbon.html', 'overmolded.html', 'pcb.html', 'value.html', 'custom.html', 'distribution.html');
	
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	document.write ('<tr>');
	//if (page == 'index.html')
		//document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header_active.jpg" width="174" height="30"></td>');
	//else
		document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header.jpg" width="174" height="30" border="0"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	document.write ('</tr>');
	
	for (i=0; i<8; i++) {
		document.write ('<tr>');
		if (page == links[i])
			document.write ('<td background="images/navbg_active.jpg" bgcolor="#EFEBDE" class="navTextProdActive">' + labels[i] + '</td>');
		else
			document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE" class="navTextProd"><a href="' + links[i] + '" class="navTextLinkProd">' + labels[i] + '</a></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#333333" height="1"></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#FFFFFF" height="1"></td>');
		document.write ('</tr>');
	}
    
	document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('</table>');
}

function writeServicesMenu (page)
{
	labels = new Array ('New Product Development', 'Logistics Services', 'Procurement Services');
	links = new Array('new.html', 'logistics.html', 'procurement.html');
	
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header.jpg" width="174" height="30"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	document.write ('</tr>');
	
	for (i=0; i<3; i++) {
		document.write ('<tr>');
		if (page == links[i])
			document.write ('<td background="images/navbg_active.jpg" bgcolor="#EFEBDE" class="navTextServActive">' + labels[i] + '</td>');
		else
			document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE" class="navText"><a href="' + links[i] + '" class="navTextLinkServ">' + labels[i] + '</a></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#333333" height="1"></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#FFFFFF" height="1"></td>');
		document.write ('</tr>');
	}
    
	document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('</table>');
}


function writeAppMenu (page)
{
	labels = new Array ('Computer Peripherals', 'Telecom &amp; DataCom', 'Consumer Electronics', 'Automotive', 'Semicon &amp; Other Equipments');
	links = new Array('computer.html', 'telecom.html', 'consumer.html', 'automotive.html', 'semicon.html');
	
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header.jpg" width="174" height="30"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	document.write ('</tr>');
	
	for (i=0; i<5; i++) {
		document.write ('<tr>');
		if (page == links[i])
			document.write ('<td background="images/navbg_active.jpg" bgcolor="#EFEBDE" class="navTextAppActive">' + labels[i] + '</td>');
		else
			document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE" class="navText"><a href="' + links[i] + '" class="navTextLinkApp">' + labels[i] + '</a></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#333333" height="1"></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#FFFFFF" height="1"></td>');
		document.write ('</tr>');
	}
    
	document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('</table>');
}

function writeContactMenu (page)
{
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE"><img src="images/contact_header.jpg" width="174" height="30"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	document.write ('</tr>');
	document.write ('</table>');
}


function writeFacLocsMenu (page)
{
	labels = new Array ('Locations', 'Singapore', 'Malaysia', 'China', 'Visual Plant Tour');
	links = new Array('faclocs.html', 'singapore.html', 'malaysia.html', 'china.html', 'visual.html');
	
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header.jpg" width="174" height="30"></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	document.write ('</tr>');
	
	for (i=0; i<5; i++) {
		document.write ('<tr>');
		if (page == links[i]) {
			if (i == 0 || i == 4)
				document.write ('<td background="images/navbg_active.jpg" bgcolor="#EFEBDE" class="navTextFacsActive">' + labels[i] + '</td>');
			else
				document.write ('<td background="images/navbg_active.jpg" bgcolor="#EFEBDE" class="navTextFacsSubActive">' + labels[i] + '</td>');
		} else {
			if (i == 0 )
				document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE" class="navText"><a href="' + links[i] + '" class="navTextLinkFacs">' + labels[i] + '</a></td>');
			else if (i == 4)
				document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE" class="navText"><a href="javascript:popWindow(\'' + links[i] + '\')" class="navTextLinkFacs">' + labels[i] + '</a></td>');
			else
				document.write ('<td background="../images/navbgsub.jpg" bgcolor="#EFEBDE" class="navTextSub"><a href="' + links[i] + '" class="navTextLinkFacsSub">' + labels[i] + '</a></td>');
		}
		document.write ('</tr>');
		if (i == 0 || i == 4 || i == 3) {
			document.write ('<tr>');
			document.write ('<td bgcolor="#333333" height="1"></td>');
			document.write ('</tr>');
			document.write ('<tr>');
			document.write ('<td bgcolor="#FFFFFF" height="1"></td>');
			document.write ('</tr>');
		}
	}
    
	document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('<tr>');
    document.write ('<td background="../images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('</table>');
}

function writeMainMenu ()
{
	labels = new Array ('Contact Info', 'Enquiry Form', 'Career Opportunities');
	links = new Array('contact.html', 'enquiry.html', 'careers.html');
	
	document.write ('<table width="174" border="0" cellspacing="0" cellpadding="0">');
	//document.write ('<tr>');
	//document.write ('<td bgcolor="#EFEBDE"><img src="images/menu_header.jpg" width="174" height="30"></td>');
	//document.write ('</tr>');
	//document.write ('<tr>');
	//document.write ('<td bgcolor="#EFEBDE" height="1"></td>');
	//document.write ('</tr>');
	
	for (i=0; i<3; i++) {
		document.write ('<td background="images/navbg.jpg" bgcolor="#EFEBDE" class="navText"><a href="' + links[i] + '" class="navTextLink">' + labels[i] + '</a></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#333333" height="1"></td>');
		document.write ('</tr>');
		document.write ('<tr>');
		document.write ('<td bgcolor="#FFFFFF" height="1"></td>');
		document.write ('</tr>');
	}
    
	document.write ('<tr>');
    document.write ('<td background="images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('<tr>');
    document.write ('<td background="images/navbg.jpg" bgcolor="#EFEBDE">&nbsp;</td>');
    document.write ('</tr>');
    document.write ('</table>');
}

function writeTextFooter ()
{
	printerOn = new Image();
	printerOn.src = '../images/icon_printer_active.gif';
	printerOff = new Image();
	printerOff.src = '../images/icon_printer.gif';

	topOn = new Image();
	topOn.src = '../images/icon_top_active.gif';
	topOff = new Image();
	topOff.src = '../images/icon_top.gif';

	var content = '<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">' +
//	'<tr>' +
//	'<td colspan="3" height="2" background="../images/dotted_bg_blue_horz.jpg"></td>' +
//	'</tr>' +		
//	'<tr>' +
//	'<td width="40"></td>' +
//	'<td valign="top" align="right" class="text"><a href="#" onClick="window.print()" onMouseOver="swapImage(print,printerOn);" onMouseOut="swapImage(print,printerOff);"><img src="../images/icon_printer.gif" width="21" height="15" alt="PRINT THIS PAGE" name="print" border="0"></a> ' +
//	'<a href="#" onMouseOver="swapImage(top,topOn);" onMouseOut="swapImage(top,topOff);" border="0"><img src="../images/icon_top.gif" width="21" height="15" alt="GO TO TOP" name="top" border="0"></a></td>' +
//	'<td width="40"></td>' +
//	'</tr>	' +
	'<tr>' +
	'<td colspan="3" height="40">&nbsp;</td>' +
	'</tr>' +
	'</table>';
	document.write (content);
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
