//**************************Displaying Div according to the selection ***************************//
//here you place the ids of every element you want.
var ids=new Array('textfield','radio','checkbox','select1','file','text', 'textarea', 'password','select', 'multiselect', 'hidden');
function Submitform(id)
{
	//alert(id);
	var blnSelect = false;
	var blnText = false;
	hideallids(id);
	//document.frmCommon.label.value="";
	//document.frmCommon.instruction.value="";
	if(id=='textfield') 
	
	{
		//alert('hello1');
		showdiv('textfield');
		if (document.frmText.group2[0].checked)
		{
			showdiv('text');
			blnText = true;
		}
		if (document.frmText.group2[1].checked)
		{
			showdiv('textarea');
			blnText = true;
		}
		if (document.frmText.group2[2].checked)
		{
			showdiv('hidden');
			blnText = true;
		}
		if (document.frmText.group2[3].checked)
		{
			showdiv('password');
			blnText = true;
		}
		
		if (blnText == false)
		{
			document.frmSelect.group2[0].checked=true;
			showdiv('text');
		}
	}
	if(id=='text') 
	{
		//alert('hello2');
		showdiv('textfield');
		showdiv('text');
	}
	if(id=='textarea') 
	{
		showdiv('textfield');
		showdiv('textarea');
	}
	if(id=='password') 
	{
		showdiv('textfield');
		showdiv('password');
	}
	if(id=='hidden') 
	{
		showdiv('textfield');
		showdiv('hidden');
	}
	if(id=='select1')
	{
		//alert('hello3');
		showdiv('select1');
		if (document.frmSelect.group3[0].checked)
		{
			document.frmSelect.group3[0].checked=true;
			showdiv('select');
			blnSelect = true;
		}
		if (document.frmSelect.group3[1].checked)
		{
			document.frmSelect.group3[1].checked=true;
			showdiv('multiselect');
			blnSelect = true;
		}
		
		if (blnSelect == false)
		{
			document.frmSelect.group3[0].checked=true;
			showdiv('select');
		}
	}
	if(id=='select') 
	{
		//alert('hello5');
		showdiv('select1');
		showdiv('select');
	}
	if(id=='multiselect') 
	{
		showdiv('select1');
		showdiv('multiselect');
	}
	showdiv(id);
	document.frmCommon.label.focus();
}

function displaycolor(id)
	{
		if(id > 0)
			{
				alert(id);
				document.getElementById(id).style.background='white';
				alert(id);
			}
	}
						
function hideallids(){
	//loop through the array and hide each element by id
	
	for (var i=0;i<ids.length;i++){
		
		hidediv(ids[i]);
	}	
	  
}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';

	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
//********************************************************************************************************//

//*******************Function for adding values from input to table list ********************************//

function IsIDAdded(ID)
{
	//frm = document.controlfieldradio;
	//MyDestinationList = frm.MyDestinationradio;
	//alert(ID);
	var ret=false;
	for (var i=0;i<MyDestinationList.length;i++)
	{
		if (ID==MyDestinationList.options[i].value)
		{
			alert('This Value already exist, please write another');
				ret=true;
		}
		
	}
	return ret;
}

function IsIDAddedd(ID)
{
	//frm = document.controlfieldradio;
	//MyDestinationList = frm.MyDestinationradio;
	//alert(ID);
	var ret=false;
	for (var i=0;i<MyDeleteDestinationList.length;i++)
	{
		if (ID==MyDeleteDestinationList.options[i].value)
		{
			alert('This Value already exist, please write another');
				ret=true;
		}
		
	}
	return ret;
}
// Radio Options list Remove function creating MyDestinationList table object

//function RemoveRadioList(type)
//{
		//frm = document.controlfieldradio;
		//MyDestinationList = frm.MyDestinationradio;
		//RemoveFromTheList();
//}
// CheckBox Options list Remove function creating MyDestinationList table object
//function RemoveCheckList()
//{
		//frm = document.controlfieldcheck;
		//MyDestinationList = frm.MyDestinationcheck;
		//RemoveFromTheList();
//}
// SelectBox Options list Remove function creating MyDestinationList table object
//function RemoveSelectList()
//{
		//frm = document.controlfieldselect;
		//MyDestinationList = frm.MyDestinationselect;
		//RemoveFromTheList();
//}
// MultiSelect Options list Remove function creating MyDestinationList table object
//function RemoveMultiSelectList()
//{
		//frm = document.controlfieldmultiselect;
		//MyDestinationList = frm.MyDestinationmultiselect;
		//RemoveFromTheList();
//}
// Selected option in list box can go up using this function
function GoUp(type)
{
	if(type=='radio')
	{
		frm = document.controlfieldradio;
		MyDestinationList = frm.MyDestinationradio;
		//var controlvalue=frm.controlvalueradio.value;
	}
	//For Checkbox Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='checkbox')
	{
		frm = document.controlfieldcheck;
		MyDestinationList = frm.MyDestinationcheck;
		//var controlvalue=frm.controlvaluecheck.value;
	}
	//For Select Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='select')
	{
		frm = document.controlfieldselect;
		MyDestinationList = frm.MyDestinationselect;
		//var controlvalue=frm.controlvalueselect.value;
	}	
    var lBox=MyDestinationList;
    //var sBox=frm.StringBox;		
    var SelectedIndex=lBox.selectedIndex;
    if(SelectedIndex==-1)
    {
        //alert("You must select an item first");
        return;
    }
    if(SelectedIndex>0)
    {
        var SelectedItemValue=lBox[SelectedIndex].value;
        var SelectedItemText=lBox[SelectedIndex].text;
        var SelectedItemValueUp=lBox[SelectedIndex-1].value;
        var SelectedItemTextUp=lBox[SelectedIndex-1].text;
        //*************
        lBox[SelectedIndex].value=SelectedItemValueUp;
        lBox[SelectedIndex].text=SelectedItemTextUp;
        lBox[SelectedIndex-1].value=SelectedItemValue;
        lBox[SelectedIndex-1].text=SelectedItemText;
        SelectedIndex=SelectedIndex-1
        lBox.selectedIndex=SelectedIndex;
      //  BuildOrderedString();
    }
   
}
// Selected option in list box can go down using this function
function GoDown(type)
{
    if(type=='radio')
	{
		frm = document.controlfieldradio;
		MyDestinationList = frm.MyDestinationradio;
		//var controlvalue=frm.controlvalueradio.value;
	}
	//For Checkbox Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='checkbox')
	{
		frm = document.controlfieldcheck;
		MyDestinationList = frm.MyDestinationcheck;
		//var controlvalue=frm.controlvaluecheck.value;
	}
	//For Select Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='select')
	{
		frm = document.controlfieldselect;
		MyDestinationList = frm.MyDestinationselect;
		//var controlvalue=frm.controlvalueselect.value;
	}	
    var lBox=MyDestinationList;
    //var sBox=frm.StringBox;		
    var SelectedIndex=lBox.selectedIndex;
    if(SelectedIndex==-1)
    {
        //alert("You must select an item first");
        return;
    }
    if(SelectedIndex<lBox.length-1)
    {
        var SelectedItemValue=lBox[SelectedIndex].value;
        var SelectedItemText=lBox[SelectedIndex].text;
        var SelectedItemValueDown=lBox[SelectedIndex+1].value;
        var SelectedItemTextDown=lBox[SelectedIndex+1].text;
        //*************
        lBox[SelectedIndex].value=SelectedItemValueDown;
        lBox[SelectedIndex].text=SelectedItemTextDown;
        lBox[SelectedIndex+1].value=SelectedItemValue;
        lBox[SelectedIndex+1].text=SelectedItemText;
        SelectedIndex=SelectedIndex+1
        lBox.selectedIndex=SelectedIndex;
       // BuildOrderedString();
    }       
}

