function rastita(){

var joo = document.forms[0].emails_yes.checked
var ei = document.forms[0].emails_no.checked

if (joo != true && ei != true) 
	{
	alert('Please check one of the required fields');
	document.forms[0].emails_yes.focus();
	}

}

//<!--
function Product(prodcode,prodname,prodpath) 
{
	this.prodcode = prodcode;
	this.prodname = prodname;
	this.prodpath = prodpath;
}

function SetPath(){
//käsittele urli
var mystr = document.location.search;
var mypath = "empty.htm"
	mystr = mystr.substring(9,mystr.length);
var myproduct = ""

//tuote array
var num_products =22;
var library = new Object();
library[0] = new Product("empty","empty","");
library[1] = new Product("adrem_netcrunch","Adrem NetCrunch","");
library[2] = new Product("adrem_server_manager","Adrem Server Manager","");
library[3] = new Product("adrem_sfconsole","Adren sfConsole","");
library[4] = new Product("application_control_solution","Altiris Application Control Solution","");
library[5] = new Product("client_management_suite","Altiris Client Management Suite","");
library[6] = new Product("deployment_solution","Altiris Deployment Solution","");
library[7] = new Product("endpoint_security_solution","Altiris Endpoint Security Solution","");
library[8] = new Product("inventory_solution","Altiris Inventory Solution","");
library[9] = new Product("helpdesk_solution","Altiris Helpdesk Solution","");
library[10] = new Product("local_security_solution","Altiris Local Security Solution","");
library[11] = new Product("patch_management_solution","Altiris Patch Management Solution","");
library[12] = new Product("altiris_quarantine_solution","Altiris Quarantine Solution","");
library[13] = new Product("recovery_solution","Altiris Recovery Solution","");
library[14] = new Product("securityexpressions","Altiris SecurityExpressions","");
library[15] = new Product("server_management_suite","Altiris Server Management Suite","");
library[16] = new Product("service_asset_management_suite","Altiris Service & Asset Management Suite","");
library[17] = new Product("software_delivery_solution","Altiris Software Delivery Solution","");
library[18] = new Product("adminstudio","AdminStudio","");
library[19] = new Product("wise_package_studio","Wise PackageStudio","");
library[20] = new Product("adrem_itools","Adrem iTools","");
library[21] = new Product("adrem_snmp_manager","Adrem SNMP manager","");



	//library.length = num_products;

	for (var i = 0; i < num_products ; i++) 	{

		if (library[i].prodcode == mystr) 
			{ 
			  //mypath = library[i].prodpath ;
			  mypath = "download2.htm?product=" + library[i].prodcode ;  			  
			  myproduct = library[i].prodname;	
			  
				//var option0 = new Option(library[i].prodname, "")
				//eval("document.DownloadForm.PRODUCT.options[0]=option" + 0)
				//document.DownloadForm.PRODUCT.options[0].selected=true
				
			}
	}

// set values

document.forms[0].redirect.value = "http://www.ubm-europe.com/downl/" + mypath;
document.forms[0].PRODUCT.value = myproduct;
document.forms[0].subject.value = myproduct + " Download";	


}
// -->

