function addNewName()
{
	var present = false;
	var sel_list_Box = document.frmNewUser.selectedaddress; 
	var inputText = document.frmNewUser.txtEMailID.value;
	var inputfirstname = document.frmNewUser.txtFirst_Name.value;
	var inputlastname = document.frmNewUser.txtLast_Name.value;
	var inputValue =  inputfirstname+ " "+ inputlastname + " " + "< " + inputText + ">";
	var selectLenght = document.frmNewUser.selectedaddress.length;
	var myNewOption = new Option(inputValue,inputText);
	for (var i=0; i < sel_list_Box.length; i++)
	{ 
		 var listValue = sel_list_Box.options[i].text;
		 if (inputValue == listValue) 
		 {
				present = true;
		 }
     }
	 // Check the presence of ID the address book
	 var sel_Add_list_Box = document.frmNewUser.txtAddress_Book; 
	 for (var i=0; i < sel_Add_list_Box.length; i++)
	{ 
		 var listValue1 = sel_Add_list_Box.options[i].text;
		 if (inputValue == listValue1) 
		 {
				present = true;
		 }
		 
     }
	
	if (present == true)
	{
				alert("User already exist");
				document.frmNewUser.txtFirst_Name.setfocus;
				return false;
	}
	else
	{
		document.frmNewUser.selectedaddress.options[selectLenght] = myNewOption;
		document.frmNewUser.txtFirst_Name.value = "";
		document.frmNewUser.txtLast_Name.value ="";
		document.frmNewUser.txtEMailID.value="";
	}
}


function addtext()
{
	var cmbFrom_List = document.frmNewUser.txtAddress_Book;
	var cmbTo_List = document.frmNewUser.selectedaddress;
	
	var listText = cmbFrom_List.options[cmbFrom_List.selectedIndex].text;
	var listValue = cmbFrom_List.options[cmbFrom_List.selectedIndex].value;
	var selectLenght = cmbTo_List.length;
	//alert(listText);
	var myNewOption = new Option(listText,listValue);
	cmbTo_List.options[selectLenght] = myNewOption;
	cmbFrom_List.options[cmbFrom_List.selectedIndex] = null;
}

function fnSubmit()
{
   var sel_list_Box = document.frmNewUser.selectedaddress;
   selectAll(sel_list_Box,true);
   document.frmNewUser.submit();
}
function removetext()
{

    var cmbFrom_List = document.frmNewUser.selectedaddress;
	var cmbTo_List = document.frmNewUser.txtAddress_Book;;
	
	var listText = cmbFrom_List.options[cmbFrom_List.selectedIndex].text;
	var listValue = cmbFrom_List.options[cmbFrom_List.selectedIndex].value;
	var selectLenght = cmbTo_List.length;
	
	var myNewOption = new Option(listText,listValue);
	cmbTo_List.options[selectLenght] = myNewOption;
	cmbFrom_List.options[cmbFrom_List.selectedIndex] = null;

}

function selectAll(cbList,bSelect) {
  for (var i=0; i<cbList.length; i++) 
    cbList[i].selected = cbList[i].checked = bSelect
}
function toggleDiv(e, link) {
  var imageTitle;
  var div = document.getElementById(e);
  var linkDiv = document.getElementById(link);
  var display = div.style.display;

  if (display == "none") {
    div.style.display = "block";
    imageTitle = "grn_dn.gif";
  }
  else if (display == "block") {
    div.style.display = "none";
    imageTitle = "grn_rt.gif";
  }
  if(linkDiv != null) {
  	linkDiv.innerHTML = "<a href=\"\" onClick=\"toggleDiv('" + e + "','" + link + "'); return false;\"><img src=\"/images/06/arrows/"+ imageTitle +"\" width=\"11\" height=\"11\" border=\"0\"></a>";
  }
}
	
function toggleDivForRegistry(e, link) {
	  var imageTitle;
	  var div = document.getElementById(e);
	  var linkDiv = document.getElementById(link);
	  var display = div.style.display;

	  if (display == "none") {
	    div.style.display = "block";
	    imageTitle = "grn_dn.gif";
	  }
	  else if (display == "block") {
	    div.style.display = "none";
	    imageTitle = "grn_rt.gif";
	  }
	  if(linkDiv != null) {
	  	linkDiv.innerHTML = "<a href=\"\" onClick=\"toggleRegistryDiv(); return false;\"><img src=\"/images/06/arrows/"+ imageTitle +"\" width=\"11\" height=\"11\" border=\"0\"></a>" +
	  					   "<img src='/images/t.gif' width='5' height='1'><a href=\"\" onClick=\"toggleRegistryDiv(); return false;\" class=\"crGreen\">Add a Target Registry</a>";
	  }
	}