function textfieldRadio()
{

		frm = document.controlfieldradio;
		frm.controlvalueradio.value=frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text;
		//alert(frm.controlvalueradio.value);
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text="";
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].value="";
}
function textfieldcheck()
{
		frm = document.controlfieldcheck;
		frm.controlvaluecheck.value=frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text;
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text="";
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].value="";
}
function textfieldselect()
{
		frm = document.controlfieldselect;
		frm.controlvalueselect.value=frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text;
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text="";
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].value="";
}
function textfieldmultiselect()
{
		frm = document.controlfieldmultiselect;
		frm.controlvaluemultiselect.value=frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text;
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text="";
		//frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].value="";
}
function RemoveMultiSelectList(type)
{
	if(type=='multiselect')
		{
			frm = document.controlfieldmultiselect;
			MyDeleteDestinationList = frm.MyDelateDestination;
			MyDestinationmultiselectList = frm.MyDestinationmultiselect;
			MyDestinationList = frm.MyDestinationmultiselect;
			var controlDeltevalue = MyDestinationmultiselectList.options[MyDestinationmultiselectList.selectedIndex].text;
		}
		var NonSelected = true;
			var DidAdd = true;
			if (MyDestinationList.selectedIndex>=0)
			{
				if (!IsIDAddedd(controlDeltevalue))
				{
					MyDeleteDestinationList.options[MyDeleteDestinationList.length] = new Option(controlDeltevalue,controlDeltevalue);
					DidAdd=true;
				}
					if(type=='multiselect')
						{
							MyDestinationmultiselectList.options[MyDestinationmultiselectList.selectedIndex].text="";
							MyDestinationmultiselectList.options[MyDestinationmultiselectList.selectedIndex].value="";
							BumpUp(MyDestinationmultiselectList);
						}
					if (DidAdd)
						{
							for (var i=0;i<MyDeleteDestinationList.length;i++)
								{
									MyDeleteDestinationList.className='';
								}
						}
	
			}
}
function RemoveSelectList(type)
{
	if(type=='select')
		{
			frm = document.controlfieldselect;
			MyDeleteDestinationList = frm.MyDelateDestination;
			MyDestinationselectList = frm.MyDestinationselect;
			var controlDeltevalue = MyDestinationselectList.options[MyDestinationselectList.selectedIndex].text;
		}
		var NonSelected = true;
			var DidAdd = true;
			if (MyDestinationList.selectedIndex>=0)
			{
				if (!IsIDAddedd(controlDeltevalue))
				{
					MyDeleteDestinationList.options[MyDeleteDestinationList.length] = new Option(controlDeltevalue,controlDeltevalue);
					DidAdd=true;
				}
					if(type=='select')
						{
							//alert(type);
							MyDestinationselectList.options[MyDestinationselectList.selectedIndex].text="";
							MyDestinationselectList.options[MyDestinationselectList.selectedIndex].value="";
							BumpUp(MyDestinationselectList);
						}
					if (DidAdd)
						{
							for (var i=0;i<MyDeleteDestinationList.length;i++)
								{
									MyDeleteDestinationList.className='';
								}
						}
	
			}
}
function RemoveCheckList(type)
{
	if(type=='checkbox')
		{
			frm = document.controlfieldcheck;
			MyDeleteDestinationList = frm.MyDelateDestination;
			MyDestinationcheckList = frm.MyDestinationcheck;
			MyDestinationList = frm.MyDestinationcheck;
			var controlDeltevalue = MyDestinationcheckList.options[MyDestinationcheckList.selectedIndex].text;
		}
		var NonSelected = true;
			var DidAdd = true;
			if (MyDestinationList.selectedIndex>=0)
			{
				if (!IsIDAddedd(controlDeltevalue))
				{
					MyDeleteDestinationList.options[MyDeleteDestinationList.length] = new Option(controlDeltevalue,controlDeltevalue);
					DidAdd=true;
				}
					if(type=='checkbox')
						{
							MyDestinationcheckList.options[MyDestinationcheckList.selectedIndex].text="";
							MyDestinationcheckList.options[MyDestinationcheckList.selectedIndex].value="";
							BumpUp(MyDestinationcheckList);
						}
					if (DidAdd)
						{
							for (var i=0;i<MyDeleteDestinationList.length;i++)
								{
									MyDeleteDestinationList.className='';
								}
						}
	
			}
}

function RemoveRadioList(type)
	{
		//alert('hello');
		if(type=='radio')
			{
				frm = document.controlfieldradio;
				MyDeleteDestinationList = frm.MyDelateDestination;
				MyDestinationList = frm.MyDestinationradio;
				var controlDeltevalue = frm.MyDestinationradio.options[MyDestinationList.selectedIndex].text;
			}
			var NonSelected = true;
			var DidAdd = true;
			if (MyDestinationList.selectedIndex>=0)
			{
				if (!IsIDAddedd(controlDeltevalue))
				{
					MyDeleteDestinationList.options[MyDeleteDestinationList.length] = new Option(controlDeltevalue,controlDeltevalue);
					DidAdd=true;
					
				}
					if(type=='radio')
						{
							frm.MyDestinationradio.options[MyDestinationList.selectedIndex].text="";
							frm.MyDestinationradio.options[MyDestinationList.selectedIndex].value="";
							//var tewmp_det=document.getElementsByName('MyDestinationList');
							//tewmp_det.remove(MyDestinationList.selectedIndex);
							BumpUp(MyDestinationList);
							
						}
					if (DidAdd)
						{
							for (var i=0;i<MyDeleteDestinationList.length;i++)
								{
									MyDeleteDestinationList.className='';
								}
						}
	
			}
	}
	
function AddToTheList(type) 
{
	//alert('hello');
	//For Radio Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='radio')
	{
		frm = document.controlfieldradio;
		MyDestinationList = frm.MyDestinationradio;
		var controlvalue=frm.controlvalueradio.value;
	}
	//For Checkbox Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='checkbox')
	{
		frm = document.controlfieldcheck;
		MyDestinationList = frm.MyDestinationcheck;
		var controlvalue=frm.controlvaluecheck.value;
	}
	//For Select Creating MyDestinationList object and stroing option in controlvalue variable
	
	if(type=='select')
	{
		frm = document.controlfieldselect;
		MyDestinationList = frm.MyDestinationselect;
		var controlvalue=frm.controlvalueselect.value;
	}
	//For MultiSelect Creating MyDestinationList object and stroing option in controlvalue variable
	if(type=='multiselect')
	{
		frm = document.controlfieldmultiselect;
		MyDestinationList = frm.MyDestinationmultiselect;
		var controlvalue=frm.controlvaluemultiselect.value;
	}
	var NonSelected = true;
	var DidAdd = false;
	//Adding option record to the MyDestinationList Table
	if (controlvalue.length>0)
	{
		if (!IsIDAdded(controlvalue))
		{
			MyDestinationList.options[MyDestinationList.length] = new Option(controlvalue,controlvalue);
			DidAdd=true;
			
		}
		// Removing the option from the input controlvalue field
		if(type=='radio')
		{
			frm.controlvalueradio.value="";
			
		}
		if(type=='checkbox')
		{
			frm.controlvaluecheck.value="";
		}
		if(type=='select')
		{
			frm.controlvalueselect.value="";
		}
		if(type=='multiselect')
		{
			frm.controlvaluemultiselect.value="";
		}
	}
	else
	{
		alert('Please enter the Control Value');
	}
	if(frm.MyDelateDestination.length !== 0)
				{					
					if(frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text == controlvalue)
					{
						frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].text="";
						frm.MyDelateDestination.options[frm.MyDelateDestination.selectedIndex].value="";
						BumpUp(frm.MyDelateDestination);
					}
				}
	if (DidAdd)
	{
		//alert('tom1234');
		for (var i=0;i<MyDestinationList.length;i++)
		{
			MyDestinationList.className='';
		}
	}
}
function BumpUp(abox) {

for(var i = 0; i < abox.options.length; i++) {
if(abox.options[i].value == "")  {
for(var j = i; j < abox.options.length - 1; j++)  {
abox.options[j].value = abox.options[j + 1].value;
abox.options[j].text = abox.options[j + 1].text;
}
var ln = i;
break;
   }
}
if(ln < abox.options.length)  {
abox.options.length -= 1;
BumpUp(abox);
   }
}

