var xWn = self.document;

var bgColor1 = "#DDDDDD";
var bgColor2 = "#666666";

var orangeColor = "#FF6633";
var borderColor = "#FF6633";
var backgroundColor = "#FFFFFF";
var warningColor = "#FFCCCC";
var leftPadding = "100";

var personID = "perID";
var companyID = "coID";
var detailsID = "detID";

var fNames = new Array();
fNames[0] = "Name:";  	
fNames[1] = "Position / Occupation:";
fNames[2] = "Department:";
fNames[3] = "Email Address:";
fNames[4] = "Phone Number:";

fNames[5] = "Industry:";	
fNames[6] = "Company Name:"; 	
fNames[7] = "Address 1:";	
fNames[8] = "Address 2:";	
fNames[9] = "City:";
fNames[10] = "State / Province:";	
fNames[11] = "Zip / Postal Code: ";
fNames[12] = "Country:";	

fNames[13] = "Currently, are you using any SIACAD Solutions:";
fNames[14] = "Operating System:";
fNames[15] = "How did you hear about SIACAD InfoBase?:";
var fValues = new Array();

var sPleaseSpecify = "Please Specify: ";

var fObject = new Array();
var selFields = new Array("level","country","hear");
var otherObjects = new Array();

function showTable(){
setDefaults();
xWn.open();
xWn.write(buildHeader());
xWn.write(buildPerson());
xWn.write(buildcompany());
xWn.write(buildDetails());
xWn.write(buildSave());

xWn.write('</td></tr></table></form>\n');
xWn.write(dpiTest());

xWn.close();
checkDPI();

}


function setDefaults(){
var i;
var s1;

for (i=0;i<3;i++){
	otherObjects[selFields[i]] = new apxTextField;
	otherObjects[selFields[i]].id = selFields[i] + '_other_txt';
	otherObjects[selFields[i]].selWidth = "65%";
	otherObjects[selFields[i]].values = new Array("");
}

}



function buildHeader(){
var ss;
ss  = '<table width="700" bgcolor="#FFFFFF" > \n';
ss += '<tr><td width="' + leftPadding + '"></td><td><br /><br />\n';
ss += '<form id="fx"><table width="500" bgcolor="' + borderColor + '" cellspacing="1" ';
ss += ' cellpadding="10" class="txt10">\n';
ss += '<tr bgcolor="#FFFFFF">\n';
ss += '<td>\n';
ss += '<span class="txt12"><b>InfoBase License Application</b></span><br /><br />\n';
ss += 'Please fill in the form below:<br />\n';


return ss;
	
	
	
}


function buildPerson(){
	
var i;
var ss = "";

ss += '<br /><table bgcolor="' + bgColor1 + '" width="100%" cellpadding="2" cellspacing="0" class="txt10" ';
ss += 'id="' + personID + '">\n';

for (i=0;i<5;i++){
	ss += '<tr valign="top">\n';
	ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
	ss += '<td>\n';
	
	fObject[i] = new apxTextField;
	fObject[i].id = "fnames_" + i.toString();
	fObject[i].backgroundColor=backgroundColor;
	
	fObject[i].values = new Array("");
	ss += fObject[i].popDialog();
	
	ss += '</td>\n';
	
	ss += '</tr>\n';

}	
	
ss += '</table>\n';
	
return ss;
	
}

