// used to open new window to get confirmation letter
function newWindow(file,window) {
    msgWindow=open(file,window,'resizable=yes,width=210,height=210');
    if (msgWindow.opener == null) msgWindow.opener = self;

}


//alert on finding all numbers
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
			IsNumber = false;
	}
	return IsNumber;
}


function setfocus(a)
{
	a.focus()
	//a.select()
}

function toggleLayer(whichLayer,turnon)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		if (turnon == "1") 
		{
			style2.display = "block"
		}
		else style2.display = "";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		if (onnoff == "1") style2.display = "block"
		else style2.display = "";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		if (onnoff == "1") style2.display = "block"
		else style2.display = "";
	}
}

function reprDelete(fa,action,reprid)
{// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].ReprID.value = reprid
	document.forms[fa].submit();
}
function listSuppAction(fa,action,EID, SID)
{
	
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].PersonID.value = SID
	document.forms[fa].EventID.value = EID
	document.forms[fa].submit();
}

function listActionx(fa,action, EID)
{
	
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].EventID.value = EID
	if (validEvent(fa,action,document.forms[fa].step.value) == false)
		return false
	document.forms[fa].submit();
}


function listActionzz(fa,action, EID,step)
{
	
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].EventID.value = EID
	document.forms[fa].step.value = step
	document.forms[fa].nextstep.value = step
	document.forms[fa].submit();
}


function reprAction(fa,action)
{
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].submit();
}

function calAction(fa,action, sort, page)
{
	
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].sort.value = sort
	document.forms[fa].page.value = page
	
	document.forms[fa].submit();
}

// used by admin function to change org ID
function listActionChgID(fa,action, EID,ID, step)
{
		
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].EventID.value = EID
	document.forms[fa].EventID.value = ID
	document.forms[fa].step.value = step
	document.forms[fa].submit();
}



function listAction(fa,action, EID, step)
{
		
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].EventID.value = EID
	
	document.forms[fa].step.value = step
	document.forms[fa].submit();
}

function admintAction(fa,action,org,  EID, step)
{
	//alert( "document.forms[fa].loginType = " + document.forms[fa].loginType.value )
	// type of event required	
	if (document.forms[fa].loginType.value == "NGOentity" )
	{
		//	alert( "here org = " + org )
		document.forms[fa].loginID.value = org
		document.forms[fa].orgID.value = org
		// alert( "here org = " + org )
	}
	else if  (document.forms[fa].loginType.value == "UNentity" )
	{
		//alert( "UN here org = " + org )
		document.forms[fa].UNloginID.value = org
		document.forms[fa].UNorgID.value = org
		//alert( "UN here org = " + org )
	}
	
	//document.forms[fa].ID.value = org
	document.forms[fa].action.value = action
	document.forms[fa].EventID.value = EID
	
	document.forms[fa].step.value = step
	document.forms[fa].submit();
}

function menuAction(fa,action)
{
	
	// type of event required	
	document.fa.action.value = action
	document.fa.submit();
}