//Begin
function SetEmail() {

var mailstr = document.forms[0].recipient.value
var prodname = document.forms[0].PRODUCT.value
var strEur = "ubm-europe.com"
var strFin = "ubm.fi"
var strSwi = "ubm.ch"
var strCorne = "7corne.meulendijks" + "@" + strEur
var strTimo = "timo.hamalainen" + "@" + strEur
var strUno = "uno.kurvet" + "@" + strFin
var strSwe = "kari.mattila" + "@" + strFin
var strFra = "ines.jarvsoo" + "@" + strEur

//if (prodname == "Group Policy Guardian" || prodname == "Shavlik HFNetChkPro" || prodname == "Group Policy Administrator" || prodname == "AdRem NetCrunch" //|| prodname == "AdRem Server Manager" || prodname == "AdRem sfConsole" || prodname == "FAZAM 2000" || prodname == "FAZAM Auditing") {
//    mailstr = mailstr + ",tt@tt.tt"; }

var country = ""
country = document.forms[0].COUNTRY.value

//if (country == "SOUTH AFRICA" || country == "UNITED KINGDOM" || country == "AUSTRALIA" || country == "UNITED STATES") {
//	mailstr = mailstr + ",edwardr@" + strEur; }	

//if (country == "SWITZERLAND" ) {
//	mailstr = mailstr + ",downloads@" + strSwi; }	

//if (country == "FRANCE" ) {
//	mailstr = mailstr + "," + strUno; }	
	
if (country == "SWEDEN" ) {
	mailstr = mailstr + "," + strSwe + "ubm.fi"; }	

//if (country == "BELARUS" || country == "BULGARIA" || country == "CROATIA" || country == "CZECH REBUPLIC" || country == "GEORGIA") {
//	mailstr = mailstr + "," + strUno; }	

//if (country == "ESTONIA" || country == "HUNGARY" || country == "LATVIA" || country == "LITHUANIA" || country == "ROMANIA" || country == "RUSSIAN FEDERATION") {
//	mailstr = mailstr + "," + strUno; }	

//if (country == "SLOVAKIA" || country == "SLOVENIA" || country == "UKRAINE" || country == "YUGOSLAVIA" || country == "ICELAND") {
//	mailstr = mailstr + "," + strUno; }	


document.forms[0].recipient.value = mailstr;
document.forms[0].sender_name.value = document.forms[0].FIRST_NAME.value + " " + document.forms[0].LAST_NAME.value
document.forms[0].sender_email.value = document.forms[0].EMAIL.value


}
//End



//\/\/\/\/\/\/\/\/\  ** Here is the CookieName */\/\/\/\/\/\/\

TheCookieName = 'UBM_Form_Cookie';
numDays       = 365;  //Days 'till Cookie expires.(eg. 183 days = 6 months)

// Write One Big Cookie with all the values in it.
function WriteOneBigCookie () {
   var expire = new Date ();
   expire.setTime (expire.getTime() + (numDays * 24 * 3600000)); //6 months from now!
//                                     (dd) (hr) (ms in hr)
   var WholeCookie = expire ;

//Text entry

   WholeCookie = WholeCookie + '`' + document.DownloadForm.COMPANY.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.FIRST_NAME.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.LAST_NAME.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.TITLE.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.ADDRESS1.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.ADDRESS2.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.ZIP.value;
   WholeCookie = WholeCookie + '`' + document.DownloadForm.CITY.value;   
   WholeCookie = WholeCookie + '`' + document.DownloadForm.PHONE1.value;  
   WholeCookie = WholeCookie + '`' + document.DownloadForm.PHONE2.value;   
   WholeCookie = WholeCookie + '`' + document.DownloadForm.EMAIL.value;
   
  
if (document.DownloadForm.TOTALPCS != null) 
{   
   WholeCookie = WholeCookie + '`' + document.DownloadForm.TOTALPCS.value;
}

//Select Form (One entry)
   WholeCookie = WholeCookie + '`' + document.DownloadForm.COUNTRY.selectedIndex; 

//CheckBoxes
if (document.DownloadForm.emails_yes != null) 
{
   WholeCookie = WholeCookie + '`' + document.DownloadForm.emails_yes.checked;
   //WholeCookie = WholeCookie + '`' + document.DownloadForm.emails_no.checked;
}


//Radio button
//   WholeCookie = WholeCookie + '`' + setChkIndx(document.DownloadForm.send_emails);



//Put cookie in the Oven Bake 'till done.
  document.cookie = TheCookieName +"=" + escape (WholeCookie) +
                    "; expires=" + expire.toGMTString() ;

// alert('Your Personal information has been stored, ready for the next time you use this page.');
}


