﻿// JScript File
var currObj="padv";
 
var minpwlength = 4;
var fairpwlength = 7;

var STRENGTH_SHORT = 0; // less than minpwlength 
var STRENGTH_WEAK = 1;  // less than fairpwlength
var STRENGTH_FAIR = 2;  // fairpwlength or over, no numbers
var STRENGTH_STRONG = 3;// fairpwlength or over with at least one number

img0 = new Image(); 
img1 = new Image();
img2 = new Image();
img3 = new Image();

img0.src = 'images/tooshort.jpg';
img1.src = 'images/fair.jpg';
img2.src = 'images/medium.jpg';
img3.src = 'images/strong.jpg';

var tablingcentre = "";

function changeblurtext(object,text)
{
    if(object!=null)
    {
        if(trim(object.value)=="")
        {
            object.value = text;
        }
    }
}
function changefocustext(object,text)
{
    if(object!=null)
    {
        if(trim(object.value)==text)
        {
            object.value = "";
        }
    }
}
function LTrim( value ) 
{				
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");				
}
	
// Removes ending whitespaces
function RTrim( value ) 
{				
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");				
}

// Removes leading and ending whitespaces
function trim( value ) 
{					
	return LTrim(RTrim(value));					
}

function restrictChars(e, validList)  
{  
    var key, keyChar;  
    key = getKey(e);  
    if (key == null) return true;  
    // get character - remove toLowerCase for case sensitive checking  
    keyChar = String.fromCharCode(key).toLowerCase();  
    // check valid characters - remove toLowerCase for case sensitive checking  
    if (validList.toLowerCase().indexOf(keyChar) != -1)  
    return true;  
    // control keys  
    // null, backspace, tab, carriage return, escape  
    if ( key==0 || key==8 || key==9 || key==13 || key==27 )  
       return true;  
    // else return false  
    return false;  
} 
function numericOnly(e,validList)  
{
    return restrictChars( e, validList);
    //return restrictChars( e, "0123456789+ ");
} 

function getKey(e)  
{  
    if (window.event)  
       return window.event.keyCode;  
    else if (e)  
       return e.which;  
    else  
      return null;  
}

function showthis(divObj,className,showobj,displayobj)
{
	clearInterval(intervalId);
    document.getElementById("padv").style.display="none";
    document.getElementById("ppub").style.display="none";
    document.getElementById("pmar").style.display="none";
	
	document.getElementById("divadvertisersignup").style.display="none";
    document.getElementById("divpublishersignup").style.display="none";
    document.getElementById("divmarketplace").style.display="none";
    
    document.getElementById("divadv").className = "advertisers";
    document.getElementById("divpub").className="publishers";
    document.getElementById("divmar").className="marketplace";
    
    if(document.getElementById(showobj)!=null)
    {
        currObj = showobj;
        document.getElementById(showobj).style.display="";
    }	  
	if(document.getElementById(displayobj)!=null)
    {
        document.getElementById(displayobj).style.display="";
    }	 
    if(divObj!=null)
    {
        divObj.className=className;
    }  
	currentDiv = divObj.id;
}

var intervalId;
var currentDiv = "";

function restartHighLighting()
{
	moveHighlighting();
}

function moveHighlighting()
{
	if(currentDiv=="")
	{
		currentDiv = "divadv";
	}
	moveFocus();
	//intervalId = setInterval("moveFocus()",3000);
}

function CheckTextAreaLength(e,id)
{
    var charLength=0;
    if(document.getElementById(id) != null)
    {
        charLength = document.getElementById(id).value.length;
        if(charLength > 450 && getKeyCode(e) != 8 && getKeyCode(e) != 46)// 8 and 46 are the key codes for delete and backspace
        {
            return false;
        }
        else
        {
            return true;
        }
    }    
}

function getKeyCode(e) {
var keycode;
if (window.event) 
{
    keycode = window.event.keyCode;
}
else if(e)
{
    keycode = e.which;
}

return keycode;
}