function RemoveFromTheList() 
{
	//alert('hello12345');
	var NonSelected = true;
	if ( MyDestinationList.selectedIndex >= 0)
	{
		MyDestinationList.options[MyDestinationList.selectedIndex] = null;
		NonSelected = false;
		return false;
	}
	if (NonSelected)
	{
		if(MyDestinationList.length<1)
		{
			alert('There is no Value in list to be Removed');
			return false;
		}
		alert('Please select the Value to be deleted');
		return false;
	}
			
	
	
}
//Assigning the class of mouseover, mouseout and onclick
function DoHL()
{
var e=window.event.srcElement;
while (e.tagName!="TR"){e=e.parentElement;}
if (e.className!='SL') e.className='HL';
}
function DoLL()
{
var e=window.event.srcElement;
while (e.tagName!="TR"){e=e.parentElement;}
if (e.className!='SL')	e.className='';
}
function DoSL()
{
var TB=e=window.event.srcElement;
while (TB.tagName!="TABLE")
{TB=TB.parentElement;}
for (var i=0;i<TB.rows.length;i++){TB.rows[i].className='';}
while (e.tagName!="TR"){e=e.parentElement;}
e.className='SL';
}
//****************************************************************************************************//
//***********************TextField validation *******************************************************//
function chktxtform()
{
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	document.controlfieldtext.textlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable
	if (document.frmCommon.label_seating[0].checked)
		document.controlfieldtext.textlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		document.controlfieldtext.textlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction to the hidden variable
	document.controlfieldtext.textinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position to the hidden variable
	if (document.frmCommon.instruction_seating[0].checked)
		document.controlfieldtext.textinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		document.controlfieldtext.textinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	//document.controlfieldtext.textinstructionpos.value=document.frmCommon.instruction_seating.value;
	
	//return false;
	//Make sure Size is numeric
	if (isNumber(document.controlfieldtext.textsize, "Size") == false)
		{
			document.controlfieldtext.textsize.value="";
			return false;
		}
	//Make sure MaxLength is numeric
	if (isNumber(document.controlfieldtext.textmaxlen, "maxLength") == false)
		{
			document.controlfieldtext.textmaxlen.value="";
			return false;
		}
}
//****************************************************************************************************//
//***********************TextArea Field validation *******************************************************//
function chktxtareaform()
{
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	document.controlfieldtextarea.textarealabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	if (document.frmCommon.label_seating[0].checked)
		document.controlfieldtextarea.textarealabelpos.value=document.frmCommon.label_seating[0].value;
	else
		document.controlfieldtextarea.textarealabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	document.controlfieldtextarea.textareainstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//document.controlfieldtextarea.textareainstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		document.controlfieldtextarea.textareainstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		document.controlfieldtextarea.textareainstructionpos.value=document.frmCommon.instruction_seating[1].value;
	//Make sure Rows is numeric
	if (isNumber(document.controlfieldtextarea.textarearows, "Rows") == false)
		{
			document.controlfieldtextarea.textarearows.value="";
			return false;
		}
	//Make sure Cols is numeric
	if (isNumber(document.controlfieldtextarea.textareacols, "Cols") == false)
		{
			document.controlfieldtextarea.textareacols.value="";
			return false;
		}
	//Make sure character limit is numeric
	if (isNumber(document.controlfieldtextarea.charlimit, "Character limit") == false)
		{
			document.controlfieldtextarea.charlimit.value="";
			return false;
		}
}
//***********************Password Field validation *******************************************************//
function chkpwdform()
{
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	document.controlfieldpwd.pwdlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//document.controlfieldpwd.pwdlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		document.controlfieldpwd.pwdlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		document.controlfieldpwd.pwdlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	document.controlfieldpwd.pwdinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//document.controlfieldpwd.pwdinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		document.controlfieldpwd.pwdinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		document.controlfieldpwd.pwdinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	//Make sure Size is numeric
	if (isNumber(document.controlfieldpwd.pwdsize, "Size") == false)
		{
			document.controlfieldpwd.pwdsize.value="";
			return false;
		}
	//Make sure maxLength is numeric
	if (isNumber(document.controlfieldpwd.pwdlen, "maxLength") == false)
		{
			document.controlfieldpwd.pwdlen.value="";
			return false;
		}
}

//****************************************************************************************************//
//***********************function for reloading captcha image *******************************************************//

function upload_captcha(path)
{
	//showdiv("divStayTopLeft");	
	AjaxRequest('upload_captcha.cfm',path);
	return false;
}

//****************************************************************************************************//
//***********************HiddenField validation *******************************************************//
function chkhiddenform()
{
	//Transfer form label value to the hidden variable
	if (document.frmCommon.label.value != "")
		document.controlfieldhidden.hiddenlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable
	if (document.frmCommon.label_seating.value != "")
		document.controlfieldhidden.hiddenlabelpos.value='Left';
		
	//Transfer form field instruction value to the hidden variable  
	document.controlfieldhidden.hiddeninstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction value to the hidden variable  
	document.controlfieldhidden.hiddeninstructionpos.value='Left';
	//Make sure Default Value is not blank
	if (isBlank(document.controlfieldhidden.textlabel, "Default Value") == false)
		{
			return false;
		}
}

//**********************Transfering values from MyDestination Table to SelectedOptionList*************//
function SelectedOptionList()
{//var formname="controlfield";
//alert(type); 

	if(MyDestinationList.length>0)
		{
			var SelectedList = "";
			for(var i = 0; i < MyDestinationList.length; i++) 
			{
				SelectedList += (MyDestinationList.options[i].value + "~");	
				
			}
			SelectedList = SelectedList.substring(0, SelectedList.length-1);
			frm.SelectedContactsList.value = SelectedList;
			frm.chkoption.value=SelectedList;
			
		}
	
}
//***********************Radio Field validation *******************************************************//
function chksaveradioform()
{	
	frm = document.controlfieldradio;
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	
	//frm = document.controlfieldradio;
	//Transfer form label value to the hidden variable  
	frm.radiolabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//frm.radiolabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.radiolabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.radiolabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.radioinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction value to the hidden variable
	//frm.radioinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.radioinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.radioinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	MyDestinationList = frm.MyDestinationradio;
	if(document.controlfieldradio.saveradio.value=="1")
	{
	 //var type="radio";
	SelectedOptionList()
		
	}
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvalueradio.focus();
		return false;
	}
	
}
function chkeditradioform()
{	
	frm = document.controlfieldradio;
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	
	//frm = document.controlfieldradio;
	
	//Transfer form label value to the hidden variable  
	frm.radiolabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//frm.radiolabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.radiolabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.radiolabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.radioinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.radioinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.radioinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.radioinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	
	MyDestinationList = frm.MyDestinationradio;
	if(document.controlfieldradio.editradio.value=="1")
	{
		SelectedOptionList()
		
	}
	
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvalueradio.focus();
		return false;
	}
	
}