function toggleRegistryDiv(){
	var eventType = document.frmCreate_Invitation.eventType.value;
	var registryCouple = document.frmCreate_Invitation.registryCouple.value;
	var registryType = document.frmCreate_Invitation.registryType.value;
	if(isNull(registryCouple) == true && (eventType == 'Wedding_Themes_top' || eventType == 'Baby_Shower_top')){
		if(eventType == 'Wedding_Themes_top'){
			toggleDivForRegistry('regWedding','addRegistryDiv');
		} else if(eventType == 'Baby_Shower_top'){
			toggleDivForRegistry('regBaby','addRegistryDiv');
		}
	} else if(isNull(registryType) == false){
		if(registryType == 'wedding'){
			changeDivTag('regWedding','none');
			toggleDivForRegistry('regWeddingConfirm','addRegistryDiv');
		} else if(registryType == 'babyreg'){
			changeDivTag('regBaby','none')
			toggleDivForRegistry('regBabyConfirm','addRegistryDiv');
		}			
	}
}

function displayRegistryDiv(){
	var eventType = document.frmCreate_Invitation.eventType.value;
	var registryCouple = document.frmCreate_Invitation.registryCouple.value;

      if(show_registry == true){
 	    if(eventType == 'Wedding_Themes_top'){
 		   if(isNull(registryCouple)){
 		   	 toggleRegistryDiv();
 		   	 changeDivTag('regBaby', 'none');
    			// changeDivTag('regWedding','block');
    			// changeDivTag('regBaby','none');
    		   }
 		   changeDivTag('addRegistryDiv','block');
 	    } else if(eventType == 'Baby_Shower_top'){
 		   if(isNull(registryCouple)){
 		     toggleRegistryDiv();
 		     changeDivTag('regWedding', 'none');
    			 // changeDivTag('regBaby','block');
    			 // changeDivTag('regWedding','none');
 		   }
    		   changeDivTag('addRegistryDiv','block');
    	    } else {
    		   changeDivTag('regWedding','none');
    		   changeDivTag('regBaby','none');
    		   if(isNull(registryCouple)){
    		   	  changeDivTag('addRegistryDiv','none');
    		   } else {
    		      changeDivTag('addRegistryDiv','block');
    		   }
        }	     	
   
      }
}

function displayGiftExchangeDiv(){
	var eventType = document.frmCreate_Invitation.eventType.value;
	if(eventType == 'gift_exchange'){
		changeDivTag('gift','block');
	} else {
		if(document.frmCreate_Invitation.includeGiftExchange.checked == false){
			changeDivTag('gift','none');
		}
	}
}

function submitTargetRegistryBabyForm(){
	var firstName = document.frmCreate_Invitation.targetFirstnameBaby.value;
	var lastName = document.frmCreate_Invitation.targetLastnameBaby.value;
	var targetRoleValue = getRadioValue(document.frmCreate_Invitation.targetRoleBaby);
	var url = "/app/invitations/create/target/getTargetRegistryInfo.do";
	url += "?firstname=" + firstName + "&lastname=" + lastName;
	url += "&location="+ document.frmCreate_Invitation.targetLocationBaby.value;
	url += "&eventMonth="+ document.frmCreate_Invitation.targetEventMonthBaby.value;
	url += "&role=" + targetRoleValue;
	url += "&type=babyreg";
	url += "&newSearch=true";
	if(isNull(firstName) == true || isNull(lastName) == true){
		alert('The first & last names are required.');
	} else {
		popupWin(url,'613', '580','yes','yes','no','no','DependentWindow','no','no','center');
	}
}
















