
var todayIs=new Date();

var maxNames = 3;
var maxSessions = 4;

//var kidPrice = 365;
//var multiKidPrice = 365;
//var pricePerSession = 14.61;		// reduce price per day when past start
var deposit = 1;

var discountRate = 0;
var discountPrice = 0;
var discountDate = '1/1/2010';

// these are the displayed prices
var subtotalPrice=0;
var taxPrice=0;
var totalPrice=0;
var depositPrice =0;
var balanceDue = 0;

var eventName = "Climbing Team Registration";

var months = ["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec"];

// create array of all sessions
var allSessions = new Array();
function sessionDefination(name, closeDate, price, time, status) {
	this.name = name;
	this.closeDate = closeDate;
	this.price = price;
	this.pricePerSession;
	this.time = time;
	this.status = status;
	};
var sessionCount = 2;	
for (i=1;i<=sessionCount+1;i++) allSessions[i] = new sessionDefination("", "", 0, 0, "", "");

// 
i=0;
allSessions[i+=1] = {name:"Fall 08 Comp Team",		closeDate:"10/14/2008",		price:375, pricePerSession:11.36,	time:"4:30-6:30pm",		status:"Open"};
allSessions[i+=1] = {name:"Fall 08 Travel Team",	closeDate:"10/14/2008",		price:425, pricePerSession:12.88,	time:"4:30-6:30pm",		status:"Open"};

session1Dates = ["9/4/2008","9/9/2008",  "9/11/2008", "9/16/2008",  "9/18/2008",  "9/23/2008","9/25/2008","9/30/2008","10/2/2008",  "10/7/2008",  "10/9/2008", "10/14/2008"];
session2Dates = ["9/4/2008","9/9/2008",  "9/11/2008", "9/16/2008",  "9/18/2008",  "9/23/2008","9/25/2008","9/30/2008","10/2/2008",  "10/7/2008",  "10/9/2008", "10/14/2008"];

//todayIs.setFullYear(2008,8,6);  //remember, month minus one!
//todayIs.setHours(17,20);
//alert("today is="+todayIs)

for (x in session1Dates) {
	if (todayIs < returnDate(session1Dates[x]).setHours(17,00,0,0)) break;
	allSessions[1].price = allSessions[1].price - allSessions[1].pricePerSession;
};

for (x in session2Dates) {
	if (todayIs < returnDate(session2Dates[x]).setHours(17,00,0,0)) break;
	allSessions[2].price = allSessions[2].price - allSessions[1].pricePerSession;
};

//alert("test for closed");
// automatically close everything earlier than current date
for (ii = 1; ii<=sessionCount;  ii=ii+1) { 
	//alert("test session "+ii+" data is: "+returnDate(allSessions[ii].closeDate));
	if (todayIs >  returnDate(allSessions[ii].closeDate)) {
		allSessions[ii].status = "Closed";
		//alert("session "+ii+" closed");
		};
	};
		
		
// create array of kids
var child = new Array();
var childCount = 0;
function childDefination(name,age,sex,tsize,status,oldname) {
	this.name=name;
	this.age=age;
	this.sex=sex;
	this.tsize=tsize;
	this.status=status;  //true if all data ok for this kid
	this.oldname=oldname;
	};
for (i=1;i<=maxNames;i++) child[i] = new childDefination("",0,"","",false,"");

// create array of selected sessions
var selectedSessions = new Array();
for (i=0;i<=maxSessions;i++) {
	selectedSessions[i] = new aSession(0, "", "", "", "", "", 0, false);
	};
	
function aSession(nameidx, age, sex, name, date, price, status) {
	this.nameidx=nameidx;  //0 no name
	this.date=date;
	this.name=name;
	this.price=price;
	this.age=age;
	this.sex=sex;
	this.status=status;
	};
	
// complet initalization of arrays --------------------------------------------------------------------------

window.onload=formLoad;

