

var reqFields=new Array(
  Array ('Subject','Subject'),
  Array ('EmailAddress','Email Address'),
  Array ('FirstName','First Name'),
  Array ('LastName','Last Name'),
  Array ('Message','Message')  
);
// contains LicCompany, LicPhone, LicUrl, email
var LicProdInfo = new Array(
  Array('Paramount Farms','(800) 528-6887','http://www.paramountfarms.com','tibach@paramountfarms.com'),
  Array('Cadbury Schweppes (CSAB)','(800) 696-5891','http://www.sunkistsoda.com','consumer.relations@brandspeoplelove.com'),
  Array('WN Pharmaceuticals','(800) 430-7898','http://www.wnpharmaceuticals.com','info@webbernaturals.com'),
  Array('Winnie Anthony','','','wanthony@sunkistgrowers.com'),
  Array('A. Lassonde Inc.','(888) 343-9083','http://www.lassonde.com','lebeaud@lassonde.com'),
  Array('General Mills','(800) 231-0308','http://www.generalmills.com', 'wanthony@sunkistgrowers.com'),
  Array('Vitality Foodservice','(888) 863-6726','http://www.vitalityfoodservice.com','cknarr@vitalityinc.com'),
  Array('Heartland Farms','(626) 923-3220','http://www.sunkistjuice.com','ruth.clinnick@heartlandfarms.com')
);
// 'nl' = not licensed product
var selectedToInfo = new Array('nl',0,'nl','nl','nl',3,'nl',5,5,5,'nl','nl',5,'nl','nl','nl','nl','nl',6,2,'nl');

function productsSelected(sel,f){ 
	var PRODUCT_SELECT_INDEX = 1;
	
	if(sel==PRODUCT_SELECT_INDEX) {
		document.getElementById('product_label').style.display='block';
		document.getElementById('product_select').style.display='block';
		
		// when the user select product as a cateogory
		// the subselect that is reveled is mandatory.
		var req = Array('Product','Product');
		reqFields.push(req);
	} else {
		document.getElementById('product_label').style.display='none';
		document.getElementById('product_select').style.display='none';
		
		// remove sub-select from required
		if(reqFields[reqFields.length-1][0]=='Product'){
			reqFields.pop();
		}
	}
	
	// Tell amail which internal soj to use
	
	var productValue = f.Subject[sel].value;
	f.SendInternalOnJoin.value="forms/SGI/contact_licensed_internal_" + productValue + ".txt" ;
	f.ForceSendInternalOnJoin.value="forms/SGI/contact_licensed_internal_" + productValue + ".txt" ;

}
function productSubSelected(sel,f){
	LicProdInfoIndex = selectedToInfo[sel];
	
	// if the selected index is one that we have information for then populate the data.
	if(LicProdInfoIndex != 'nl'){
		f.LicCompany.value=LicProdInfo[LicProdInfoIndex][0];
		f.LicPhone.value=LicProdInfo[LicProdInfoIndex][1];
		f.LicUrl.value=LicProdInfo[LicProdInfoIndex][2];
		f.LicContactEmail.value=LicProdInfo[LicProdInfoIndex][3];
		f.LicContactCC.value = 'wanthony@sunkistgrowers.com';
	}//wanthony@sunkistgrowers.com
	else {
	    f.LicContactEmail.value = 'wanthony@sunkistgrowers.com';
	}
}

function preVal(frm) {
    if (formVal(frm, frm.EmailAddress.value)) {
        if (confirm("You have selected " + frm.Subject[frm.Subject.selectedIndex].innerHTML + " for a topic.\n  Click okay to send your response.")){
            return true;
        }
    }
    return false;
}


//var scf = $('sunkistcontactform');

//scf.Subject.selectedIndex = 0;
//scf.Product.selectedIndex = 0;