function moveFocus()
{
	document.getElementById("padv").style.display="none";
    document.getElementById("ppub").style.display="none";
    document.getElementById("pmar").style.display="none";
	
	document.getElementById("divadvertisersignup").style.display="none";
    document.getElementById("divpublishersignup").style.display="none";
    document.getElementById("divmarketplace").style.display="none";
    
    document.getElementById("divadv").className = "advertisers";
    document.getElementById("divpub").className="publishers";
    document.getElementById("divmar").className="marketplace";
      
	
	if(currentDiv == "divadv")
	{
		document.getElementById("padv").style.display="";
		document.getElementById("divadvertisersignup").style.display="";
		document.getElementById("divadv").className = "advertisers1";
		currentDiv = "divpub";
		return false;
	}
	
	if(currentDiv == "divpub")
	{
		document.getElementById("ppub").style.display="";
		document.getElementById("divpublishersignup").style.display="";
		document.getElementById("divpub").className = "publishers1";
		currentDiv = "divmar";
		return false;
	}
	
	if(currentDiv == "divmar")
	{
		document.getElementById("pmar").style.display="";
		document.getElementById("divmarketplace").style.display="";
		document.getElementById("divmar").className = "marketplace1";
		currentDiv = "divadv";
		return false;
	}
}


function redirecttorequired()
{
    var pagename="advertisersignup.php";
    if(currObj == "padv")
    {
        pagename="advertisersignup.php";    
    }
    else if(currObj == "ppub")
    {
        pagename="publishersignup.php";  
    }
    else if(currObj == "pmar")
    {
        pagename="advertisersignup.php";  
    }
    
    window.location.href = pagename;
}

	
	var strengthlevel = 0;
	
	var strengthimages = Array( img0.src,
								img1.src,
								img2.src,
								img3.src );
	
	function updatestrength( pw ) {
	
		if( istoosmall( pw ) ) {
	
			strengthlevel = STRENGTH_SHORT;
			strengthlevel = "<font color='#676767'>Too short</font>";
	
		}
		else if( !isfair( pw ) ) { 
	
			strengthlevel = STRENGTH_WEAK;
			strengthlevel ="<font color='#008000'>Weak</font>";
			
	
		}	
		else if( hasnum( pw ) ) {
	
			strengthlevel = STRENGTH_STRONG;
			strengthlevel ="<font color='#008000'>Strong</font>";
	
		}
		else {
	
			strengthlevel = STRENGTH_FAIR;
			strengthlevel ="<font color='#f5ac00'>Fair</font>";
	
		}
	
		//document.getElementById( 'strength' ).src = strengthimages[ strengthlevel ];
		document.getElementById( 'spanpasswordstrength' ).innerHTML = strengthlevel;
	
	}
	
	function isfair( pw ) {
	
		if( pw.length < fairpwlength ) {
	
			return false;
	
		}
		else { 
	
			return true;
	
		}
	
	}
	
	function istoosmall( pw ) {
	
		if( pw.length < minpwlength ) {
	
			return true;
	
		}
		else {
	
			return false;

		}
	
	}
	
	function hasnum( pw ) {
	
		var hasnum = false;
	
		for( var counter = 0; counter < pw.length; counter ++ ) {
	
			if( !isNaN( pw.charAt( counter ) ) ) {
	
				hasnum = true;
	
			}
	
		}	
	
		return hasnum;	
	}
	
	// RTI functions
	
	function showOrHideTextField(showField)
	{	
	    if(showField == "Tabler")
	    {
	        document.getElementById('spanName').innerHTML = "Tabler <b>(YOUR)</b> Name <br/>(as listed in the Directory)";
	        document.getElementById('spnCurrTableTitle').innerHTML = "Table that you are currently in";
	    }
	    else if(showField == "SquareLeg")
	    {
            document.getElementById('spanName').innerHTML = "Square Leg <b>(YOUR)</b> Name <br/>(as listed in the Directory)";            
            document.getElementById('spnCurrTableTitle').innerHTML = "Table that you are retired from";
	    }
	    else if(showField == "HonoraryTabler")
	    {            
            document.getElementById('spanName').innerHTML = "HT <b>(YOUR)</b> Name <br/>(as listed in the Directory)";
            document.getElementById('spnCurrTableTitle').innerHTML = "Table that you are currently listed in as an Honorary Tabler";            
	    }   
	}
	
	function bindTablesInDropDown()
	{
	    var areaname = document.getElementById('DDLArea').value;
	    
	    switch(areaname)
	    {
	        case "Area I":
	        BindTables(0);
	        break;
	        
	        case "Area II":
	        BindTables(1);
	        break;
	        
	        case "Area III":
	        BindTables(2);
	        break;
	        
	        case "Area IV":
	        BindTables(3);
	        break;
	        
	        case "Area V":
	        BindTables(4);
	        break;
	        
	        case "Area VI":
	        BindTables(5);
	        break;
	        
	        case "Area VII":
	        BindTables(6);
	        break;
	        
	        case "Area VIII":
	        BindTables(7);
	        break;
	        
	        case "Area IX":
	        BindTables(8);
	        break;
	        
	        case "Area X":
	        BindTables(9);
	        break;
	        
	    }
	}
	
	function BindTables(start)
    {
	    var DDLTableName=document.getElementById("DDLTableName");
	    
	    document.getElementById('DDLTableName').length = 0;
	    
	    var defoption = document.createElement("OPTION");
        defoption.value = "";
        defoption.text = "Select an option";
        DDLTableName.options.add(defoption);
	    		    
	    for(var index = 0; index < 10; index++)
	    {     
	        var option = document.createElement("OPTION");
	        option.value = "Table "  + (start*10 + index);
	        option.text = "Table "  + (start*10 + index);
	        DDLTableName.options.add(option);
	    }
    }
    
    function checkIfotherTextSelected(ddlId)
    {
        var dropDown;
        if(ddlId == 'DDLHowdoyouknow')
        {
          dropDown = document.getElementById('DDLHowdoyouknow'); 
          if(dropDown != null && dropDown.value != "Other")
          {
            //document.getElementById('divOtherHowdoyouknow').style.display = "none";
            document.getElementById('divOtherHowdoyouknow').className = "hideother";
            document.getElementById('txtOtherHowdoyouknow').className = "";
          }
          else
          {
            document.getElementById('divOtherHowdoyouknow').className = "showother";
            //document.getElementById('divOtherHowdoyouknow').style.display = "";
            document.getElementById('txtOtherHowdoyouknow').className = "genericrequiredtext";
          }
        }
        else if(ddlId == 'DDLHowWellDoUKnow')
        {
          dropDown = document.getElementById('DDLHowWellDoUKnow'); 
          
          if(dropDown != null && dropDown.value != "Other")
          {
            document.getElementById('divOtherHowWellDoUKnow').className = "hideother";
            document.getElementById('txtOtherHowWellDoUKnow').className = "";
          }
          else
          {
            document.getElementById('divOtherHowWellDoUKnow').className = "showother";
            document.getElementById('txtOtherHowWellDoUKnow').className = "genericrequiredtext";
          }
        }
        else if(ddlId == 'DDLSpecificTablePreference')
        {
          dropDown = document.getElementById('DDLSpecificTablePreference'); 
          
          if(dropDown != null && dropDown.value != "Other")
          {
            document.getElementById('divOtherPrefSpecificTable').className = "hideother";
            document.getElementById('txtOtherPrefSpecificTable').className = "";
          }
          else
          {
            document.getElementById('divOtherPrefSpecificTable').className = "showother";
            document.getElementById('txtOtherPrefSpecificTable').className = "genericrequiredtext";
          }
        }        
        else
        {
            document.getElementById('divOtherHowdoyouknow').className = "hideother";
            document.getElementById('divOtherHowWellDoUKnow').className = "hideother";
            
            document.getElementById('txtOtherHowdoyouknow').className = "";
            document.getElementById('txtOtherHowWellDoUKnow').className = "";
        }
    }
    
    function sendmail(prospectname, prospectcityname, areaname , tablename, prospectAge, prospectEmail, prospectPhone, mailto)
    {
        var email="";
        var name="";
        var phone="";
        var comments="";
        var _url = "includes/mail.php";  
        
        
        _url += "?pname="+prospectname+"&pcity="+prospectcityname+ "&areaname="+areaname+"&tablename="+tablename+"&pAge="+prospectAge+"&pEmail="+prospectEmail+"&pPhone="+prospectPhone+"&mailto="+mailto;          
        
        try
        {
		    var xmlHttp = new XMLHTTP();	    
    		
		    xmlHttp.SendGETRequest(_url, function()
                                                {
									                if(xmlHttp.xmlHttpClient.readyState == 4)
								                    {
				   							            if(xmlHttp.xmlHttpClient.responseText != null )
				   							            {
				   							                if(mailto != "admin")
				   							                {

				   							                }
				   							                else
				   							                {
				   							                    sendmail(prospectname, prospectcityname, areaname , tablename, prospectAge, prospectEmail, prospectPhone,"user");
				   							                }
    			   							                			   							            
				   							            }
    				   							  
				   							        }
				   							    }
				   				    );	
    				   							        
        }
        catch(err)
        {}
    }
    
    function setFocus(id)
    {
       if(document.getElementById(id) != null)
        {
            document.getElementById(id).focus();
            return false; 
        }
    }
    
    