function saveOrg(fa,action)
{
	
	// type of event required	
	document.forms[fa].action.value = action	
	
	// Org Contact first name validation
	if (trim(document.forms[fa].Cont1stName.value) == "") 
	{
		alert("Please enter your organization's main contact's FIRST NAME, before saving.")
		setfocus(document.forms[fa].Cont1stName)
		document.forms[fa].Cont1stName.select()
		return false
	}
	// Org Contact last name validation
	if (trim(document.forms[fa].ContLastName.value) == "") 
	{
		alert("Please enter your organization's main contact's LAST NAME, before saving.")
		setfocus(document.forms[fa].ContLastName)
		document.forms[fa].ContLastName.select()
		return false
	}
/*	// Org Contact Street Address
	if (trim(document.forms[fa].OrgMailAddress.value) == "") 
	{
		alert("Please enter your Organization's Address, before saving.")
		setfocus(document.forms[fa].OrgMailAddress)
		document.forms[fa].OrgMailAddress.select()
		return false
	}
	// Org Contact country
	if (document.forms[fa].OrgMailCountry.options[document.forms[fa].OrgMailCountry.selectedIndex].value == 0)
	{
		alert("Please select your Orgnaization's Country Mailing Address, before moving to the next step.")
		document.forms[fa].OrgMailCountry.focus()
		return false
	}
	// org country hpone code
	if (trim(document.forms[fa].OrgPhoneCode.value) == "") 
	{
		alert("Please enter your organization's Internnational & City phone code number.")
		setfocus(document.forms[fa].OrgPhoneCode)
		document.forms[fa].OrgPhoneCode.select()
		return false
	}
	else if (!isValidPhoneNumber(trim(document.forms[fa].OrgPhoneCode.value))) 
	{
		alert("Please enter your organization's PHONE country code number. \n Only numbers plus the following characters are allowed '(',')' and '-'")
		setfocus(document.forms[fa].OrgPhoneCode)
		document.forms[fa].OrgPhoneCode.select()
		return false
	}
	// org phone number
	if (trim(document.forms[fa].OrgPhone.value) == "")
	{
		alert("Please enter your organization's PHONE number. \n Only numbers plus the following characters are allowed '(',')' and '-'")
		setfocus(document.forms[fa].OrgPhone)
		document.forms[fa].OrgPhone.select()
		return false
	}
	else if (!isValidPhoneNumber(trim(document.forms[fa].OrgPhone.value))) 
	{
		alert("Please enter your organization's PHONE number. \n Only numbers plus the following characters are allowed '(',')' and '-'")
		setfocus(document.forms[fa].OrgPhone)
		document.forms[fa].OrgPhone.select()
		return false
	}
	// org fax county code number
	if (trim(document.forms[fa].OrgFaxCode.value) == "") 
	{
		alert("Please enter your organization's FAX Country Code number.")
		setfocus(document.forms[fa].OrgFaxCode)
		document.forms[fa].OrgFaxCode.select()
		return false
	}
	else if (!isValidPhoneNumber(trim(document.forms[fa].OrgFaxCode.value))) 
	{
		alert("Please enter your organization's FAX Country Code number.\n Only numbers plus the following characters are allowed '(',')' and '-'")
		setfocus(document.forms[fa].OrgFaxCode)
		document.forms[fa].OrgFaxCode.select()
		return false
	}
	// orf fax number
	if (trim(document.forms[fa].OrgFax.value) == "") 
	{
		alert("Please enter your organization's FAX number.")
		setfocus(document.forms[fa].OrgFax)
		document.forms[fa].OrgFax.select()
		return false
	}
	else if (!isValidPhoneNumber(trim(document.forms[fa].OrgFax.value))) 
	{
		alert("Please enter your organization's FAX number.\n Only numbers plus the following characters are allowed '(',')' and '-'")
		setfocus(document.forms[fa].OrgFax)
		document.forms[fa].OrgFax.select()
		return false
	}
	//if (trim(document.forms[fa].OrgEmail.value) != "") 
	//{
		if (!isValidEmail(document.forms[fa].OrgEmail.value)) 	
		{
			alert("Please enter your organization's correct e-mail address.")
			setfocus(document.forms[fa].OrgEmail)
			document.forms[fa].OrgEmail.select()
			return false
		}
	//}
	if (!document.forms[fa].ScopeLocal.checked && 
		!document.forms[fa].ScopeNational.checked &&
		!document.forms[fa].ScopeRegional.checked &&
		!document.forms[fa].ScopeInternational.checked ) 
	{
			alert("Please check your Organization Scope of Coverage.")
			setfocus(document.forms[fa].ScopeLocal)
			document.forms[fa].ScopeLocal.select()
			return false
	}
	if (trim(document.forms[fa].ScopeCountries.value) == "") 
	{
		alert("Please enter in the Country or Countries that organization coverage is in.")
		setfocus(document.forms[fa].ScopeCountries)
		document.forms[fa].ScopeCountries.select()
		return false
	}
	
	
	if (!document.forms[fa].ActivityA.checked && 
		!document.forms[fa].ActivityB.checked &&
		!document.forms[fa].ActivityC.checked &&
		!document.forms[fa].ActivityD.checked &&		
		!document.forms[fa].ActivityE.checked ) 
	{
			alert("Please check the Type of activity that your Organization is engaged in.")
			setfocus(document.forms[fa].ActivityA)
			document.forms[fa].ActivityA.select()
			return false
	}

if (!document.forms[fa].LangEnglish.checked && 
		!document.forms[fa].LangFrench.checked &&
		!document.forms[fa].LangSpanish.checked &&
		!document.forms[fa].LangArabic.checked &&		
		!document.forms[fa].LangChinese.checked &&				
		!document.forms[fa].LangRussian.checked &&
		trim(document.forms[fa].LangOther.value) == "") 
	{
			alert("Please check the Working Language(s) of your Organization.")
			setfocus(document.forms[fa].LangEnglish)
			document.forms[fa].LangEnglish.select()
			return false
	}

  */
	document.forms[fa].submit();
}

