﻿if (typeof(window.onload) == 'function')
{
    var f = window.onload;
    window.onload = function() {
//        f();
        myWindowOnLoad();
    };
}
else
{
    window.onload = myWindowOnLoad;
}

function myWindowOnLoad()
{
    var clist = azblue.aspxControls.ContactOrNotList
// this function is called here to handle a refresh of a page after the user 
// selects "yes". In this case the contact info form should continue to be displayed
   ContactOrNotList_SelectedIndexChanged()
    
    if (clist != null) {
        clist.onchange = ContactOrNotList_SelectedIndexChanged;
    }
}

String.prototype.trim = function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}; 

function RadioButtonList_ClientValidate(sender, args)
{   
    var elementsList = document.getElementsByTagName("input");
    args.IsValid = false ;
    for (var i = 0 ; i < elementsList.length ; i++) 
    {
       if (elementsList[i].type == "radiobutton") 
       {
           args.IsValid = args.IsValid || elementsList[i].checked ;
       }
    }
}

function nameTextBox_ClientValidate(sender, args)
{
      var nameTextBox = azblue.aspxControls.name;
      var ContactOrNotList = azblue.aspxControls.ContactOrNotList ;
      if (ContactOrNotList.selectedIndex == 1)
      {
            if (nameTextBox.value.length < 1) 
            {
                args.isValid = false ;
            }
      }   
}

// function toggleElementDisplay(id) {
//    var elem = $(id);
//    if (elem != null) {
//        if (elem.style.display == 'block')
//            elem.style.display = 'none';
//        else
//            elem.style.display = 'block';
//    }
// }

 function setElementDisplay(id, show) {
    var elem = $(id);
    if (elem != null) {
        elem.style.display = (show) ? 'block' : 'none';
    }
 }

 function  ContactOrNotList_SelectedIndexChanged()
 {
    if (azblue.aspxControls.ContactOrNotList != null) {
        show = (azblue.aspxControls.ContactOrNotList.selectedIndex == 1);
        setElementDisplay('contactInformationDiv', show);
    }
    //
    //
//   // var dropDownList = document.getElementById("ctl00$ColumnOneContent$ContactOrNotList");
//    //var div = document.getElementById("ctl00_ColumnOneContent_contactInformationDiv");
//   var dropDownList = document.getElementById("ContactOrNotList");
//   var div = document.getElementById("contactInformationDiv");
//   // alert(dropDownList.value);
//	if(dropDownList.value == "No")
//	{

//		//document.getElementById(contact1).style.display = 'block';
//		div.style.display='none';
//	//	alert("No");
//	}else
//	{
//		//document.getElementById(contact1).style.display = 'block';

//		div.style.display='block';
////		alert("Yes");
//		
//	}
 }
	
// function  ContactOrNotList_SelectedIndexChanged2()
// {
//   var dropDownList = document.getElementById("ctl00$ColumnOneContent$ContactOrNotList");
//   var div = document.getElementById("ctl00_ColumnOneContent_contactInformationDiv");
////   var dropDownList = document.getElementById("ContactOrNotList");
////   var div = document.getElementById("contactInformationDiv");
//    alert(dropDownList.value);
//	if(dropDownList.value == "No"){

//		
//		div.style.display='none';
//	    alert("No");
//	}else{
//		div.style.display='block';
//        alert("Yes");
//		
//	}
//        alert(div.style.display);
// }       
 
 function ContactOrNotList_OnLoad()
 {
      alert("Hey There");
//        var dropDownList = document.getElementById("ctl00$ColumnOneContent$ContactOrNotList");
//        var div = document.getElementById("ctl00_ColumnOneContent_contactInformationDiv")
        var dropDownList = azblue.aspxControls.ContactOrNotList ;
        var div = azblue.aspxControls.contactInformationDiv ;
        
        alert(dropDownList.value);
	    if(dropDownList.value == "false"){
	        alert(1);
		    //document.getElementById(contact1).style.display = 'block';
		    div.style='display:none';
		    
	    }else{
		    //document.getElementById(contact1).style.display = 'block';
		    alert(2);
		    div.style='display:inline';
	    }
    	
	    alert(div.display);
 }