//******************************CheckBox validation***********************************************//
function chksavecheckboxform()
{
	frm = document.controlfieldcheck;
	MyDestinationList = frm.MyDestinationcheck;
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	frm.checkboxlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//frm.checkboxlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.checkboxlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.checkboxlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.checkboxinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.checkboxinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.checkboxinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.checkboxinstructionpos.value=document.frmCommon.instruction_seating[1].value;
   if(document.controlfieldcheck.savecheckbox.value=="1")
	{
		SelectedOptionList()
	}
		
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvaluecheck.focus();
		return false;
	}
	
}
function chkeditcheckboxform()
{	
	frm = document.controlfieldcheck;
	MyDestinationList = frm.MyDestinationcheck;
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
   //Transfer form label value to the hidden variable  
	frm.checkboxlabel.value=document.frmCommon.label.value;
   //Transfer form label position value to the hidden variable  
	//frm.checkboxlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.checkboxlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.checkboxlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.checkboxinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.checkboxinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.checkboxinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.checkboxinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	if(frm.editcheckbox.value=="1")
	{
		SelectedOptionList()
		
	}
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvaluecheck.focus();
		return false;
	}
	
}

//*******************************************************************************************************//
//******************************Select Box validation***********************************************//
function chksaveselectform()
{
	frm = document.controlfieldselect;
	MyDestinationList = frm.MyDestinationselect;
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	frm.selectlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//frm.selectlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.selectlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.selectlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.selectinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.selectinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.selectinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.selectinstructionpos.value=document.frmCommon.instruction_seating[1].value;
   if(frm.saveselect.value=="1")
	{
		SelectedOptionList()
	}
	
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvalueselect.focus();
		return false;
	}
	
}

function chkeditselectform()
{
	frm = document.controlfieldselect;
	MyDestinationList = frm.MyDestinationselect;
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
   //Transfer form label value to the hidden variable  
	frm.selectlabel.value=document.frmCommon.label.value;
   //Transfer form label position value to the hidden variable  
	//frm.selectlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.selectlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.selectlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.selectinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.selectinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.selectinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.selectinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	if(frm.editselect.value=="1")
	{	SelectedOptionList()
		
	}
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvalueselect.focus();
		return false;
	}
	
}

//*******************************************************************************************************//
//******************************MultiSelect Box validation***********************************************//
function chksavemultiselectform()
{
	frm = document.controlfieldmultiselect;
	MyDestinationList = frm.MyDestinationmultiselect;
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	frm.multiselectlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//frm.multiselectlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.multiselectlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.multiselectlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.multiselectinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.multiselectinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.multiselectinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.multiselectinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	
   //Make sure Size is numeric
	if (isNumber(frm.multiselectsize, "Size") == false)
		{
			frm.multiselectsize.value="";
			return false;
		}
	 if(frm.savemultiselect.value=="1")
	{
		SelectedOptionList()
	}
	
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvaluemultiselect.focus();
		return false;
	}
	
}

function chkeditmultiselectform()
{
	frm = document.controlfieldmultiselect;
	MyDestinationList = frm.MyDestinationmultiselect;
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	frm.multiselectlabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//frm.multiselectlabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		frm.multiselectlabelpos.value=document.frmCommon.label_seating[0].value;
	else
		frm.multiselectlabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	frm.multiselectinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//frm.multiselectinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		frm.multiselectinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		frm.multiselectinstructionpos.value=document.frmCommon.instruction_seating[1].value;
   //Make sure Size is numeric
	if (isNumber(frm.multiselectsize, "Size") == false)
		{
			frm.multiselectsize.value="";
			return false;
		}
	if(frm.editmultiselect.value=="1")
	{
		SelectedOptionList()
		
	}
	if(frm.chkoption.value=="")
	{
		alert('Please add options from Control table');
		frm.controlvaluemultiselect.focus();
		return false;
	}
	
}

//*******************************************************************************************************//
//***********************File Field validation *******************************************************//
function chkfileform()
{
	//Make sure Form Label is not blank
	if (isBlank(document.frmCommon.label, "Form Label") == false)
		{
			return false;
		}
	//Transfer form label value to the hidden variable  
	document.contolfieldfile.filelabel.value=document.frmCommon.label.value;
	//Transfer form label position value to the hidden variable  
	//document.contolfieldfile.filelabelpos.value=document.frmCommon.label_seating.value;
	if (document.frmCommon.label_seating[0].checked)
		document.contolfieldfile.filelabelpos.value=document.frmCommon.label_seating[0].value;
	else
		document.contolfieldfile.filelabelpos.value=document.frmCommon.label_seating[1].value;
	//Transfer form field instruction value to the hidden variable
	document.contolfieldfile.fileinstruction.value=document.frmCommon.instruction.value;
	//Transfer form field instruction position value to the hidden variable
	//document.contolfieldfile.fileinstructionpos.value=document.frmCommon.instruction_seating.value;
	if (document.frmCommon.instruction_seating[0].checked)
		document.contolfieldfile.fileinstructionpos.value=document.frmCommon.instruction_seating[0].value;
	else
		document.contolfieldfile.fileinstructionpos.value=document.frmCommon.instruction_seating[1].value;
	//Make sure Size is numeric
	if (isNumber(document.contolfieldfile.filesize, "Size") == false)
		{
			document.contolfieldfile.filesize.value="";
			return false;
		}
	
}
//****************************************************************************************************//
//***********************Delete Field validation *******************************************************//
function chkdeletefield(fieldid, sectionid)
{ 
	var id=fieldid;
	var result= confirm("Are you sure you want to delete this field")
	
	if(result !=0)
	{
		location="form.cfm?fieldid="+id+"&deletefield=1&sectionid="+sectionid;
	
	}
}
//****************************************************************************************************//
//***********************Edit Field validation *******************************************************//
function chkeditfield(fieldid, type)
{ 
	document.myform.fid.value==type;
	alert(tp);
		location="form.cfm?"
	
}
//****************************************************************************************************//
//*************************Checking FormConnection Page *********************************************//
function chkformconnection()
{
	frm = document.myformconnection;
	if(frm.email.checked)
	{
		var emailid = frm.emails.value;
		if(emailid == "")
		{
			alert('Enter email-id');
			frm.emails.focus();
			return false;
		}
		var spChar = ",";
		var emails = new Array();
		for(i=0; i<emailid.length; i++)
		{
			if(emailid.charAt(i) == spChar)
			{
				emails = emailid.split(",");
			}
		}
		if(emails.length > 0)
		{
			for(x=0; x<emails.length; x++)
			{
				if(isEmail(emails[x], "emails") == false)
				{
					frm.emails.focus();
					return false;
				}
			}
		}
		else
		{
			if (isEmail(frm.emails.value, "Emails") == false)
			{
				frm.emails.focus();
				return false;
			}
		}
		
		
		if(frm.group1[1].checked == true)
		{
			if(frm.thanksmessage.value == "")
			{
				alert('Enter Thank You message');
				frm.thanksmessage.focus();
				return false;
			}
		}
		if(frm.group1[2].checked == true)
		{
			if(frm.internalURL.value == "")
			{
				alert('Enter Nav ID of the internal link');
				frm.internalURL.focus();
				return false;
			}
		}
		if(frm.group1[3].checked == true)
		{
			if(frm.externalURL.value == "")
			{
				alert('Enter external website URL');
				frm.externalURL.focus();
				return false;
			}
		}
	}
	
	else
	{
		if(!(frm.database.checked))
		{
			if(frm.group1[4].checked == false)
			{
			alert('Select at least one of the 2 options for receiving data collected through your form');
			return false;
			}
			else
			{
				if(frm.postURL.value == "")
				{
					alert('Enter external server path');
					frm.postURL.focus();
					return false;
				}
			}
		}
		else
		{
			if(frm.group1[1].checked == true)
			{
				if(frm.thanksmessage.value == "")
				{
					alert('Enter Thank You message');
					frm.thanksmessage.focus();
					return false;
				}
			}
			if(frm.group1[2].checked == true)
			{
				if(frm.internalURL.value == "")
				{
					alert('Enter Nav ID of the internal link');
					frm.internalURL.focus();
					return false;
				}
			}
			if(frm.group1[3].checked == true)
			{
				if(frm.externalURL.value == "")
				{
					alert('Enter external website URL');
					frm.externalURL.focus();
					return false;
				}
			}
		}
	}
	
}
//Post option selected Disabling others
function disableothers()
{
	frm = document.myformconnection;
	frm.email.checked=false;
	frm.database.checked=false;
	frm.emails.value ="";
	frm.thanksmessage.value ="";
	frm.internalURL.value ="";
	frm.externalURL.value ="";
	frm.postURL.focus();
	
}