function buildcompany(){
	
var i;
var ss = "";
var tmp = new Array();

tmp[0] = "Architecture" + comSep1 + "Architecture";
tmp[1] = "Interior Design" + comSep1 + "Interior Design";
tmp[2] = "Engineering" + comSep1 + "Engineering";
tmp[3] = "Contracting" + comSep1 + "Contracting";
tmp[4] = "Supplier" + comSep1 + "Supplier";
tmp[5] = "Manufacturer" + comSep1 + "Manufacturer";
tmp[6] = "Education" + comSep1 + "Education";
tmp[7] = "other" + comSep1 + "Other...";


i = 5;

ss += '<br /><table bgcolor="' + bgColor1 + '" width="100%" cellpadding="2" cellspacing="0" class="txt10" ';
ss += 'id="' + companyID + '" >\n';

ss += '<tr valign="top">\n';
ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
ss += '<td>\n';
	
fObject[i] = new apxSelector;
fObject[i].id = selFields[0];

fObject[i].setArray(tmp);

ss += fObject[i].popDialog("University");
ss += '<span id="' + selFields[0] + '_other"></span>\n';

ss += '</td>\n';
ss += '</tr>\n'



for (i=6;i<12;i++){
	ss += '<tr valign="top">\n';
	ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
	ss += '<td>\n';
	
	fObject[i] = new apxTextField;
	fObject[i].id = "fnames_" + i.toString();
	fObject[i].backgroundColor=backgroundColor;
//	fObject[i].isBold = false;
	fObject[i].values = new Array("");
	ss += fObject[i].popDialog();
	
	ss += '</td>\n';
	
	ss += '</tr>\n';
}	

i=12;

tmp = new Array();

tmp[0] = "Singapore" + comSep1 + "Singapore";
tmp[1] = "Malaysia" + comSep1 + "Malaysia";

tmp[2] = "Indonesia" + comSep1 + "Indonesia";
tmp[3] = "Philippines" + comSep1 + "Philippines";
tmp[4] = "India" + comSep1 + "India";

tmp[5] = "other" + comSep1 + "Other...";


ss += '<tr valign="top">\n';
ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
ss += '<td>\n';
	
fObject[i] = new apxSelector;
fObject[i].id = selFields[1];

fObject[i].setArray(tmp);

ss += fObject[i].popDialog("Singapore");
ss += '<span id="' + selFields[1] + '_other"></span>\n';
ss += '</td>\n';
ss += '</tr>\n'




	
ss += '</table>\n';
	
return ss;
	
}


function buildDetails(){
var i;
var ss = "";
var tmp = new Array();

i = 13;
ss += '<br /><table bgcolor="' + bgColor1 + '" width="100%" cellpadding="2" cellspacing="0" class="txt10" ';
ss += 'id="' + detailsID + '" >\n';

ss += '<tr valign="top">\n';
ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
ss += '<td>\n';
	
tmp[0] = "No" + comSep1 + "No ";
tmp[1] = "Yes" + comSep1 + "Yes ";
	
fObject[i] = new apxRadioCheckBox;
fObject[i].id = "have";
fObject[i].setArray(tmp);

fObject[i].checkType="radio";
fObject[i].backgroundColor=bgColor1;
fObject[i].checkedNos = new Array("No");

ss += fObject[i].popDialog();
ss += '</td>\n';
ss += '</tr>\n'
	
i = 14;
//ss += '<br /><table bgcolor="' + bgColor1 + '" width="100%" cellpadding="2" cellspacing="0" class="txt10">\n';

ss += '<tr valign="top">\n';
ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
ss += '<td>\n';
	
tmp[0] = "Win" + comSep1 + "Windows ";
tmp[1] = "Mac" + comSep1 + "Mac OSX ";
	
fObject[i] = new apxRadioCheckBox;
fObject[i].id = "platform";

fObject[i].setArray(tmp);
fObject[i].checkType="checkbox";
fObject[i].backgroundColor=bgColor1;
fObject[i].checkedNos = new Array("Win");

ss += fObject[i].popDialog();
ss += '</td>\n';
ss += '</tr>\n'	
	

i = 15;
tmp = new Array();

tmp[0] = "" + comSep1 + "(Select One)";
tmp[1] = "Instructor" + comSep1 + "An friend told me about it";
tmp[2] = "Co-Worker" + comSep1 + "My colleague is using it now";
tmp[3] = "Website" + comSep1 + "I found your SIACAD website while surfing";
tmp[4] = "User Demo" + comSep1 + "I saw it during a SIACAD User Group Meeting";
tmp[5] = "Supplier" + comSep1 + "A Supplier/Manufacturer recommended me to use it";
tmp[6] = "Already using" + comSep1 + "I've been using SIACAD Solutions in my former office";
tmp[7] = "other" + comSep1 + "Other...";


ss += '<tr valign="top">\n';
ss += '<td width="40%" align="right">' + fNames[i] + '</td>\n';
ss += '<td>\n';
	
fObject[i] = new apxSelector;
fObject[i].id = selFields[2];

fObject[i].setArray(tmp);

ss += fObject[i].popDialog("Not Selected");
ss += '<span id="' + selFields[2] + '_other"></span>\n';

ss += '</td>\n';
ss += '</tr>\n'


	
ss += '</table>\n';
	
return ss;
		
	
	
}