// Binding Drop Downs Areas, cities and tables

function getData(type,areaid,cityid)
{
    var _url = "private/common/phpAjax.php";
    
    if(type == "areas")
    {
        _url += "?from=personalinfo&type="+type;
    }
    else if(type == "tablesForSpecPreference")
    {        
        _url += "?from=personalinfo&type="+type+"&cityid="+cityid;
    }
    else
    {        
        _url += "?from=personalinfo&type="+type+"&areaid="+areaid;
    }
    
    try
    {
	    var xmlHttp = new XMLHTTP();        
		
        xmlHttp.SendGETRequest(_url, function()
                                            {
				                                if(xmlHttp.xmlHttpClient.readyState == 4)
			                                    {  
			                                        //alert(xmlHttp.xmlHttpClient.responseText);
						                            if(xmlHttp.xmlHttpClient.responseXML != null )
						                            {
						                               if(type == "areas")
						                                {
						                                    bindData(xmlHttp.xmlHttpClient.responseXML, type);
						                                }
						                                else if(type == "cities")
						                                {
						                                    bindData(xmlHttp.xmlHttpClient.responseXML, type);
						                                }
						                                else if(type == "tables")
						                                {
						                                    bindData(xmlHttp.xmlHttpClient.responseXML, type);
						                                }
						                                else if(type == "tablesForSpecPreference")
						                                {
						                                    bindData(xmlHttp.xmlHttpClient.responseXML, type);
						                                }
						                            }
						                            else
						                            {				   							                    
                                                        
						                            }
						                        }
						                    }
			                    );
												
    }
    catch(err)
    {}
}