function UpdateForm () {

//Get the Cookievalue then use a Cookie Cutter to slice it up in an array.
MakeCookieArray(GetCookie(TheCookieName));

//FORM action 
//  document.DownloadForm.action = 'mailto:inglis@maxcomp.com,' + ckArray[5];
//    document.DownloadForm.action = 
//	'mailto:test@envmed.rochester.edu,' 
//	+ document.DownloadForm.EMAIL.value 
//	+ '?Subject=JavaScript Cookie Form V2';

//TEXT input Form

//alert('ckArray: ' + ckArray[0]);
 if (ckArray[0] != "*") {
//  document.DownloadForm.ExpDate.value  = ckArray[0];

  document.DownloadForm.COMPANY.value   = ckArray[1];
  document.DownloadForm.FIRST_NAME.value  = ckArray[2];
  document.DownloadForm.LAST_NAME.value  = ckArray[3];
  document.DownloadForm.TITLE.value = ckArray[4];
	document.DownloadForm.ADDRESS1.value = ckArray[5];
	document.DownloadForm.ADDRESS2.value = ckArray[6];
	document.DownloadForm.ZIP.value = ckArray[7];
	document.DownloadForm.CITY.value = ckArray[8];   
	document.DownloadForm.PHONE1.value = ckArray[9]
	document.DownloadForm.PHONE2.value = ckArray[10];   
	document.DownloadForm.EMAIL.value = ckArray[11];
if (document.DownloadForm.TOTALPCS != null)
 {   
	document.DownloadForm.TOTALPCS.value = ckArray[12];
 }

//Select Form (One entry)
//  if (ckArray[13] != "*" )  
//	{
        document.DownloadForm.COUNTRY.selectedIndex = ckArray[13];
//    }
        
//CheckBoxes
if (document.DownloadForm.emails_yes != null) 
{
  document.DownloadForm.emails_yes.checked = (ckArray[14]=='true')? true:false ;
  //document.DownloadForm.emails_no.checked = (ckArray[15]=='true')? true:false ;
}

//RadioButton
//  if (ckArray[14] != "*" )  
//  {
//        document.DownloadForm.send_emails[ckArray[14]].checked = true;
//  }


 }
}

//Get and return the index of THE checked radio button
 function setChkIndx(theName) { 
   for (var i=0; i < theName.length; i++ ) {
   if (theName[i].checked == true) return i; 
   }
 return "*"; // One item is always supposed to be checked but... 
 }

//Find and return list of indexes of *all* the selected MULTIPLE selects. YUCK.
//Return list of indexes, seperated by ",".
 function findChkIndx_MS(theName) { 
 var indxlist = "";
   for (var i=0; i < theName.options.length; i++ ) {
   if (theName.options[i].selected == true) indxlist = indxlist + "," + i; 
   }
 return (indxlist == "")?indxlist = "*":indxlist;
 }

//Use the list to SET all stored MULTIPLE selects.
// Most efficient storage for a very long list, but messy.
// Requires clearing all before loading to get only those checked.
 function setChkIndx_MS(formObj,theList) {
   for (var i=0; i < formObj.options.length; i++) { 
   formObj.options[i].selected = false;} //clear all.
   var ilen = 0;
   while ( ilen < theList.length-1 ) { 
    var indxstart = theList.indexOf(',',ilen);
    if (indxstart == -1) return;

    ilen = theList.indexOf(',',indxstart+1);
    if (ilen == -1) ilen = theList.length;

    //make sure its an integer before using as subscript
    var indx = parseInt(theList.substring(indxstart+1,ilen) ,10);
    formObj.options[indx].selected = true;
   }
 }

//Get the cookie from a list of possible cookies. Honest!
function GetCookie (CookieName) {
  var cname = CookieName + "=";
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + cname.length;
    if (document.cookie.substring(i, j) == cname){
	var leng = document.cookie.indexOf (";", j);
	if (leng == -1) leng = document.cookie.length;
	return unescape(document.cookie.substring(j, leng));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; //thats -1 plus 1, duh.
  }
   return "*";
}

//Set the Cookie with expire date in the past - 2 days to get it for sure.
function DelEatCookie (name) {
  var expire = new Date();
  expire.setTime (expire.getTime() - 2 * 86400001);  //-2 days ago. Stale Cookie
  document.cookie = name + "=*; expires=" + expire.toGMTString();
}

//Parse Big  Cookie. A CookieCutter if you will.
function MakeCookieArray(cookieValue) {
  var i = 0,indx = 0, citemlen =0;
  ckArray = new Array();
   if ( cookieValue == null ) {ckArray[0]= "*";return}//Data has expired or never entered.
   if ( cookieValue == "*"  ) {ckArray[0]= "*";return}//Data has expired or never entered.
  while (citemlen < cookieValue.length) {
    citemlen=(cookieValue.indexOf("`", indx)>0)
	     ?cookieValue.indexOf("`", indx):cookieValue.length;
    ckArray[i]= cookieValue.substring(indx, citemlen); i++;
    indx = citemlen + 1;
  }
}

// end script -->