function frmvalidator(theForm)
{
  if (theForm.txtName.value.length < 1)
  {
    alert("Please enter your full name .");
    theForm.txtName.focus();
    return (false);
  }
  if (theForm.txtCity.value.length < 1)
  {
    alert("Please enter City ");
    theForm.txtCity.focus();
    return (false);
  }
  if (theForm.txtState.value.length < 1)
  {
    alert("Please enter state ");
    theForm.txtState.focus();
    return (false);
  }
  if (theForm.txtZip_Code.value.length < 4)
  {
    alert("Please enter valid  zip code ");
    theForm.txtZip_Code.focus();
    return (false);
  }
   if (theForm.txtAddress.value.length < 4)
  {
    alert("Please enter address ");
    theForm.txtAddress.focus();
    return (false);
  }
 
  // E-mail Validator Code
  if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.txtEmail.value))) 
  {
		//  do nothing
  }
  else
  {
	alert("Invalid E-mail Address! Please re-enter.")
	theForm.txtEmail.focus();
	return (false);
  }
  
    if (theForm.txtSummary.value.length < 10)
  {
    alert("Please enter summary for your resume ");
    theForm.txtSummary.focus();
    return (false);
  }
  
  if (theForm.txtSkillSet_Des.value.length < 4)
  {
    alert("Please enter words for skill set ");
    theForm.txtSkillSet_Des.focus();
    return (false);
  }
  
  if (theForm.txtCurrent_Position.value.length < 1)
  {
    alert("Please enter current position or designation, which will be displayed with resume title. ");
    theForm.txtCurrent_Position.focus();
    return (false);
  }

  return (true);
}

function frmvalidatorjob(theForm)
{
  if (theForm.txtJobDetail.value.length < 1)
  {
    alert("Please enter job details .");
    theForm.txtJobDetail.focus();
    return (false);
  }
  if (theForm.txtCompanyName.value.length < 1)
  {
    alert("Please enter company name ");
    theForm.txtCompanyName.focus();
    return (false);
  }
  if (theForm.txtKeywords.value.length < 1)
  {
    alert("Please enter Keywords ");
    theForm.txtKeywords.focus();
    return (false);
  }
  if (theForm.txtJobOpening.value.length < 1)
  {
    alert("Please enter number of job opening. ");
    theForm.txtJobOpening.focus();
    return (false);
  }
   if (theForm.txtPosted.value.length < 1)
  {
    alert("Please enter Text Posted ");
    theForm.txtPosted.focus();
    return (false);
  }
  
  if (theForm.txtPositionTitle.value.length < 1)
  {
    alert("Please enter Position Title  ");
    theForm.txtPositionTitle.focus();
    return (false);
  }
    if (theForm.txtOffPositionTitle.value.length < 1)
  {
    alert("Please enter Official Position Title  ");
    theForm.txtOffPositionTitle.focus();
    return (false);
  }
  if (theForm.txtPositionDes.value.length < 1)
  {
    alert("Please enter Position Description  ");
    theForm.txtPositionDes.focus();
    return (false);
  }
  if (theForm.txtLocation.value.length < 1)
  {
    alert("Please enter Location  ");
    theForm.txtLocation.focus();
    return (false);
  }

  // E-mail Validator Code
  if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.txtEmail.value))) 
  {
		//  do nothing
  }
  else
  {
	alert("Invalid E-mail Address! Please re-enter.")
	theForm.txtEmail.focus();
	return (false);
  }
  
    if (theForm.txtCompanyDes.value.length < 5)
  {
    alert("Please enter company Description ");
    theForm.txtCompanyDes.focus();
    return (false);
  }
  return (true);
}


function fnOpenWindow(theURL)
{
 var winName = "Character";
 var features = "toolbar=0,left=50,top=50,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=400,height=400"
 window.open(theURL,winName,features);
}
function fnOpenWindow1(theURL)
{
 var winName = "Character";
 var features = "toolbar=0,left=100,top=100,location=0,status=0,menubar=1,scrollbars=1,resizable=1,width=800,height=600"
 window.open(theURL,winName,features);
 
}
function fnOpenWindowForPDF(theURL)
{
 var winName = "Character";
 window.open(theURL,winName);
}
function fnclose()
{
	window.close()
}
function fnOpenWindowSmall(theURL)
{
 var winName = "Character";
 var features = "toolbar=0,left=100,top=100,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=200"
 window.open(theURL,winName,features);
}
		 
function fnOpenWindowSmall1(theURL)
{
 var winName = "Character";
 var features = "toolbar=0,left=500,top=200,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=100"
 window.open(theURL,winName,features);
}
function toUp(tci)
{
   tci.value =  tci.value.toUpperCase();
}