// to date stamp a Side Evnet for scheduling.
// used by actSubmitEvent.asp
function dateStampIt(fa,action, EID)
{
	
	// 
	 var fRet; 
	 msg = 'Please note although you will still be able to\n'
	 msg = msg +  '  1. Add Speakers, Support Staff & Invitees\n'
	 msg = msg +  '  2. Make additional requests for Technicial Equipment\n'
	 msg = msg +  'You will NOT be able to change the following for this Parallel Event on-line:\n\n'
 	 msg = msg +  'The Title\n'
  	 msg = msg +  'The Type of Side Event selected\n'
  	 msg = msg +  'The Dates and Duration selected\n'
	 msg = msg +  'To change these details, you may send an email to csw53@un.org with the change requests\n'
	 msg = msg + 'Press [OK] if you want to continue to submit\nthis Side Event for scheduling'
     
	 fRet = confirm(msg); 
	 if (fRet == true)
 	  {	
		document.forms[fa].action.value = action
		document.forms[fa].EventID.value = EID
		document.forms[fa].submit();
	  }
}

function stepAction(fa,action, EID, level)
{
	var x =0 
	// type of event required	
	document.forms[fa].action.value = action
	document.forms[fa].EventID.value = EID
	//
	//alert ("level="+ level+"\nstep=" + document.forms[fa].step.value +"\nnextstep="+document.forms[fa].nextstep.value  )
	if (level == 'previous')
		document.forms[fa].nextstep.value = document.forms[fa].step.value - 1
	if (level == '1')
		document.forms[fa].nextstep.value = 1		
	if (level == '2')
		document.forms[fa].nextstep.value = 2
	if (level == '3')
		document.forms[fa].nextstep.value = 3
	if (level == '4')
		document.forms[fa].nextstep.value = 4
	if (level == '5')
		document.forms[fa].nextstep.value = 5
	// new event	
	if (level=='next' & document.forms[fa].step.value == 1)	
	{
		document.forms[fa].nextstep.value = 2	
		if (validEvent(fa,action,1) == false)
			return false	
	}
	else if (level=='next' & document.forms[fa].step.value == 2)	
	{
		document.forms[fa].nextstep.value = 3
		if (validEvent(fa,action,2) == false)
			return false
	}
	else if (level=='next' & document.forms[fa].step.value == 3)	
	{
		//alert ( document.forms[fa].loginType.value)
		// handles NGO - not seeing step 4 - equipment
		if (document.forms[fa].loginType.value == 'NGOentity') 
			document.forms[fa].nextstep.value = 5
		else
			document.forms[fa].nextstep.value = 4
	}
	else if (level=='next' & document.forms[fa].step.value == 4)	
	{
		document.forms[fa].nextstep.value = 5
		if (validEvent(fa,action,4) == false)
			return false
	}
	else if (level=='next' & document.forms[fa].step.value == 5)	
	{
		document.forms[fa].nextstep.value = 5
	}
	//alert("Next Step is." + document.forms[fa].nextstep.value)
	//alert("Next action is." + action)
		
	document.forms[fa].submit();
}