//Post option selected Disabling others
function resetother()
{
	frm = document.myformconnection;
	frm.thanksmessage.value ="";
	frm.internalURL.value ="";
	frm.externalURL.value ="";
	frm.postURL.value="";
	
	if(frm.group1[1].checked == true)
		frm.thanksmessage.focus();
	if(frm.group1[2].checked == true)
		frm.internalURL.focus();
	if(frm.group1[3].checked == true)
		frm.externalURL.focus();		
	
}

//Data collection option reset the postvalue
function chkpostvalue()
{
	frm = document.myformconnection;
	if(frm.group1[4].checked == true)
	{
		frm.group1[0].checked = true;
	}
	frm.group1.checked == false;
	frm.group1[0].checked == false;
	if (frm.email.checked == false)
		frm.emails.value ="";
}
function addsection1(id)
{
	//alert('hello');
	//winOpen("addsection.cfm?formid="+id+"&formname="+"addsection","object",650,350);
	window.open ("addsection.cfm?formid="+id,"mynewwindow","width=650,height=350"); 

}
function addsection(id,sid)
{

	winOpen("addsection.cfm?formid="+id+"&sectionid="+sid,"object",650,700);
	//winOpen("form.cfm?formid="+id+"&formname="+"addsection","object",650,700);
}
//Setting page opening new addsection page
function editsection(id, sid)
{
	window.open ("addsection.cfm?formid="+id+"&sectionid="+sid,"mywindow","width=650,height=350"); 
	 //popup_window.close ();
}

//Setting page opening auto-section field's page"form.cfm?formid="+id+"&sectionid="+sid,"
function editautosection(id,sid)
{
	winOpen("form.cfm?formid="+id+"&sectionid="+sid,"object",650,700);
}

//Setting page opening new addform page
function redirectionpage(id,sid)
{
	//alert(id);
	//alert(sid);
	window.location="form.cfm?formid="+id+"&sectionid="+sid+"&colorid=1"+sid;
	
	//if(id > 0)
			//{
				//alert(sid);
				//document.getElementById(sid).style.background='white';
				//alert(sid);
			//}
	
}
function redirectpage(id,sid,uid,unc)
{
	//alert(id);
	//alert(sid);	
	window.location="form.cfm?formid="+id+"&sectionid="+sid+"&colorid=1"+sid+"&uObjid="+uid+"&uNC="+unc;
	
	//if(id > 0)
			//{
				//alert(sid);
				//document.getElementById(sid).style.background='white';
				//alert(sid);
			//}
	
}
function addform(id)
{
	winOpen("form.cfm?formid="+id+"&formname="+"addfield","object",650,700);
}
//Addsection page validation
/*function chkaddsection()
{
	frm = document.addsectionform;
	if(frm.sectionheading.value == "")
	{
		alert('Please write the Section name');
		frm.sectionheading.focus();
		return false;
	}
	alert('Data has been added successfully.')
	//window.opener.location.href ='form.cfm?formid="+id+"&sectionid="+sid';
	//window.opener.location.reload(true);
	//if (window.opener.progressWindow)
		//{
    		//window.opener.progressWindow.close()
 		// }
 		 //window.close();
  	window.close();
	
}*/
function chkaddsection()
{
	frm = document.addsectionform;
	if(frm.sectionheading.value == "")
	{
		alert('Please write the Section name');
		frm.sectionheading.focus();
		return false;
	}
	alert('Data has been added successfully.')
	//window.opener.location.href ='form.cfm?formid="+id+"&sectionid="+sid';
	//parent.window.location.reload(true);
	
	
}
//***********************Delete Section validation *******************************************************//
function chkdeletesection(formid, sectionid)
{ 
	var id=formid;
	var sid=sectionid;
	var result= confirm("Are you sure you want to delete this Section")
	
	if(result !=0)
	{
		location="settings.cfm?formid="+id+"&sectionid="+sid+"&deletefield=1"
	
	}
	

}
//Checking the blank field
function isBlank(obj,displayName)
{
	var str="";
	str=obj.value;
	var len=str.length;
	var i;
	for(i=0;i<len;++i)
	{
		if(str.charAt(i)!=" ")
		{
			return true;
		}
	}
	alert(displayName+" cannot be left blank");
	obj.focus();
	return false;
}
// Checking numeric value
function isNumber(obj,displayName)
{
	var str=lTrim(obj.value);
	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i)<'0'||str.charAt(i)>'9')
		{	
			if((str.charAt(0))=="-")
			{
				i=i+1;
					continue;
			}
			alert(displayName+" should be numeric.");
			obj.focus();
			return false;
		}
	}
	return true;
}
function Trim(s)
{
	var tempStr1, s1 ,tmpStr2 ;
	s1 = s;
	tempStr1 = lTrim(s1);
	tempStr2 = rTrim(tempStr1);
	return tempStr2 ;
}	
	
function rTrim(s)
{
	var temp="";
	tempStr="";
	temp=s;
	var len=s.length;
	
	if(len>0)
	{
		for(i=len;i > 0;i--)
		{
			if(temp.charAt(i-1)!=" ")
				break;
		}
		
		k=0;
		for(j=0;j<i;j++)
		{
			tempStr=tempStr+temp.charAt(j);
			k=k+1;
		}
		return tempStr;
	}
	else
		return tempStr;
}

function lTrim(s)
{
	var temp="";
	tempStr="";
	temp=s;
	var len=s.length;
	
	if(len>0)
	{
		for(i=0;i<len;i++)
		{
			if(temp.charAt(i)!=" ")
				break;
		}
		
		k=0;
		for(j=i;j<len;j++)
		{
			tempStr=tempStr+temp.charAt(j);
			k=k+1;
		}
		return tempStr;
	}
	else
		return tempStr;
}
//Bulk mail checking validations
function isEmail (obj,displayName) 
{ 
var theStr=lTrim(obj);
var atIndex = theStr.indexOf('@'); 
var dotIndex = theStr.indexOf('.', atIndex); 
var flag = true; 
theSub = theStr.substring(0, dotIndex+1) 

if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
{ 
	alert("Not a valid email id");
	//obj.focus();
	flag = false; 
} 
else { flag = true; } 
return(flag); 
}
//Email  Checking validations
function isValidEmail (obj,displayName) 
{ 
var theStr=lTrim(obj.value);
var atIndex = theStr.indexOf('@'); 
var dotIndex = theStr.indexOf('.', atIndex); 
var flag = true; 
theSub = theStr.substring(0, dotIndex+1) 

if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
{ 
	alert("Not a valid email id");
	obj.focus();
	flag = false; 
} 
else { flag = true; } 
return(flag); 
}
//Character Validation
function IsCharacter(obj,displayName)
{
	var s=""; 
	s=lTrim(obj.value);
	splChars=new Array("@","#","$","%","^","&","*","!","\'","(",")","_","=","+","[","]","{","}","|","\\","<",">",".","/","?","\"","0","1","2","3","4","5","6","7","8","9");
	if(s.length>0)
	{
	for(i=0;i<s.length;i++)
		for(j=0;j<splChars.length;j++)
		{
			if(s.charAt(i)==splChars[j])
			{
				alert(displayName+" cannot have special characters like @,#,$,%,1,2,3 etc.");
				obj.focus();
				return false;
			}
		}
	return true;
	}
	else
	{ 
		alert(displayName+" cannot be left blank");
		obj.focus();
		return false;
	}
}
//AlphaNumeric Validation
function IsAlphaNumber(obj,displayName)
{
	var str=lTrim(obj.value);
	var flag=false;
	if(str.length>0)
	{
			for(i=0;i<str.length;i++)
			{	
				if((str.charAt(0))=="-")
				{
					i=i+1;
						continue;
				}
				if(str.charAt(i)<'0'||str.charAt(i)>'9')
				{
					flag=true;	
				}
			}
			if(flag)
				return true;
			else
			{
				alert(displayName+" should be non-numeric.");
				obj.focus();
				return false;
			}
	}
	else
		return true;
	return flag;
}
//CheckBox Validations
function isChecked(obj,displayName)
{
	var flag=false; 
	for (counter = 0; counter < obj.length; counter++)
	{
		if (obj[counter].checked)
		{flag=true;}
		
	}
	
	if(flag)
		return true;
	else
	{
		alert("Please select atleast one option of "+displayName);
		return false;
	}
	
}
//SelectBox Validations
function isSelected(obj,displayName)
{	var flag=false; 
	for (var i = 0; i < obj.length; i++)
	{
		if (!obj.options[i].selected)
		{flag=true;}
	}
	if(flag)
		return true;
	else
	{
		alert("Please select atleast one option of "+displayName);
		return false;
	}
}
/* win_open(where,x,y)*/
function winOpen(f_sWhere)
{
	if (arguments.length > 1)
	{
		sWin = arguments[1];
	}
	else
	{
		sWin = 1;
	}
	
	if (arguments.length <= 2)
	{
		iX = 700;
		iY = 550;
	}
	else
	{
		iX = arguments[2];
		iY = arguments[3];
	}
	
	win = window.open(f_sWhere,"Object"+sWin,"scrollbars=1,width="+iX+",height="+iY);
	win.focus();
}