function buildSave(){
var ss;
ss  = '<br /><table bgcolor="' + bgColor2 + '" width="100%" cellpadding="5" cellspacing="0" class="txt10" ';
ss == '  >\n';

ss += '<tr valign="top">\n';
ss += '<td align="right" id="mainbox">\n';
ss += '<input type="button" value="Submit" onclick="doSubmit();" style="width:30%;font-weight:bold">\n';
	
ss += '</td>\n';
ss += '</tr>\n'


	
ss += '</table>\n';	
	
	
return ss;
	
}


function sel_followUp(xFno,xId,xFlt,xVal){
var s1;
var s2;
var s3;

s1 = xId + "_" + xVal;

if (xVal=="other"){
	s3 = '<br /><br />' + sPleaseSpecify + ' ' + otherObjects[xId].popDialog();	
	document.getElementById(s1).innerHTML = s3;
}
else {
	s1 = xId + "_other";
		document.getElementById(s1).innerHTML = "";

}

	
// alert(xId + "\n" + xVal);
	
}




function doSubmit(){
var txtFields = new Array(0,1,2,3,4,6,7,8,9,10,11);
	
var otherFields = new Array(5,12,15);	
var errMessage = "";

var i;
var j;
var s1 ="";
var s2;
var s3;

for (i=0;i<txtFields.length;i++){
	j= txtFields[i];
	s2 = fObject[j].getValue();
	if (s2==""){
		if (errMessage==""){
			errMessage="Please enter value for :\n" };errMessage += '   -- ' + fNames[j] + "\n";
			fObject[j].setBackgroundColor(warningColor);
	}
	else {fObject[j].setBackgroundColor(backgroundColor);fValues[j] = s2;};
}

if (errMessage!=""){errMessage += '\n'};


	
for (i=0;i<otherFields.length;i++){
	j = otherFields[i];
	s2 = fObject[j].getValue();
	fObject[j].setBackgroundColor(backgroundColor);
	if (s2=="other"){
		s3 = otherObjects[selFields[i]].getValue();
		if (s3==""){errMessage += 'Please fill in "Other.." for ' + fNames[j] + '\n\n';
			otherObjects[selFields[i]].setBackgroundColor(warningColor)
		}
		else {
			otherObjects[selFields[i]].setBackgroundColor(backgroundColor);
			fValues[j]=s2 + comSep1 + s3
			}

	}else {
		if (s2==""){
			fObject[j].setBackgroundColor(warningColor);
			errMessage += 'Please select an option for \n      ' + fNames[j] + '\n';
				} else {fValues[j] = s2};
		}
}	

j = 13;
fValues[j] = fObject[j].getChecked();


j = 14;
s2 = fObject[j].getChecked();


fObject[j].setBackgroundColor(backgroundColor);

if (s2==""){errMessage += 'Please select an option for \n      ' + fNames[j] + '\n';
fObject[j].setBackgroundColor(warningColor);}

else {fValues[j]=s2};
// confirmOK();

//doPostForm();
 if (errMessage!=""){alert(errMessage) } else {doPostForm();};

	
}