function resetForm() {
	for (i=1;i<=maxSessions;i++) {
		removeAll(sDates[i]); 
		sDates[i].disabled=true;
		removeAll(sNames[i]); 
		sNames[i].disabled=true;
		selectedSessions[i].status=false;
		selectedSessions[i].nameidx=0;
		selectedSessions[i].name="";
		};
		
		document.application.childName2.disabled=true;
		document.application.childAge2.disabled=true;
		document.application.childGender2.disabled=true;
		document.application.tShirt2.disabled=true;
		
		document.application.childName3.disabled=true;
		document.application.childAge3.disabled=true;
		document.application.tShirt3.disabled=true;
		document.application.childGender3.disabled=true;
		
		for (i=1;i<=maxNames;i++) {
			child[i].status=false;
			child[i].name="";
			child[i].age=0;
			child[i].tsize="";
			child[i].oldname="";
			};
		
		displayNewPrice();
	};

function formLoad() {	// this function is called before the page is loaded (ie, page elements have not been created
	//resetForm();
	for (i=1;i<=maxNames;i++) {child[i].status=false; rowComplete(i);};
	displayNewPrice();
	};
	
//---------------------------------------------------------	
function afterLoad() { 
// this function is called after the page is loaded
	
	// create control array for session dropdown date elements
	sDates = new Array();
	sDates[1]=document.getElementById("Session1Date");
	sDates[2]=document.getElementById("Session2Date");
	sDates[3]=document.getElementById("Session3Date");
	sDates[4]=document.getElementById("Session4Date");
	
	// create control array of session names
	sNames = new Array();
	sNames[1]=document.getElementById("Session1Name");
	sNames[2]=document.getElementById("Session2Name");
	sNames[3]=document.getElementById("Session3Name");
	sNames[4]=document.getElementById("Session4Name");
	
	hSessions = new Array();  // these point to the hidden text field to be forwarded
	hSessions[1] = document.application.Session1;
	hSessions[2] = document.application.Session2;
	hSessions[3] = document.application.Session3;
	hSessions[4] = document.application.Session4;
	
	childAges = new Array();
	childAges[1] = document.application.childAge1;
	childAges[2] = document.application.childAge2;
	childAges[3] = document.application.childAge3;
	
	childGenders = new Array();
	childGenders[1] = document.application.childGender1;
	childGenders[2] = document.application.childGender2;
	childGenders[3] = document.application.childGender3;
	
	childTShirts = new Array();
	childTShirts[1] = document.application.tShirt1;
	childTShirts[2] = document.application.tShirt2;
	childTShirts[3] = document.application.tShirt3;
	
	childNames = new Array();
	childNames[1] = document.application.childName1;
	childNames[2] = document.application.childName2;
	childNames[3] = document.application.childName3;
	
	for (im1=1;im1<=maxSessions;im1++) { //load session dates into dropdown options
		loadDateChoices(sDates[im1]);
		sDates[im1].disabled=true;
		};
	};

function loadDateChoices(dde) {
// load session dates into drop-down
	dde.disabled=false;
	for (ii=1;ii<=sessionCount;ii++) {
		s=allSessions[ii].status;
		
		if (s.substr(0,4)=="Open") addOption(dde, allSessions[ii].name + " - $" + allSessions[ii].price.toFixed(2));
		};       
	};	

function newPhone(field) {
	if (ValidatePhone(field.value)) {  //if good phone number, then format
		var s = field.value;
		s=s.replace(/[^0-9]/gi, "");  //keep only numbers, format into 3 seperate fields
		if (s.length == 7) pnumber = "(801) " + s.substr(0,3) + "-" +  s.substr(3)
		else pnumber = "(" + s.substr(0,3) + ") " + s.substr(3,3) + "-" + s.substr(6);
		field.value=pnumber;
		};
	};
	
//function testAllSessionRow() {
//	for (var idx=1;idx<=maxSessions;idx++) sessionNameSelected(sNames[idx],idx);
//	};

function testSessionRow(idx) {  
// if row is complete, then enable next row
//alert("test session row: " + idx + " sNameIndex=" + sNames[idx].selectedIndex + " sDateIndex=" + sDates[idx].selectedIndex);
	if (sNames[idx].selectedIndex > 0 && sDates[idx].selectedIndex > 0 ) { // this session row is complete?		 		
		if (idx < 4) { // enable next row
			sDates[idx+1].disabled=false;
			sNames[idx+1].disabled=false;
			};
		};
	displayNewPrice();
	};
	
function sessionNameSelected(field,idx){
// called when name on a session loses focus/changes
	
	testSessionRow(idx);	
	};

function newDateSelected(field,idx) {
// get date, populate alternitive dates; called when session date is selected

	testSessionRow(idx);	
	};