function maxLength(obj,displayname,num)
{
	var str="";
	var  num=num;
	str=lTrim(obj.value);

	if(str.length > num)
	{
		alert(displayname+" should not have more than "+num+" characters.");
		obj.focus();
		return false;
	}
	return true;
}

//new validation functions for multiple languages

function isNumber_new(obj,displayName,fieldname,str1)
{
	var str=lTrim(obj.value);
	var variablename = document.getElementById(fieldname);
	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i)<'0'||str.charAt(i)>'9')
		{	
			if((str.charAt(0))=="-")
			{
				i=i+1;
					continue;
			}
			showdiv(fieldname);
			obj.style.border = '1px solid red';
			variablename.innerHTML = displayName+" "+str1;	
			//alert(displayName+" "+str1);
			obj.focus();
			return false;
		}
	}
	obj.style.border = '';
	variablename.innerHTML = " ";
	return true;
}

function IsCharacter_new(obj,displayName,fieldname,str1,str2)
{	
	var s=""; 
	//alert(document.getElementById(fieldname));
	var variablename = document.getElementById(fieldname);
	showdiv(fieldname);
	//alert(obj.value);
	s=lTrim(obj.value);
	splChars=new Array("@","#","$","%","^","&","*","!","\'","(",")","_","=","+","[","]","{","}","|","\\","<",">",".","/","?","\"","0","1","2","3","4","5","6","7","8","9");
	if(s.length>0)
	{
	for(i=0;i<s.length;i++)
		for(j=0;j<splChars.length;j++)
		{			
			if(s.charAt(i)==splChars[j])
			{
				//alert(obj);
				//alert(str1);
				//alert(str2);
				obj.style.border = '1px solid red';				
				variablename.innerHTML = displayName+" "+str1+" @,#,$,%,1,2,3 etc.";	
				showdiv(fieldname);
				//alert(displayName+" "+str1+" @,#,$,%,1,2,3 etc.");
				obj.focus();
				return false;
			}
		}		
	obj.style.border = '';	
	variablename.innerHTML = " ";
	return true;
	}
	/*else
	{ 
		alert(displayName+str2);
		obj.focus();
		return false;
	}*/
}

function isBlank_new(obj,displayName,fieldname,str1)
{	
	var str="";	
	str=obj.value;
	var len=str.length;
	var i;
	var variablename = document.getElementById(fieldname);	
	for(i=0;i<len;++i)
	{
		
		if(str.charAt(i)!=" ")
		{
			//alert("Test");
			//obj.style.border = '0px solid black';
			variablename.innerHTML = " ";
			return true;
		}
	}
	//alert(fieldname);
	//alert(displayName+" "+str1);
	obj.style.border = '1px solid red';
	variablename.innerHTML = displayName+" "+str1;		
	obj.focus();
	return false;
}