function validEvent(fa,action,step)
{
	var typeofEvent = 0;
	var whichitem = 0, selectit=0;
	// STEP 1: Event Title & Type of Event 
	if (step == 1)
	{
		// allow only if not already submitted
		if (document.forms[fa].submitted.value == 0)
		{
		// type of event required, what one selected
			while (whichitem < document.forms[fa].rEvent.length) 
			{
				if (document.forms[fa].rEvent[whichitem].checked) 
				{
					typeofEvent = 1;
					selectit = whichitem;				
				}
			whichitem++;
			}
			
			if (typeofEvent== 0) 
			{
				alert("Please select the [Type of Side Event] you want to setup, before moving to the next step.")
				document.forms[fa].rEvent[0].focus()
				return false
			} 
			else if (document.forms[fa].rEvent[selectit].value == 5)
			{
				if (trim(document.forms[fa].tEventOther.value) == "") 
				{
					alert("Please specify what type of event you want to setup, before moving to the next step.")
					setfocus(document.forms[fa].tEventOther)
					return false
				}
			}
		}
		// event title -required
		if (trim(document.forms[fa].tEventTitle.value) == "") 
		{
			alert("Please enter the [Title of the Side Event] you want to setup, before moving to the next step.")
			setfocus(document.forms[fa].tEventTitle)
			return false
		}
		if (trim(document.forms[fa].iPaticipants.value) != "") 
			 if (!IsNumeric(trim(document.forms[fa].iPaticipants.value)))
			 {
				alert("Please enter only numbers in the [Number of Participants expected], before moving to the next step.")
				setfocus(document.forms[fa].iPaticipants)
				return false
			 }	
	}
	//  STEP 2: Contact Information
	else if (step == 2)
	{	
		// ensure if email address is added in form that it is in the correct format
		if (trim(document.forms[fa].tContactEmail.value) != "")  	
			if (!isValidEmail(document.forms[fa].tContactEmail.value)) 
			{
			alert("Please ensure your Primary Contact's e-mail address for the Side Event you would like \nto add is a VALID address, before submitting this request.")
			setfocus(document.forms[fa].tContactEmail)
			document.forms[fa].tContactEmail.select()
			return false
			}
		// ensure if phone added it contains number or "()-" only
		if (trim(document.forms[fa].tContactPhone.value) != "") 
			if (!isValidPhoneNumber(document.forms[fa].tContactPhone.value)) 
			{
			alert("Please ensure your Primary Contact's phone number for the Side Event you would like \nto add is a correct, before submitting this request.\n Please only numbers plus the following characters are allowed '(',')' and '-'")
			setfocus(document.forms[fa].tContactPhone)
			document.forms[fa].tContactPhone.select()
			return false
			}
		if (trim(document.forms[fa].tContactFax.value) != "") 
			if (!isValidPhoneNumber(document.forms[fa].tContactFax.value)) 
			{
			alert("Please ensure your Primary Contact's fax number for the Side Event you would like \nto add is a correct, before submitting this request.\n Only numbers plus the following characters are allowed '(',')' and '-'")
			setfocus(document.forms[fa].tContactFax)
			document.forms[fa].tContactFax.select()
			return false
			}
		// ensure if email address is added in form that it is in the correct format
		if (trim(document.forms[fa].tBackupEmail.value) != "")  	
			if (!isValidEmail(document.forms[fa].tBackupEmail.value)) 
			{
			alert("Please ensure your Backup Contact's e-mail address for the Side Event you would like \nto add is a VALID address, before submitting this request.")
			setfocus(document.forms[fa].tBackupEmail)
			document.forms[fa].tBackupEmail.select()
			return false
			}
		if (trim(document.forms[fa].tBackupPhone.value) != "") 
			if (!isValidPhoneNumber(document.forms[fa].tBackupPhone.value)) 
			{
			alert("Please ensure your Backup Contact's phone number for the Side Event you would like \nto add is a correct, before submitting this request.\n Only numbers plus the following characters are allowed '(',')' and '-'")
			setfocus(document.forms[fa].tBackupPhone)
			document.forms[fa].tBackupPhone.select()
			return false
			}
		if (trim(document.forms[fa].tBackupFax.value) != "") 
			if (!isValidPhoneNumber(document.forms[fa].tBackupFax.value)) 
			{
			alert("Please ensure your Backup Contact's fax number for the Side Event you would like \nto add is a correct, before submitting this request.\n Only numbers plus the following characters are allowed '(',')' and '-'")
			setfocus(document.forms[fa].tBackupFax)
			document.forms[fa].tBackupFax.select()
			return false
			}
	}
	else if (step == 3)
	{
		//alert ("vlaidate step 3")
		
	}
	else if (step == 4 )
	{
		// fi element exists and is not nul it should be a number
		//i1..50
		err = 0
		
		// check if input type text and textarea are empty
		for(var noElement=0;noElement<document.forms[fa].elements.length;noElement++)
		{ 
			var element = document.forms[fa].elements[noElement] 
			if(((element.type == "text")||(element.type == "textarea")) && !element.optional && element.name != "UNAgencyAcc")
			{ 
				if(element.value!=null && trim(element.value) != "" )
				{  
					if (!IsNumeric(element.value))
					{
						alert("Please enter in the quantity of the Technical Equipment you need for this Side Event.\n\n Only numbers are allowed." & element.value)
						
						setfocus(element)
						element.select()
						err = 1 // error found
						break;
					} 
				}
			} 
		} 
		
		if (err == 1) 
			return false
		// check to that N Agnecy requesters have entered thier un account number
		//if (trim(document.forms[fa].orgtype.value) == "Agency")
		//{
		///	if (trim(document.forms[fa].UNAgencyAcc.value) == "")
		//	{
			//	alert("Please enter in the UN account number that will be used to pay for the costs is entered")
			//	setfocus(document.forms[fa].UNAgencyAcc)
			//	document.forms[fa].UNAgencyAcc.select()
			//	return false
		//	}
		//	
	//	}
	}
}