//----------------------------------------------------------------------------------------------
function newTSize(field,idx) {
	rowComplete(idx);	
	};

function newAge(field,idx) {
	rowComplete(idx);
	};

function newGender(field,idx){
	rowComplete(idx);
	};

function newChildName(field,idx) {
	capWords(field);
	field.value = trim(field.value);
	
	// check for duplicate names
	for (nt=1;nt<=maxNames;nt++) {  
		if (field.value == childNames[nt].value && nt != idx && field.value != "") {
			alert ("enter name only once: "+child[nt].name);
			field.value = child[idx].oldname;
			return;
			};
		};
		
	// is this a replacement name?
	if ( ( child[idx].oldname != field.value ) && child[idx].status) {
		updateNameAll(child[idx].oldname,field.value);
		child[idx].oldname = field.value;
		displayNewPrice();
		return;
		};
			
	// test for blank name
	if (childNames[idx].value == '' && child[idx].oldname != '') {
		//alert("name is now blank");
		updateNameAll(child[idx].oldname,"");
		child[idx].status =false;
		displayNewPrice();
		return;
		};

	// if row complete then add name to otions... here
	rowComplete(idx);
	};

function rowComplete(rown) {
// test for kid completed row, enable following row

	if (!child[rown].status && childNames[rown].value != "" && childAges[rown].selectedIndex > 0 && childGenders[rown].selectedIndex > 0 && childTShirts[rown].selectedIndex > 0 ) {
		
		child[rown].status = true;
//alert("test name row:"+rown + " old status=" +child[rown].status);
		
		if (rown <=2 ) { // enable next row
			childNames[rown+1].disabled =false;
			childGenders[rown+1].disabled =false;
			childAges[rown+1].disabled =false;
			childTShirts[rown+1].disabled =false;
			
			document.application.Session1Name.disabled=false;
			document.getElementById("Session1Date").disabled = false;
			};
			
		//add name to option boxes for session names
		updateNameAll(child[rown].oldname,childNames[rown].value);
		child[rown].oldname=childNames[rown].value;
		
		return;   ////////////////////////////////////////////////////  only one
		
		kidCount=0;
		for (i=1;i<=maxNames;i++) if (childNames[i].selectedIndex >= 0) {
			kidCount++;
			onlyOne=i;
			};

		if (kidCount==1)  {  //if only one name, then select in sessions
			document.getElementById("Session1Name").remove(0);
			insertOption(document.getElementById("Session1Name"),"select name");
  			};
		}
		else { // name row is incomplete
		child[rown].status = false;
		updateNameAll(child[rown].oldname,"");
		};
};

//-----------------------------------------------------------------------------------------------------------------------------
function updateNameAll(oldName,newName) {
		updateName(document.getElementById('Session1Name'), oldName, newName,1); //remove old name
		updateName(document.getElementById('Session2Name'), oldName, newName,2); //remove old name
		updateName(document.getElementById('Session3Name'), oldName, newName,3); //remove old name
		updateName(document.getElementById('Session4Name'), oldName, newName,4); //remove old name
};

function updateName(obj,oldName,newName, idxx) {
	// if oldName="" then insert newName; if newName="" then delete oldName
	var i;
	if (oldName != "" ) {// find old name, replace with new
		for (i = 1 ; i <= obj.length -1; i++ ) {
			if ( obj.options[i].text == oldName ) {
				obj.remove(i);
				//alert(oldName + " removed for " + obj.id);
				};
			};
		};
	if (newName != "" ) addOption(obj,newName);  // just add new name
};

function addOption(obj,option) {
// add option to dropdown element
	myobject=document.createElement("OPTION");
	myobject.value=option;
	obj.appendChild(myobject);
	myobjecttext=document.createTextNode(option);
	myobject.appendChild(myobjecttext);
//alert(option +"  added to dropdown " + obj.id);
};

function insertOption(obj,option) {  //insert optin to first in dropdown
	//var elSel = document.getElementById('Session1Name');
	if (obj.selectedIndex >= 0) {
    	var elOptNew = document.createElement('option');
    	elOptNew.text = option;
    	//elOptNew.value = 'select name';
    	var elOptOld = obj.options[obj.selectedIndex];  
    	try {
      		obj.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
    		}
    	catch(ex) {
      		obj.add(elOptNew, obj.selectedIndex); // IE only
    		}
	};
};