function validate(obj,fieldname,fieldlabel,email,alpha,character,numeric)
{		
	var str="";	
	str=obj.value;		
	var len=str.length;
	var i;
	//alert(numeric);
	var variablename = document.getElementById(fieldname);			
	if(email == 1 && str != "")
	{
		
		if(str != "")
		{			
			var atIndex = str.indexOf('@'); 
			var dotIndex = str.indexOf('.', atIndex); 
			theSub = str.substring(0, dotIndex+1) 
			if (str != "")
			{				
				if ((atIndex < 1)||(atIndex != str.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(str.length <= theSub.length)) 
				{ 
					//alert(str1);
					//document.getElementById(obj).style.backgroundcolor = "red";
					obj.style.border = '1px solid red';
					variablename.innerHTML = "Sorry - we didn't recognise your email address as being valid";	
					//obj.focus();
					return false; 
				} 
				else 
				{		
					//alert("Test");
					obj.style.border = '';
					variablename.innerHTML = " ";	
				 	return true; 
				}
			}
		}
		/*else
		{
			variablename.innerHTML = " ";	
			return true;
		}*/
	}
	if(alpha == 1 && str != "")
	{
		var text = 'should be non-numeric';		
		IsAlphaNumber_new(obj,fieldlabel,fieldname,text);
		return false;
	}
	if(character == 1 && str != "")
	{		
		var textone_character = 'cannot have special characters like';
		var texttwo_character = 'cannot be left blank';
		IsCharacter_new(obj,fieldlabel,fieldname,textone_character,texttwo_character);
		return false;
	}
	if(numeric == 1 && str != "")
	{
		//alert("Test");
		var string = "should be numeric";
		isNumber_new(obj,fieldlabel,fieldname,string);
		return false;
	}
	if(str != "")
	{
			//document.getElementById(fieldlabel).style.background = 'white';	
			//document.getElementById(obj).style.border = '';
			obj.style.border = '';
			variablename.innerHTML = "";						
			document.getElementById(fieldname).style.display = 'none';
			return true;		
	}
	else
	{			
//		alert(obj);
		obj.style.border = '1px solid red';		
		//alert(document.getElementById(obj).value);	
//		document.getElementById(obj).style.border = '1px solid black';
		//document.getElementById(fieldname).style.bordercolor = '5px solid black';
		//obj.style.border = '1px solid black';
		variablename.innerHTML = fieldlabel+ " " +"cannot be left blank";	
		document.getElementById(fieldname).style.display = 'block';
		//obj.focus();
		return false;	
	}

	
	
}
function IsAlphaNumber_new(obj,displayName,fieldname,str1)
{
	var str=lTrim(obj.value);
	var variablename = document.getElementById(fieldname);
	var flag=false;	
	if(str.length>0)
	{
			for(i=0;i<str.length;i++)
			{	
				if((str.charAt(0))=="-")
				{
					i=i+1;
						continue;
				}
				if(str.charAt(i)<'0'||str.charAt(i)>'9')
				{
					flag=true;	
				}
			}
			if(flag)
				return true;
			else
			{
				//document.getElementById(displayName).style.border = '1px solid black';
				obj.style.border = '1px solid red';
				variablename.innerHTML = displayName+" "+str1;	
				//alert(displayName+" "+str1);
				obj.focus();
				return false;
			}
	}
	else
		variablename.innerHTML = " ";
		return true;
	return flag;
}

function isChecked_new(obj,displayName,fieldname,str1)
{
	var flag=false; 
	var variablename = document.getElementById(fieldname);	
	//obj.style.border = '1px solid red';
	showdiv(fieldname);
	for (counter = 0; counter < obj.length; counter++)
	{
		if (obj[counter].checked)
		{flag=true;}
		
	}
	if (!obj.length){if (obj.checked){flag=true;}}
	if(flag)
	{		
		//obj.style.border = '';
		variablename.innerHTML = " ";
		document.getElementById(fieldname).style.display = 'none';
		return true;
	}
	else
	{
		//obj.style.border = '1px solid red';
		variablename.innerHTML = str1+" "+displayName;	
		//alert(str1+" "+displayName);
		return false;
	}
	
}
//SelectBox Validations
function isSelected_new(obj,displayName,fieldname,str1)
{	var flag=false; 
	//alert(fieldname);
	var variablename = document.getElementById(fieldname);
	//alert(obj.length);
	for (var i = 0; i < obj.length; i++)
	{
		if (obj.options[i].selected)
		{
			variablename.innerHTML = " ";
			flag=true;
		}
	}
	if(flag)
	{
		variablename.innerHTML = " ";
		return true;
	}
	else
	{
		obj.style.border = '1px solid red';
		variablename.innerHTML = str1+" "+displayName;	
		return false;
	}
}

//Email  Checking validations
function isValidEmail_new(obj,displayName,fieldname,str1) 
{ 
var theStr=lTrim(obj.value);
var atIndex = theStr.indexOf('@'); 
var dotIndex = theStr.indexOf('.', atIndex); 
var flag = true; 
var variablename = document.getElementById(fieldname);
theSub = theStr.substring(0, dotIndex+1) 
if (theStr != "")
{
	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
	{ 
		//alert(str1);
		showdiv(fieldname);
		obj.style.border = '1px solid red';
		variablename.innerHTML = str1;	
		obj.focus();
		flag = false; 
	} 
	else 
	{
		//alert("hello");
		obj.style.border = '';
		variablename.innerHTML = " ";	
	 	flag = true; 
	}
}
else { flag = true; } 
return(flag); 
}

function maxLength_new(obj,displayname,num,str1,str2)
{
	var str="";
	var  num=num;
	str=lTrim(obj.value);

	if(str.length > num)
	{
		alert(displayname+" "+str1+" "+num+" "+str2);
		obj.focus();
		return false;
	}
	return true;
}


/*
function AjaxRequest(){var req =new Object();
req.timeout =null;
req.generateUniqueUrl =true;
req.url =window.location.href;
req.method ="GET";
req.async =true;
req.username =null;
req.password =null;
req.parameters =new Object();
req.requestIndex =AjaxRequest.numAjaxRequests++;
req.responseReceived =false;
req.groupName =null;
req.queryString ="";
req.responseText =null;
req.responseXML =null;
req.status =null;
req.statusText =null;
req.aborted =false;
req.xmlHttpRequest =null;
req.onTimeout=null;
req.onLoading=null;
req.onLoaded=null;
req.onInteractive=null;
req.onComplete=null;
req.onSuccess=null;
req.onError=null;
req.onGroupBegin=null;
req.onGroupEnd=null;
req.xmlHttpRequest =AjaxRequest.getXmlHttpRequest();
if(req.xmlHttpRequest==null){return null;}req.xmlHttpRequest.onreadystatechange =
function(){if(req==null || req.xmlHttpRequest==null){return;}if(req.xmlHttpRequest.readyState==1){req.onLoadingInternal(req);}if(req.xmlHttpRequest.readyState==2){req.onLoadedInternal(req);}if(req.xmlHttpRequest.readyState==3){req.onInteractiveInternal(req);}if(req.xmlHttpRequest.readyState==4){req.onCompleteInternal(req);}};
req.onLoadingInternalHandled=false;
req.onLoadedInternalHandled=false;
req.onInteractiveInternalHandled=false;
req.onCompleteInternalHandled=false;
req.onLoadingInternal=
function(){if(req.onLoadingInternalHandled){return;}AjaxRequest.numActiveAjaxRequests++;
if(AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function"){AjaxRequestBegin();}if(req.groupName!=null){if(typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined"){AjaxRequest.numActiveAjaxGroupRequests[req.groupName] =0;}AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
if(AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function"){req.onGroupBegin(req.groupName);}}if(typeof(req.onLoading)=="function"){req.onLoading(req);}req.onLoadingInternalHandled=true;};
req.onLoadedInternal=
function(){if(req.onLoadedInternalHandled){return;}if(typeof(req.onLoaded)=="function"){req.onLoaded(req);}req.onLoadedInternalHandled=true;};
req.onInteractiveInternal=
function(){if(req.onInteractiveInternalHandled){return;}if(typeof(req.onInteractive)=="function"){req.onInteractive(req);}req.onInteractiveInternalHandled=true;};
req.onCompleteInternal=
function(){if(req.onCompleteInternalHandled || req.aborted){return;}req.onCompleteInternalHandled=true;
AjaxRequest.numActiveAjaxRequests--;
if(AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function"){AjaxRequestEnd(req.groupName);}if(req.groupName!=null){AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
if(AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function"){req.onGroupEnd(req.groupName);}}req.responseReceived =true;
req.status =req.xmlHttpRequest.status;
req.statusText =req.xmlHttpRequest.statusText;
req.responseText =req.xmlHttpRequest.responseText;
req.responseXML =req.xmlHttpRequest.responseXML;
if(typeof(req.onComplete)=="function"){req.onComplete(req);}if(req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function"){req.onSuccess(req);}else if(typeof(req.onError)=="function"){req.onError(req);} else {document.write(req.responseText);}delete req.xmlHttpRequest['onreadystatechange'];
req.xmlHttpRequest =null;};
req.onTimeoutInternal=
function(){if(req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled){req.aborted =true;
req.xmlHttpRequest.abort();
AjaxRequest.numActiveAjaxRequests--;
if(AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function"){AjaxRequestEnd(req.groupName);}if(req.groupName!=null){AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
if(AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function"){req.onGroupEnd(req.groupName);}}if(typeof(req.onTimeout)=="function"){req.onTimeout(req);}delete req.xmlHttpRequest['onreadystatechange'];
req.xmlHttpRequest =null;}};
req.process =
function(){if(req.xmlHttpRequest!=null){if(req.generateUniqueUrl && req.method=="GET"){req.parameters["AjaxRequestUniqueId"] =new Date().getTime() + "" + req.requestIndex;}var content =null;
for(var i in req.parameters){if(req.queryString.length>0){req.queryString +="&";}req.queryString +=encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);}if(req.method=="GET"){if(req.queryString.length>0){req.url +=((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;}}req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
if(req.method=="POST"){if(typeof(req.xmlHttpRequest.setRequestHeader)!="undefined"){req.xmlHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');}content =req.queryString;}if(req.timeout>0){setTimeout(req.onTimeoutInternal,req.timeout);}req.xmlHttpRequest.send(content);}};
req.handleArguments =
function(args){for(var i in args){if(typeof(req[i])=="undefined"){req.parameters[i] =args[i];}else{req[i] =args[i];}}};
req.getAllResponseHeaders =
function(){if(req.xmlHttpRequest!=null){if(req.responseReceived){return req.xmlHttpRequest.getAllResponseHeaders();}alert("Cannot getAllResponseHeaders because a response has not yet been received");}};
req.getResponseHeader =
function(headerName){if(req.xmlHttpRequest!=null){if(req.responseReceived){return req.xmlHttpRequest.getResponseHeader(headerName);}alert("Cannot getResponseHeader because a response has not yet been received");}};
return req;}AjaxRequest.getXmlHttpRequest =function(){if(window.XMLHttpRequest){ http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) {http_request.overrideMimeType('text/xml');} return http_request;}else if(window.ActiveXObject){ try {http_request = new ActiveXObject("Msxml2.XMLHTTP");return http_request;} catch (e) { try {http_request = new ActiveXObject("Microsoft.XMLHTTP");return http_request;} catch (e) {}}}else{return null;}};
AjaxRequest.isActive =function(){return(AjaxRequest.numActiveAjaxRequests>0);};
AjaxRequest.get =function(args){AjaxRequest.doRequest("GET",args);};
AjaxRequest.post =function(args){AjaxRequest.doRequest("POST",args);};
AjaxRequest.doRequest =function(method,args){if(typeof(args)!="undefined" && args!=null){var myRequest =new AjaxRequest();
myRequest.method =method;
myRequest.handleArguments(args);
myRequest.process();}};
AjaxRequest.submit =function(theform, args){var myRequest =new AjaxRequest();
if(myRequest==null){return false;}var serializedForm =AjaxRequest.serializeForm(theform);
myRequest.method =theform.method.toUpperCase();
myRequest.url =theform.action;
myRequest.handleArguments(args);
myRequest.queryString =serializedForm;
myRequest.process();
return true;};
AjaxRequest.serializeForm =function(theform){var els =theform.elements;
var len =els.length;
var queryString ="";
this.addField =
function(name,value){if(queryString.length>0){queryString +="&";}queryString +=encodeURIComponent(name) + "=" + encodeURIComponent(value);};
for(var i=0;i<len;i++){var el =els[i];
if(!el.disabled){switch(el.type){case 'text': case 'password': case 'hidden': case 'textarea':
this.addField(el.name,el.value);
break;
case 'select-one':
if(el.selectedIndex>=0){this.addField(el.name,el.options[el.selectedIndex].value);}break;
case 'select-multiple':
for(var j=0;j<el.options.length;j++){if(el.options[j].selected){this.addField(el.name,el.options[j].value);}}break;
case 'checkbox': case 'radio':
if(el.checked){this.addField(el.name,el.value);}break;}}}return queryString;};
AjaxRequest.numActiveAjaxRequests =0;
AjaxRequest.numActiveAjaxGroupRequests =new Object();
AjaxRequest.numAjaxRequests =0;


function checkEmailSetting(formid,type)
{
	AjaxRequest.get(
		{ 
		'url':'checkEmailSetting.cfm?formid='+formid
		,'onSuccess':function(req)
		{ //alert(req.responseText);
		//hidediv("divStayTopLeft");
		xmldoc = req.responseXML;
		var status = xmldoc.getElementsByTagName("status").item(0);
		var statusvalue = status.firstChild.data;
		//alert(statusvalue);
		//alert(type);
		if(statusvalue == 1)
		{
			if(type==1)
				hidediv("email")
			else
				hidediv("Temail")
			//alert("Comment Successfully Added");
		}
		else
		{
			if(type==1)
				showdiv("email")
			else
				showdiv("Temail")
		}
		}
		});
}*/

/*function AjaxRequest(url)
{
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
             http_request.overrideMimeType('text/xml');                
        }		
	} 
	else if (window.ActiveXObject) { // IE
	http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
	http_request.onreadystatechange = function() { alertContents(http_request); };
    http_request.open('GET', url, true);
    http_request.send(null);
}

function alertContents(http_request) 
{
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            alert(http_request.responseText);
        } else {
            alert('There was a problem with the request.');
        }
    }

}*/

function AjaxRequest(url, type, edit)
{
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
             http_request.overrideMimeType('text/xml');                
        }		
	} 
	else if (window.ActiveXObject) { // IE	
	http_request = new ActiveXObject("Microsoft.XMLHTTP");
	/*if (http_request.overrideMimeType) {
             http_request.overrideMimeType('text/xml');                
        }*/	
	}
	if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }	
	http_request.onreadystatechange = function() { alertContents(http_request, type, edit); };
    http_request.open('GET', url, true);
    http_request.send(null);
}