function getTablesByArea()
{
     var ddlArea = document.getElementById("DDLArea");
     if(ddlArea != null)
     {
        var areaid = ddlArea.value;        
        saveAreaName();
        
        // Removing the options from the Table DropDown
        if(document.getElementById('DDLTableName') != null)
        {   
		    var ddlTables = document.getElementById("DDLTableName");
		    
            ddlTables.length = 0;
            
            var defoption = document.createElement("OPTION");
            defoption.value = "";
            defoption.text = "Select an option";
            ddlTables.options.add(defoption);   
        }
                
        getData("tables",areaid,0);
     }
     else
     {
        return false;
     }
}

function getTablesByCity(cityid)
{    
     if(cityid > 0)
     {  
        document.getElementById('divOtherPrefSpecificTable').className = "hideother";
        document.getElementById('txtOtherPrefSpecificTable').value = "";
        
        // Removing the options from the Specific Preference Table DropDown
        if(document.getElementById('DDLSpecificTablePreference') != null)
        {
            var ddlTables = document.getElementById("DDLSpecificTablePreference");
            
            ddlTables.length = 0;	        
            
            var defoption = document.createElement("OPTION");
            defoption.value = "";
            defoption.text = "Select an option";
            ddlTables.options.add(defoption);
         }
                
        getData("tablesForSpecPreference",0,cityid);
     }
     else
     {
        return false;
     }
}