//	removeAll(document.getElementById('Session1Name'));
function removeAll(obj) {
	//remove all but the first option in a dropdown box
  	//var elSel = document.getElementById('selectX');
  	var i;
  	for (i = obj.length - 1; i>=1; i--) { obj.remove(i); };
    };







//-------------------------------------------------------------------------------------------
//----------------------------
function displayNewPrice() {
// this computes the prices before being displayed
	form=document.application;
	
	// go thru all name and verify status
	for (i=1;i<=maxNames;i++) {
		child[i].status = false;
		child[i].name =  childNames[i].value;
		child[i].age = 	 childAges[i].options[childAges[i].selectedIndex].text;
		child[i].sex = 	 childGenders[i].options[childGenders[i].selectedIndex].text;
		child[i].tsize = childTShirts[i].options[childTShirts[i].selectedIndex].text;
		
		if (child[i].name !='' & child[i].age != '' & child[i].sex != '' & child[i].tsize != '') {
			child[i].status = true;
//			alert("child: "+i+ "status OK");
		};
	}; // next name
		
		/////////////////////////////////////////////////////////////////
	var firstSession = true;
	subtotalPrice = 0;
	discountPrice = 0;
	for (i=1;i<=maxSessions;i++) {
		// is this session complete with name and date?
		selectedSessions[i].status =  false;
		
		selectedSessions[i].name = 	  sDates[i].options[sDates[i].selectedIndex].text;   //remove price from session name
		a = selectedSessions[i].name.indexOf("$")-3;
		selectedSessions[i].name = selectedSessions[i].name.substr(0, a );
		
		selectedSessions[i].nameidx = 0;
		selectedSessions[i].age = '';
		selectedSessions[i].sex = '';
		if (sNames[i].selectedIndex > 0) {
			for (n=1; n<=maxNames; n++) { 
				if (child[n].name == sNames[i].options[sNames[i].selectedIndex].text) {
					selectedSessions[i].nameidx = n;
					selectedSessions[i].age = child[n].age;
					selectedSessions[i].sex = child[n].sex;
				};
			};  //next name
		};  //end if
		
//alert ("testing session: "+i); 
		if (selectedSessions[i].nameidx > 0 & sDates[i].options[sDates[i].selectedIndex].text != 'select session') {
			selectedSessions[i].status = true;
			
			//get the price from session name drop down box
			price = sDates[i].options[sDates[i].selectedIndex].text.indexOf("$");
			kidPrice = parseFloat(sDates[i].options[sDates[i].selectedIndex].text.substr(price+1));
			
			if (firstSession) {  // is first?
				selectedSessions[i].price= kidPrice; 
				firstSession = true;	//always true; no mulit-kid discount (change to false if multi-kid discount)
				}
			else {
				selectedSessions[i].price = multiKidPrice;
				};
			/// if session date > 2 weeks from now; add price to subtotal-available-for-deposit (make sure it includes any early-discount)
			subtotalPrice=subtotalPrice+selectedSessions[i].price;      // check and create running discount if not spring break session...
			if (todayIs < returnDate(discountDate) && (selectedSessions[i].date).indexOf("April 17") == -1)  discountPrice = discountPrice - roundTo( selectedSessions[i].price * discountRate,2);
			 
			}; //close complet session
		}; //next session
	
	
	subtotalPrice = subtotalPrice + discountPrice;
	taxPrice = roundTo((subtotalPrice) * taxRate,2);
	totalPrice = subtotalPrice + taxPrice;
	
	/// subtotalDepositPrice to include only 'subtotal-available-for-deposit
	/// add function to display 'one or more session are not available for depost' whenever 'deposit' is selected.
	
	subtotalDepositPrice = roundTo(subtotalPrice * deposit,2);
	depositTaxPrice = roundTo(subtotalDepositPrice * taxRate,2);
	totalDepositPrice = subtotalDepositPrice + depositTaxPrice;
	
	totalBalanceDue = (totalPrice - totalDepositPrice );
	
	dispPrice2();
};