// validate Representative and save
function saveRep()
{
// event Contact first Name Description -required
	if (trim(document.rep.tFN.value) == "") 
	{
	alert("Please enter your Representative's details (First Name), \nbefore saving.")
	setfocus(document.rep.tFN)
	return false
	}
	if (trim(document.rep.tLN.value) == "") 
	{
	alert("Please enter your Representative's details (Last Name), \nbefore saving.")
	setfocus(document.rep.tLN)
	return false
	}
	
	if (trim(document.rep.tOrg.value) == "") 
	{
	alert("Please enter your Representative's details (Orgnanization Name), \nbefore saving.")
	setfocus(document.rep.tOrg)
	return false
	}
	
		
	document.rep.submit();
}

	
function saveSupp()
{
	// type of event required
//	if (document.supp.sTitle.selectedIndex == 0) 
	//{
//	alert("Please select the Title of the suport staff you want to add, before \nsubmitting this request.")
	//setfocus(document.supp.sTitle)
//	return false

// Loop from zero to the one minus the number of radio button selections
var radio_choice = false;

	for (counter = 0; counter < document.supp.rdStaff.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.supp.rdStaff[counter].checked)
		radio_choice = true; 
	}
	if (!radio_choice)
	{
	// If there were no selections made display an alert box 
	alert("Please select the Side Event Attendee Type.")
	document.supp.rdStaff[1].focus()
	return (false);
	}
	// event Contact first Name Description -required
	if (trim(document.supp.tFN.value) == "") 
	{
	alert("Please enter your Support Staff's details (First Name) for the Side Event, \nbefore submitting this request.")
	setfocus(document.supp.tFN)
	return false
	}
	if (trim(document.supp.tLN.value) == "") 
	{
	alert("Please enter your Support Staff's details (Last Name) for the Side Event, \nbefore submitting this request.")
	setfocus(document.supp.tLN)
	return false
	}
	
	if (trim(document.supp.tOrg.value) == "") 
	{
	alert("Please enter your Support Staff's details (Orgnanization Name) for the Side Event, \nbefore submitting this request.")
	setfocus(document.supp.tOrg)
	return false
	}
	
		
	document.supp.submit();
}