/* ##############  response is xml from Ajaxphp ############################   */

function bindData(response,type)
{
   if(response != null)
   {
       if(response.documentElement != null)
       {
            if(type == "areas")
            {
                var areas = response.documentElement.getElementsByTagName("areas");		
		        var ddlArea = document.getElementById("DDLArea");		        
		        
		        if(ddlArea == null)
		        {
		            return;
		        }

		        for(var index = 0; index < areas.length; index++)
		        { 
	                var areaInfo = new AreaInfo(areas[index]); 
	                var option = document.createElement("OPTION");
	                option.value = areaInfo.areaid;
	                option.text = areaInfo.name;
	                ddlArea.options.add(option);
	                
	                // This is used only in Reports section to bind the Areas of Recommender based search
	                /*if(document.getElementById("DDLRecommenderArea") != null)
	                {
	                    document.getElementById("DDLRecommenderArea").options.add(option);
	                }*/                			
		        }
		        // This is to bind the search param value in Reports section (Only required in Reports section)
		        if(document.getElementById('hidAreaId') != null)
		        {
		            setSelectedValueInDropDown("DDLArea",document.getElementById('hidAreaId').value);
		        }	        		        
            }
            else if(type == "cities")
            {
                var cities = response.documentElement.getElementsByTagName("cities");		
		        var ddlCities = document.getElementById("City");
		        
		        if(ddlCities == null)
		        {
		            return;
		        }
			   
		        for(var index = 0; index < cities.length; index++)
		        { 
	                var cityInfo = new CityInfo(cities[index]); 
	                var option = document.createElement("OPTION");
	                option.value = cityInfo.multiparamter;
	                option.text = cityInfo.name;
	                ddlCities.options.add(option);    				
		        }
            }
            else if(type == "tables")
            {
                var tables = response.documentElement.getElementsByTagName("tables");		
		        var ddlTables = document.getElementById("DDLTableName");
		        
		        document.getElementById('DDLTableName').length = 0;
		        
		        if(ddlTables == null)
		        {
		            return;
		        }
		        
		        var defoption = document.createElement("OPTION");
                defoption.value = "";
                defoption.text = "Select an option";
                ddlTables.options.add(defoption);	        
		        
			   
		        for(var index = 0; index < tables.length; index++)
		        { 
	                var tableInfo = new TableInfo(tables[index]); 
	                var option = document.createElement("OPTION");
	                option.value = tableInfo.tableid;
	                option.text = tableInfo.tablenoAndName;
	                ddlTables.options.add(option);    				
		        }
            }
            else if(type == "tablesForSpecPreference")
            {
                var tables = response.documentElement.getElementsByTagName("tables");		
		        var ddlTables = document.getElementById("DDLSpecificTablePreference");
		        
		        document.getElementById('DDLSpecificTablePreference').length = 0;
		        
		        if(ddlTables == null)
		        {
		            return;
		        }
		        
		        var defoption = document.createElement("OPTION");
                defoption.value = "";
                defoption.text = "Select an option";
                ddlTables.options.add(defoption);		        
			   
		        for(var index = 0; index < tables.length; index++)
		        { 
	                var tableInfo = new TableInfo(tables[index]); 
	                var option = document.createElement("OPTION");
	                option.value = tableInfo.tablenoAndName;
	                option.text = tableInfo.tablenoAndName;
	                ddlTables.options.add(option);    				
		        }
		        
		        if(tables.length == 0)
		        {
		            document.getElementById("DDLSpecificTablePreference").disabled = true;
		            document.getElementById("divDisableSpecPref").style.display = "";
		            document.getElementById("divDisableText").innerHTML = "This is still a proposed Tabling centre.  If a Table is currently being started, the Contact details of the <em>Buddy</em> you are recommending will be sent to the Sponsor Table(s) and they will take it forward";
		            
		            document.getElementById('divOtherPrefSpecificTable').className = "hideother";
		        }
		        else if(tables.length == 1)
		        {
		            if(tablingcentre != null && tablingcentre == "Current Tabling Centre")
		            {
		                document.getElementById("DDLSpecificTablePreference").disabled = true;
		                document.getElementById("divDisableSpecPref").style.display = "";
		                document.getElementById("divDisableText").innerHTML = "As there is only Table in this city, the details of the <em>Buddy</em> that you are recommending will be sent directly to them";
		                
		                document.getElementById('divOtherPrefSpecificTable').className = "hideother";
		            }
		            else
		            {
		                document.getElementById("DDLSpecificTablePreference").disabled = true;
		                document.getElementById("divDisableSpecPref").style.display = "";
		                document.getElementById("divDisableText").innerHTML = "This is still a proposed Tabling centre.  If a Table is currently being started, the Contact details of the <em>Buddy</em> you are recommending will be sent to the Sponsor Table(s) and they will take it forward";
		                
		                document.getElementById('divOtherPrefSpecificTable').className = "hideother";
		            }		            
		        }
		        else
		        {
		            if(tablingcentre != null && tablingcentre == "Current Tabling Centre")
		            {
		                document.getElementById("DDLSpecificTablePreference").disabled = false;
		                document.getElementById("divDisableSpecPref").style.display = "none";
		                document.getElementById("divDisableText").innerHTML = "";
		            }
		            else
		            {
		                document.getElementById("DDLSpecificTablePreference").disabled = true;
		                document.getElementById("divDisableSpecPref").style.display = "";
		                document.getElementById("divDisableText").innerHTML = "This is still a proposed Tabling centre.  If a Table is currently being started, the Contact details of the <em>Buddy</em> you are recommending will be sent to the Sponsor Table(s) and they will take it forward";
		                
		                document.getElementById('divOtherPrefSpecificTable').className = "hideother";
		            }    
		        }
		        
		        var defoptionOther = document.createElement("OPTION");
                defoptionOther.value = "Other";
                defoptionOther.text = "Other";
                ddlTables.options.add(defoptionOther);               
                
            }            	    
       }       	
   }	
}