/*function AjaxRequest(url,path)
{
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
             http_request.overrideMimeType('text/xml');                
        }		
	} 
	else if (window.ActiveXObject) { // IE	
	http_request = new ActiveXObject("Microsoft.XMLHTTP");
	/*if (http_request.overrideMimeType) {
             http_request.overrideMimeType('text/xml');                
        }	
	}
	if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }	
	http_request.onreadystatechange = function() { access_image(http_request,path); };
    http_request.open('GET', url, true);
    http_request.send(null);
}*/

function access_image(http_request,path)
{
	 if (http_request.readyState == 4) 
	 {
        if (http_request.status == 200) 
		{
            //alert(http_request.responseText);
			//hidediv("divStayTopLeft");					
			xmldoc = http_request.responseXML;
			var stat = xmldoc.getElementsByTagName("status").item(0);
			var statusvalue = stat.firstChild.data;	
			var str = '';
			str = str + '<img src="'+path+'captcha/'+statusvalue+'.jpg">';
			var divupload_captcha=document.getElementById("upload_captcha");
			divupload_captcha.innerHTML = str;
			//alert(str);
			return false;
		}
	}
}

function alertContents(http_request, type, edit) 
{
		
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            //alert(http_request.responseText);
			hidediv("divStayTopLeft");			
			xmldoc = http_request.responseXML;
			var stat = xmldoc.getElementsByTagName("status").item(0);
			var statusvalue = stat.firstChild.data;			
			if(statusvalue == 1)
			{
				if(edit==0){
					if(type==1)
						hidediv("email")
					else
						hidediv("Temail")
					}
				else{
					if(type==1)
						showdiv("email")
					else
						showdiv("Temail")
					
				}
				//alert("Comment Successfully Added");
			}
			else
			{ var str = '';
			  str = str + '<table align="left" border="0" cellspacing="0" cellpadding="0" width="100%" align="center" bgcolor="c0c0c0"><tr>';
			  str = str + '<td width="60%">Send form data using this email id</td>';
			  str = str + '<td colspan="2"><input type="Radio" name="Smail" value="1">&nbsp;&nbsp;&nbsp;&nbsp;<input type="Radio" name="Smail" value="0" checked></td>';
			  str = str + '</tr></table>';
			 
			    if(type==1)
				{
					var divsemail=document.getElementById("email");
					divsemail.innerHTML = str;
					showdiv("email");
				}
				else
				{
					var divsemail=document.getElementById("Temail");
					divsemail.innerHTML = str;
					showdiv("Temail");
				}
			}
        } else {
            alert('There was a problem with the request.');
        }
    }

}
function resetdiv(formid,type, edit)
{
	var str='';
	if(type==1)
	{
		if (edit==0)
		{
			var divsemail=document.getElementById("email");
			divsemail.innerHTML = str;
			showdiv("email");
		}
		else{
			hidediv("email");
		}
	}
	else
	{
		if (edit==0)
		{
			var divsemail=document.getElementById("Temail");
			divsemail.innerHTML = str;
			showdiv("Temail");
		}
		else{
			hidediv("Temail");
		}
	}
}

function checkEmailSetting(formid,type,edit)
{
	showdiv("divStayTopLeft");		
	AjaxRequest('checkEmailSetting.cfm?formid='+formid, type, edit);
}

function JSFX_FloatTopLeft()
{
	var startX = 500, startY = 500;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	var px = document.layers ? "" : "px";
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
		el.x = startX; el.y = startY;
		return el;
	}
	window.stayTopLeft=function()
	{
		var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 40);
	}
	ftlObj = ml("divStayTopLeft");
	stayTopLeft();
}
function redirect_onnewpage(sectionid)
{	
	window.location="form.cfm?sectionid="+sectionid;
}
function Windowclose()
{
	window.close();
}