// remove spaces
function trim(a)
{
	var start
	var end
	var len = a.length
	start = 0
	for(i=0;i<len;++i)
	{
  		if ((a.charAt(i)==" ") || (a.charAt(i)=="\n"))
		{
			start = start +1			
		}
		else break;
	}
	a = a.substring(start,len)
	len = a.length
	end = len
	for(i=len;i>0;++i)
	{
  		if ((a.charAt(i)==" ") || (a.charAt(i)=="\n"))
		{
			end = end -1			
		}
		else break;
	}
	a = a.substring(0,end)			
	return a;
}




//function isValidEmail(str) 
//{
 //'  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
//'}


function isValidEmail(str) 
{

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true					
}


function isValidPhoneNumber(str) 
{
	//Returns true if value is a number or is NULL
	//otherwise returns false   
	var object_value = str;
	var err = 0
	
	if (object_value.length == 0)
		return false;
	
	//Returns true if value is a number defined 
	var number_format = "()- 0123456789";
	var check_char;
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 0; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
	}
	return true;

}


// validation for "forgot login form"
function validLostLogin(fa)
{
	if (trim(document.forms[fa].LemailAddr.value) == "" && trim(document.forms[fa].Lid.value) == "") 
	{
				alert("You must enter in either you orgnaization's ID number. \nOr the correct organization's main contact e-mail address, before the system send you the information.")
				setfocus(document.forms[fa].Lid)
				document.forms[fa].Lid.select()
				return false
	}
	if (trim(document.forms[fa].Lid.value) != "") 
		 if (!IsNumeric(trim(document.forms[fa].Lid.value)))
		 {
			alert("Please enter only numbers in the [Login ID], before submitting.")
			setfocus(document.forms[fa].Lid)
			document.forms[fa].Lid.select()
			return false
		 }	
		 else document.forms[fa].LemailAddr.value = "" 
		 
	// ensure if email address is added in form that it is in the correct format
	if (trim(document.forms[fa].LemailAddr.value) != "")  	
		if (!isValidEmail(document.forms[fa].LemailAddr.value)) 
		{
			alert("Please ensure your orgnaization's Primary Contact's e-mail address is correctly entered.\n")
			setfocus(document.forms[fa].LemailAddr)
			document.forms[fa].LemailAddr.select()
			return false
		}
		else document.forms[fa].Lid.value = "" 
		
	document.forms[fa].submit();
}

function roundedCorners() {
  var divs = document.getElementsByTagName('div');
  var rounded_divs = [];
  for (var i = 0; i < divs.length; i++) {
    if (/\brounded\b/.exec(divs[i].className)) {
      rounded_divs[rounded_divs.length] = divs[i];
    }
  }
  for (var i = 0; i < rounded_divs.length; i++) {
    var original = rounded_divs[i];
    /* Make it the inner div of the four */
    original.className = original.className.replace('rounded', '');
    /* Now create the outer-most div */
    var tr = document.createElement('div');
    tr.className = 'rounded2';
    /* Swap out the original (we'll put it back later) */
    original.parentNode.replaceChild(tr, original);
    /* Create the two other inner nodes */
    var tl = document.createElement('div');
    var br = document.createElement('div');
    /* Now glue the nodes back in to the document */
    tr.appendChild(tl);
    tl.appendChild(br);
    br.appendChild(original);
  }
}
window.onload = roundedCorners;

