function submitPayPal()
{ // send paypalForm details to PayPal
	if (document.paypalForm.paymenttype[0].checked==true)
	{ // only do this if paypal payment type is selected
		document.paypalForm.submit();
		return;
	}
}

function submitPayment()
{ // this function has been tested without javascript on Opera and works OK
	
	if (!checkForm())
	{
		return false;
	}
	else if (document.paypalForm.paymenttype[0].checked==true)
	{
	// send profileForm details to VLV the paypalForm details to PayPal	
		document.profileForm.redirect.value="http://www.vlv.org.uk/pages/form-sent.shtml";
		document.profileForm.paymenttype.value="paypal";
		document.profileForm.submit();
		document.paypalForm.submit();
		return;
	}
	else
	{
	// alert("function called vlv");
	// send profileForm details to VLV
		document.profileForm.redirect.value="http://www.vlv.org.uk/pages/vlvform-sent.shtml";
		document.profileForm.paymenttype.value="offline";
		document.profileForm.submit();
		return;
	}
}


function addup()
{
 var p = document.profileForm.amount1.value;
 var q = document.profileForm.amount2.value;
 var r = document.profileForm.amount3.value;
 var s = document.profileForm.amount4.value;
 document.profileForm.amount0.value=eval(p) +eval(q) + eval(r) + eval(s);
 document.paypalForm.amount.value = document.profileForm.amount0.value;
}

function changeAmountb()
{
 if(testIsValidObject(document.profileForm.conference1)==true)
 { 
	  if (document.profileForm.conference1.checked == true) 
 	 	{
		for (i=0;i<document.profileForm.bookingType1.length;i++)
			{	
				if (document.profileForm.bookingType1[i].checked == true)
				{ 
   				document.profileForm.amount1.value = document.profileForm.bookingType1[i].value;
				}
			}
		}
 	 else
	 {
	 document.profileForm.amount1.value = 0;
	 for (i=0;i<document.profileForm.bookingType1.length;i++)
		{
		 	document.profileForm.bookingType1[i].checked = false;
		}
	 }
  }
  if( testIsValidObject(document.profileForm.conference2)==true)
  {
	  if (document.profileForm.conference2.checked == true) 
 	 	{
		for (i=0;i<document.profileForm.bookingType2.length;i++)
			{	
				if (document.profileForm.bookingType2[i].checked == true)
				{ 
   				document.profileForm.amount2.value = document.profileForm.bookingType2[i].value;
				}
			}
		}
 	 else 
	 { 
	 document.profileForm.amount2.value = 0;
	 for (i=0;i<document.profileForm.bookingType2.length;i++)
		{
		 	document.profileForm.bookingType2[i].checked = false;
		}
	 }
  }
 
 if(testIsValidObject(document.profileForm.conference3)==true)
 { 
	  if (document.profileForm.conference3.checked == true) 
 	 	{
		for (i=0;i<document.profileForm.bookingType3.length;i++)
			{	
				if (document.profileForm.bookingType3[i].checked == true)
				{ 
   				document.profileForm.amount3.value = document.profileForm.bookingType3[i].value;
				}
			}
		}
 	 else 
	 { 
	 document.profileForm.amount3.value = 0;
	 for (i=0;i<document.profileForm.bookingType3.length;i++)
		{
		 	document.profileForm.bookingType3[i].checked = false;
		}
	 }
  }
  if(testIsValidObject(document.profileForm.conference4)==true)
  {
	  if (document.profileForm.conference4.checked == true) 
 	 	{
		for (i=0;i<document.profileForm.bookingType4.length;i++)
			{	
				if (document.profileForm.bookingType4[i].checked == true)
				{ 
   				document.profileForm.amount4.value = document.profileForm.bookingType4[i].value;
				}
			}
		}
 	 else 
	 {
	 document.profileForm.amount4.value = 0;
	 for (i=0;i<document.profileForm.bookingType4.length;i++)
		{
		 	document.profileForm.bookingType4[i].checked = false;
		}
	 }
  }
addup();
}
function testIsValidObject(objToTest) 
{
	if (objToTest == null || objToTest == undefined) 
	{
	return false;
	}
	return true;
}
function getStyleObject(objectId) 
{
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) 
	{
		return document.getElementById(objectId).style;
    } 
	else if (document.all && document.all(objectId)) 
	{
		return document.all(objectId).style;
    } 
	else if (document.layers && document.layers[objectId]) 
	{
		return document.layers[objectId];
    } 
	else 
	{
	return;
    }
} 
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
		( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}
function setupForms(name)
{
	document.paypalForm.amount.disabled = false;
    if (name) getValues(name);
}
function setupForm() {
    if (vlvProfile) getValues(vlvProfile);
    if (vlvProfile2) getValues(vlvProfile2);
}

function getValues(string) {
    getValue(string,"titlename",  document.profileForm.titlename,  "text");    
    getValue(string,"fullname",   document.profileForm.fullname,   "text");
    getValue(string,"position",  document.profileForm.position,  "text");    
    getValue(string,"organisation",  document.profileForm.organisation,  "text");    
    getValue(string,"address1",  document.profileForm.address1,  "text");    
    getValue(string,"address2",  document.profileForm.address2,  "text");    
    getValue(string,"address3",  document.profileForm.address3,  "text");    
    getValue(string,"address4",  document.profileForm.address4,  "text");    
    getValue(string,"address5",  document.profileForm.address5,  "text");    
    getValue(string,"phone1",  document.profileForm.phone1,  "text");    
    getValue(string,"phone2",  document.profileForm.phone2,  "text"); 
    getValue(string,"phone3",  document.profileForm.phone3,  "text");  
    getValue(string,"phone4",  document.profileForm.phone4,  "text");        
    getValue(string,"email",  document.profileForm.email,  "text");         
    getValue(string,"findout",  document.profileForm.findout,  "text");   

}

function replace(string,text,by) {
    var i = string.indexOf(text);
    var newstr = '';
    if ((!i) || (i == -1)) return string;
    newstr += string.substring(0,i) + by;

    if (i+text.length < string.length)
        newstr += replace(string.substring(i+text.length,string.length),text,by);
    
    return newstr;
}

function onCheck(string) { if (string == "on") return true; return false; }

function getValue(string,elementName,object,elementType) {

    var startPos = string.indexOf(elementName + "=");
    
    if (startPos > -1) {
        startPos = startPos + elementName.length + 1;
        var endPos = string.indexOf("&",startPos);
        if (endPos == -1) endPos = string.length;

        var elementValue = unescape(string.substring(startPos,endPos));
        
        if (elementType == "text")     object.value = elementValue;
        if (elementType == "password") object.value = elementValue;
        if (elementType == "select")   object.selectedIndex = elementValue;
        if (elementType == "checkbox") object.checked = onCheck(elementValue);
        if (elementType == "radio")    object[elementValue].checked = true;
    }
}