var sendWin;

function doPostForm(){
var wWidth = 380;
var wHeight = 250;
var xLoc = (screen.width -wWidth) / 2;
var yLoc = (screen.height - wHeight) / 2;
var xParam = "toolbar=0,directories=0,scrollbars=0,resizable=no,menubar=0,width=" + wWidth + ",height=" + wHeight + ";";

sendWin =window.open("","PostWindow",xParam);
sendWin.moveTo(xLoc,yLoc);
var nz = sendWin.document;

var ss = '<html>\n<head>\n<title>\nPost Form</title>\n';
ss += '<META HTTP-EQUIV="expires" CONTENT="0">\n'
ss += '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">\m'

ss += '<SCRIPT LANGUAGE="JavaScript">\n\n';
ss += 'var isec=0;\n';
ss += 'var sMsg = "... Connecting to Database<br />...Please hold on ...";\n\n';
ss += doFlash;

ss += '\n\n</SCRIPT>\n';
ss +=  '</HEAD>\n\n';
ss += '<body>\n';
nz.write(ss);


nz.write(buildJssNotes());

ss  = '<body bgcolor="' + orangeColor + '">\n';
ss += '<br /><table width="100%" >\n';
ss += '<tr valign="center" height="100%"><td  id="flash" align="center"></td></tr></table>\n';

ss += '\n\n<SCRIPT LANGUAGE="JavaScript">\n';
ss += 'doFlash();\n';
ss += 'document.jssnotes.submit();\n';
ss += '</SCRIPT>\n';

ss += '</body>\n';

ss += '</html>\n';

nz.write(ss);
nz.close();

	
}


function doFlash(){
var s1; 
if (isec==0){s1 = "#000000"; isec=1} else {s1 = "#FFFFFF";isec=0};
var x = document.getElementById("flash");
x.innerHTML = sMsg;
x.style.color = s1;
x.style.fontWeight = "bold";
x.style.fontSize = "40";
x.style.fontFamily="Staccato222 BT,Arial";
window.setTimeout("doFlash();",500);
	
}




function buildJssNotes(){
// alert(xUrl);
var jsnUrl = 'http://www.siacad.com/cgi-bin/forms/man.cgi';

sx =  '<form name="jssnotes" action="' + jsnUrl + '" method="POST">\n';
sx += '<input type="hidden" name="formfields" id="formfields" ';
sx += 'value="' + fNames.join(comSep3) + '">\n';
sx += '<input type="hidden" name="formvalues" id="formvalues" value="' + fValues.join(comSep3) + '">\n';
sx += '<input type="hidden" name="email" id="email" value="infobase@siacad.com">\n';
sx += '<input type="hidden" name="subject" id="subject" value="InfoBase Application">\n';

sx += '</form>\n';	

return sx;
	
	
}


function confirmOK(param){
var ss;

ss = '<br />Thank you for contacting<br />SIACAD Pte Ltd!<br /><br />';

var x = document.getElementById("mainbox");
x.style.fontSize="30";
x.style.background=orangeColor;
x.style.color = "#FFFFFF";
x.style.fontWeight="bold";
x.style.fontFamily="HandelGothic BT,Highlight Let,Staccato222 BT,Arial";
x.align="center";

x.innerHTML = ss;

	
	
}


//////////// dpi tests //////////////
function dpiTest(){
var ss = '<div id="dpitest" style="width:1in;height:1in;';
ss += 'visibility:hidden;">xx</div>\n';

return ss;
	
	
}


function checkDPI(){
var x = document.getElementById("dpitest");

var xDPI = x.offsetWidth;	
var i;
var myIDs = new Array(personID,companyID,detailsID);
	
switch (parseInt(xDPI)) {
	case 120:
		for (i=0;i<myIDs.length;i++){
			document.getElementById(myIDs[i]).style.fontSize = "8pt";	
			
		}	
	
	break;	

}

	
}


showTable();