//-------------------------
function dispPrice2() {
// this does the actual writting to the frame
   costframe.document.open();  
   costframe.document.write('<div id="paydiv" style="background-color:white; layer-background-color:white; position:absolute; top:0px; left:20px; width:325px; height:115px; z-index:1">');	
   costframe.document.write('<table border=0 bordercolorlight=#dddddd bordercolordark=#ffffff  width=350px height=71 style="font-size:11px; font-family:sans-serif; color:#666666; letter-spacing:1pt;">');
   costframe.document.write('<tr><td width=25><font color="#A63F00" ><p style="line-height: 15px"><u>Session</u></P><td align=right><font color="#A63F00" ><u>Price</u></td></tr>');   
   
   for (i=1;i<=maxSessions;i++) {
   		if (selectedSessions[i].status ) {
      		costframe.document.write('<tr><td>' + selectedSessions[i].name + ' (' + child[selectedSessions[i].nameidx].name + ')</td><td align=right>' + selectedSessions[i].price.toFixed(2) + '</td></tr>');   
   		};
	};	
   
   if (discountPrice <0)    costframe.document.write("<tr><td align=right>Pre-session discount:</td><td align=right> "+discountPrice.toFixed(2)+"</td></tr>");
   costframe.document.write("<tr><td align=right><b>Subtotal:</b></td><td align=right><b> $"+subtotalPrice.toFixed(2)+"</b></td></tr>");
   costframe.document.write("<tr><td align=right><b>Tax:</b></td><td align=right><b> $"+taxPrice.toFixed(2)+"</b></td></tr>");
   costframe.document.write("<tr><td align=right><b>Total:</b></td><td align=right><b> $"+totalPrice.toFixed(2)+"</b></td></tr> ");
   //if (form.paymentType[1].checked) costframe.document.write("<tr><td align=right><b>Deposit (due now)</b></td><td align=right><b> $"+totalDepositPrice.toFixed(2)+"</b></td></tr></table> ");
   
   costframe.document.write("</div>");
   costframe.document.close();
};