function showOrHideAdditionalInfo(visibility)
{    
    if(visibility != null)
    {
        if(visibility == "show")
        {
            document.getElementById('divMaritalStatus').style.display = "";
            document.getElementById('divAge').style.display = "";
            document.getElementById('divProfOccupation').style.display = "";
            document.getElementById('divPromptLink').style.display = "none";
            document.getElementById('divHideLink').style.display = "";            
        }
        else if(visibility == "hide")
        {
            document.getElementById('divMaritalStatus').style.display = "none";
            document.getElementById('divAge').style.display = "none";
            document.getElementById('divProfOccupation').style.display = "none";
            document.getElementById('divPromptLink').style.display = "";
            document.getElementById('divHideLink').style.display = "none";
        }
         
        document.getElementById("DDLMaritalStatus").selectedIndex = 0;
        document.getElementById("DDLAge").selectedIndex = 0;
        document.getElementById("DDLProfOccupation").selectedIndex = 0;
    }    
}

function bindAreaandTablingCentre()
{
    var ddlCities = document.getElementById("City");
	var splitArray = new Array();
	var area = "";	
	var cityid = 0;
	
    if(ddlCities != null)
    {
        //alert(ddlCities.value);
        if(ddlCities.value != "")
        {
            var strArray = ddlCities.value;            
            splitArray = strArray.split("#");
            
            if(splitArray.length > 2)
            {
                area = splitArray[2];
            }
            if(splitArray.length > 3)
            {
                tablingcentre = splitArray[3];
                
                if(tablingcentre == "CT")
                {
                    tablingcentre = "Current Tabling Centre";
                }
                else if(tablingcentre == "PT")
                {
                    tablingcentre = "Proposed Tabling Centre";
                }
            }
            
            document.getElementById("lblTablingCenter").innerHTML = tablingcentre + " : " + area;
            
            if(splitArray.length > 4)
            {
                cityid = splitArray[4];
                // This is to bind the tables in the dropdon for OPTIONAL Specific Table Preference of <em>Buddy</em>
                getTablesByCity(cityid);
            }
            
        }
        else
        {
             document.getElementById("lblTablingCenter").innerHTML = "";
        }
    }
    else
    {
         document.getElementById("lblTablingCenter").innerHTML = "";
    }
}