//  exit functions  --------------------------------------------------------------------------
function validateApplication(form) {
	var OK = true;
	var message = "The following item(s) are required";
	
		//----------------------------------------
		function testField(test, errorMessage) {
		// if test is false, then error condition
		// this function needs to be inside 'validateMembership' for the scope of message
			if (test) { message += errorMessage; OK = false; return false};
			return true;   }
			
	// test for member data
	testField(form.firstName.value == "" , "; first parent/guardian name");
	testField(form.lastName.value == "" , "; last parent/guardian name");	
	testField(form.address1.value == "", "; address");
	testField(!validZip(form.zip.value), "; zip");
	testField(!ValidatePhone(form.phone.value), "; phone number");
	testField(!validEmail(form.email.value), "; valid email address (you will receive email confirmation of this request)" );
	
	testField(totalPrice==0 , "; create a session");
	
	if (!OK ) { alert (message + ".") ; return false};
	
	// verify that each child name is in a ssession
	for (i=1;i<=maxNames;i++)  {	
		if (child[i].name != "" ) {
			OK=false;
			for (j=1;j<=maxSessions;j++) {
				if (selectedSessions[j].nameidx == i)  OK=true;
				};
			if (!OK) { alert ("'"+child[i].name + "' is not used in a session.  Create session or delete name to continue"); return false };
			};
		};
	
// passed validation, save options
	if (form.needWaiver.checked) form.needWaiver.value="yes"
	else form.needWaiver.value = "no";   //else it's null
	
	form.SessionCount.value = 0;
	for (i=1;i<=maxSessions;i++) { //copy valid session data to form 
		if (selectedSessions[i].status) {
			hSessions[i].value = selectedSessions[i].name + "\t" + child[selectedSessions[i].nameidx].name + "\t" + child[selectedSessions[i].nameidx].age;
				hSessions[i].value += "\t" + child[selectedSessions[i].nameidx].sex +"\t" + child[selectedSessions[i].nameidx].tsize + "\t";
				hSessions[i].value += (selectedSessions[i].price).toFixed(2) +  "\t" + "none" +  "\t" + (selectedSessions[i].price * taxRate).toFixed(2);
      		form.SessionCount.value++;
      		};
    	};
    	
    //************** change so that only kids in session show up in Kidsx
    form.Kid1.value = child[1].name + "\t" + child[1].age + "\t" + child[1].sex + "\t" + child[1].tsize;
    form.Kid2.value = child[2].name + "\t" + child[2].age + "\t" + child[2].sex + "\t" + child[2].tsize;
    form.Kid3.value = child[3].name + "\t" + child[3].age + "\t" + child[3].sex + "\t" + child[3].tsize;
 
     	
// set cookies for Waiver    
	if (form.needWaiver.checked) {
		form.needWaiver.value = "checked";   //else it's null
		var expdate = new Date ();
		expdate.setTime (expdate.getTime() + (1000 * 60 * 5 ));
		setCookie("_GuardianName", 	form.firstName.value + " " +form.lastName.value, expdate);
		setCookie("_ClimberName", 	child[1].name, expdate);
		setCookie("_ClimberAddress1", form.address1.value, expdate);
		setCookie("_ClimberZip", 	form.zip.value, expdate);
		setCookie("_ClimberPhone", 	form.phone.value, expdate);
	      
		setCookie("_EmergencyName", 		form.EmergencyName.value, expdate); 			
		setCookie("_EmergencyRelationship", form.EmergencyRelationship.value, expdate); 
		setCookie("_EmergencyPhone", 		form.EmergencyPhone.value, expdate); 
		
	    setCookie("_needWaiver", 		"checked", expdate);
	    setCookie("_doOnlineWaiver", 	"checked", expdate);
    };
        

// set fields for PayPal 
	  form.subtotal_price.value =  subtotalPrice.toFixed(2);
	  form.tax_price.value = taxPrice.toFixed(2);
	  form.total_price.value = totalPrice.toFixed(2);
	  
	  //if (form.paymentType[0].checked ) { // this is pay-in-full
	  if (true) {  //always paid in full
		 	form.amount.value =		 	subtotalPrice.toFixed(2);
	  		form.tax.value =			taxPrice.toFixed(2);  // tax due now
	  		form.total.value = 			totalPrice.toFixed(2);
	  		
	  		form.balance_due_subtotal.value =  	(0).toFixed(2);
	  		form.tax_due.value = 				(0).toFixed(2);
	  		form.balance_due_total.value =  	(0).toFixed(2);
	  		}
	  	else { //this is deposit only
		 	form.amount.value =		 	subtotalDepositPrice.toFixed(2);
	  		form.tax.value	=			depositTaxPrice.toFixed(2);  //tax due now
	  		form.total.value = 			totalDepositPrice.toFixed(2);
	  		
	  		form.balance_due_subtotal.value =  	(subtotalPrice - subtotalDepositPrice).toFixed(2);
	  		form.tax_due.value = 				(taxPrice - depositTaxPrice).toFixed(2);
	  		form.balance_due_total.value =  	totalBalanceDue.toFixed(2);
	  		};
	  
	  form.item_name.value = 	eventName; 
	  form.item_number.value = 	eventName;
	      	  
	  form.on0.value="Child Name(s)";
	  form.os0.value = child[1].name;
	  for (i=2;i<=maxNames;i++) if (child[i].name != "") form.os0.value += ", " + child[i].name;
	    
	  form.on1.value="Session(s)";
	  form.os1.value = selectedSessions[1].name;
	  for (i=2;i<=maxSessions;i++) { 
	  	if (selectedSessions[i].name != "") {
	  		form.os1.value += ", " + selectedSessions[i].name;
	  	};
	  };
	  
	  form.quantity.value = 1;
	  
	  
	  form.success.value= window.location.href.substr(0,window.location.href.lastIndexOf("/")+1) + "thankyou1.php";
	  form.cancel.value= window.location.href.substr(0,window.location.href.lastIndexOf("/")+1) + "cancel.php";
		  
	  var s = form.phone.value;
	  s=s.replace(/[^0-9]/gi, "");  //keep only numbers, format into 3 seperate fields
	  if (s.length == 7) {
		form.night_phone_a.value = "801"
		form.night_phone_b.value = s.substr(0,3);
		form.night_phone_c.value = s.substr(3); 
		}
		else {
		form.night_phone_a.value = s.substr(0,3);
		form.night_phone_b.value = s.substr(3,3);
		form.night_phone_c.value = s.substr(6); 
		};
 
    //window.onunload=null;
    
		// save info about broswer
		form.broswerData.value = navigator.appName;
		form.broswerData.value += " / " + navigator.appVersion;
		form.broswerData.value += " / " + navigator.platform;
		form.broswerData.value += " / " + navigator.appMinorVersion;
		form.broswerData.value += " / " + navigator.userAgent;

return OK;  

}