function bindOtherFieldForProfOccupation(ddlId)
{
    var dropDown;
    
    if(ddlId == 'DDLProfOccupation')
    {
      document.getElementById('DDLSpecificProfOccupation').selectedIndex = 0;        
      document.getElementById('DDLSpecificProfOccupation').value = "";
      dropDown = document.getElementById('DDLProfOccupation');
      
      document.getElementById('txtOtherProfOccupation').value = "";
      document.getElementById('txtProfDesignation').value = "";
      
      if(dropDown != null && dropDown.value == "Professional")
      {
        document.getElementById('divOtherProfOccupation').className="hideother";
        document.getElementById('divOtherProfOccupation1').className="showother";
        //document.getElementById('DDLSpecificProfOccupation').className = "genericrequiredtext";
        //document.getElementById('divTextOther1').innerHTML = "Specific Occupation";
        document.getElementById('DDLSpecificProfOccupation').selectedIndex = 0;        
        document.getElementById('DDLSpecificProfOccupation').value = "";
      }
      else
      { 
        document.getElementById('divOtherProfOccupation1').className="hideother";
        document.getElementById('divOtherProfOccupation').className="showother";
        document.getElementById('divProfDesignation').className="hideother";
        //document.getElementById('txtOtherProfOccupation').className = "genericrequiredtext";
        document.getElementById('txtOtherProfOccupation').value = "";
        document.getElementById('txtProfDesignation').value = "";
        document.getElementById('divTextIndustrySegment').style.display = "none";
        
        if(dropDown.value == "Owner / Proprietor / Partner in Family Business")
        {
            document.getElementById('spnTextOther').innerHTML = "Nature of Business :";
        }
        else if(dropDown.value == "Entrepreneur")
        {
            document.getElementById('spnTextOther').innerHTML = "Nature of Business :";
        }
        else if(dropDown.value == "Work in the Corporate Sector")
        {
            document.getElementById('spnTextOther').innerHTML = "Industry Segment :";
            document.getElementById('divTextIndustrySegment').style.display = "";
            
            document.getElementById('divProfDesignation').className="showother";
        }
        else if(dropDown.value == "" || dropDown.value == "Not Sure/Don’t Know")
        {
            document.getElementById('divOtherProfOccupation').className="hideother";            
        }
        else
        {
            document.getElementById('spnTextOther').innerHTML = "Please enter below :";
        }               
      }
    }
    else
    {
        document.getElementById('divOtherProfOccupation').className="hideother";
        document.getElementById('txtOtherProfOccupation').className = "";
    }
}

function displayOtherFieldForReligion(ddlId)
{
    var dropDown;
    
    if(ddlId == 'DDLReligion')
    { 
      dropDown = document.getElementById('DDLReligion');
      
      document.getElementById('txtOtherReligion').value = "";      
      
      if(dropDown != null && dropDown.value == "Other")
      {
        document.getElementById('divOtherReligion').className="showother";       
      }
      else
      {
        document.getElementById('divOtherReligion').className="hideother";
      }
    }
    else
    {
        document.getElementById('divOtherReligion').className="hideother";
        document.getElementById('txtOtherReligion').value = "";
    }
}

function checkBoxesTicked(field)
{  
    var intCount = 0;
    if(field != null)
    {
        for (i = 0; i < field.length; i++)
        {
            if(field[i].checked)
            {
                intCount++;
            }
            if(intCount > 4)
            {
                alert("You can only tick a maximium of 4 options.");
                return false;
            }        
        }
        document.getElementById("hidFacetsOfTabling").value = getFacetsofTabling(field);
    }    	
}

function getFacetsofTabling(field)
{
    var intCount = 0;
    var strFacetsofTabling = "";
     
    if(field != null)
    {
        for (i = 0; i < field.length; i++)
        {
            if(field[i].checked)
            {
                intCount++;
                strFacetsofTabling += field[i].value + ", ";
            }
            if(intCount > 4)
            {
                break;                
            }
        }
        return strFacetsofTabling;
    }
    return strFacetsofTabling;
}
function saveTableName()
{
    if(document.getElementById("hidTableName") != null && document.getElementById("DDLTableName") != null)
    {
        document.getElementById("hidTableName").value = document.getElementById("DDLTableName").options[document.getElementById("DDLTableName").selectedIndex].text;
    }
}

function saveAreaName()
{
    if(document.getElementById("hidAreaName") != null && document.getElementById("DDLArea") != null)
    {
        document.getElementById("hidAreaName").value = document.getElementById("DDLArea").options[document.getElementById("DDLArea").selectedIndex].text;
    }
}

function validateTablerContactInfo(buttonClicked)
{  
    
    if(buttonClicked == "correct")
    {
        document.getElementById("autoform").submit();
        return true;
    }
    else
    {
        showBlocker();
        document.getElementById("phone").focus();
        openTablerContactInfoDiv();
        return false;
    }
    
}

function openFeedbackWindow(scr)
{   
    var windowX = 0;
    var windowY = 0;
    var wWidth = 0;
    var wHeight = 0;
    
    wWidth = 900;
    wHeight = 350;
    
    if(screen != null)
    {
        windowX = (screen.availWidth - wWidth)/2;
        windowY = (screen.availHeight - wHeight)/2;
    }
    else
    {
        windowX = 50;
        windowY = 50;
    }
    
    //window.open('Feedback.php?scr='+scr,'mywindow','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no,width='+wWidth+',height='+wHeight+',left='+windowX+',top='+windowY);    
    window.open('Feedback.php?scr='+scr,'mywindow','scrollbars=no, resizable=no,width='+wWidth+',height='+wHeight+',left='+windowX+',top='+windowY);    
}

function showOrHideEducationDropDown(dropDownId)
{
    var dropDown;
    
    dropDown = document.getElementById(dropDownId);
    if(dropDown != null && dropDown.value == "Not Sure/Don’t Know")
    {
        if(dropDownId == "DDLEducation")
        {
            document.getElementById("DDLCourse").value = "Not Sure/Don’t Know";
        }
        else
        {
            document.getElementById("DDLEducation").value = "Not Sure/Don’t Know";
        }
    }    
}

function validateFeedBackForm()
{
    if(document.getElementById("txtComments") == null)
    {
        return true;
    }
    if(document.getElementById("txtComments").value == "")
    {
        document.getElementById("feedBackErrMsg").style.visibility = "visible";
        document.getElementById("feedBackErrMsg").innerHTML = "Please enter your feedback in at least a few words.";
        return false;
    }
    else
    {
        document.getElementById("feedBackErrMsg").style.visibility = "hidden";
        document.getElementById("feedBackErrMsg").innerHTML = "";    
        return true;
    }
    
}

function resetRecommenderForm()
{
    if(document.getElementById("autoform") != null)
    {
        document.getElementById("autoform").reset();
    }
}