function stateprovince() { 
	sp = document.getElementById('country').value;
	if (sp == 'US' || sp == 'CA' ) {
		switch(sp){
		case "CA":
			 document.getElementById('province').style.display = 'block';
			 document.getElementById('state').style.display = 'none';
			break;
		case "US":
			 document.getElementById('state').style.display = 'block';
			 document.getElementById('province').style.display = 'none';
			break;
		}
	}
	else {
		 document.getElementById('state').style.display = 'none';
		 document.getElementById('province').style.display = 'none';
	}
}

function findPosX(obj){
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0; 
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}
  
function formatjoin(load_type) {
	if (load_type!= '') {
		var thetype = load_type
	}else{
		var thetype = document.getElementById('stype').value;
	}
	if(thetype==0) {
		//individual
		document.getElementById('emaildiv').style.width = "300px";
		document.getElementById('organization_join').style.display = "none";
		document.getElementById('org_name').style.display = "none";
		document.getElementById('org_web').style.display = "none";
		document.getElementById('org_pos').style.display = "none";
		//document.getElementById('cause_select').style.display = "block";
		document.getElementById('signup').style.display = "block";
		document.getElementById('biz_select').style.display = "none";
		document.getElementById('dob').style.display = "block";
		document.getElementById('theaddress').style.display = "none";
		
		RemoveClassName(document.getElementById('org_position'),'required')
		RemoveClassName(document.getElementById('organizationname'),'required')
		RemoveClassName(document.getElementById('org_mission'),'required')
		//RemoveClassName(document.getElementById('org_category'),'required')
		//RemoveClassName(document.getElementById('org_phone'),'required')
		//RemoveClassName(document.getElementById('org_taxnum'),'required')
		RemoveClassName(document.getElementById('address'),'required')
		
		AddClassName(document.getElementById('bdate1'),'required','')
		AddClassName(document.getElementById('bdate2'),'required','')
		AddClassName(document.getElementById('bdate3'),'required','')
		
		$('4realurl').innerHTML = '<strong>4REAL URL</strong><br />The 4REAL URL is your unique 4REAL webpage. Once you select a 4REAL URL it cannot be changed.<br/><br />Your 4REAL URL will look something like: www.4REAL.com/YOUR NAME'
		

	}else if(thetype==1) {
		//organization
		document.getElementById('emaildiv').style.width = "160px";
		document.getElementById('organization_join').style.display = "block";
		document.getElementById('org_name').style.display = "block";
		document.getElementById('org_web').style.display = "block";
		document.getElementById('org_pos').style.display = "block";
		//document.getElementById('cause_select').style.display = "none";
		document.getElementById('signup').style.display = "block";
		document.getElementById('biz_select').style.display = "none";
		document.getElementById('dob').style.display = "none";
		document.getElementById('theaddress').style.display = "block";

		AddClassName(document.getElementById('org_position'),'required','')
		AddClassName(document.getElementById('organizationname'),'required','')
		AddClassName(document.getElementById('org_mission'),'required','')
		//AddClassName(document.getElementById('org_category'),'required','')
		//AddClassName(document.getElementById('org_phone'),'required','')
		//AddClassName(document.getElementById('org_taxnum'),'required','')
		AddClassName(document.getElementById('address'),'required','')
		
		RemoveClassName(document.getElementById('bdate1'),'required')
		RemoveClassName(document.getElementById('bdate2'),'required')
		RemoveClassName(document.getElementById('bdate3'),'required')
		
		$('4realurl').innerHTML = '<strong>4REAL URL</strong><br /> The 4REAL URL is your organization\'s unique 4REAL webpage. Once you select a 4REAL URL it cannot be changed.<br/ ><br />Your 4REAL URL will look something like: www.4REAL.com/YOUR ORGANIZATION'
		
	}else {
		//business
		document.getElementById('emaildiv').style.width = "300px";
		document.getElementById('organization_join').style.display = "none";
		document.getElementById('org_name').style.display = "none";
		document.getElementById('org_web').style.display = "none";
		document.getElementById('org_pos').style.display = "none";
		//document.getElementById('cause_select').style.display = "none";
		document.getElementById('signup').style.display = "none";
		document.getElementById('biz_select').style.display = "block";
		//document.getElementById('dob').style.display = "none";
		
	}
	document.getElementById('join_message').style.display = 'none';
}

function AddClassName(objElement, strClass, blnMayAlreadyExist) {
   // if there is a class
   if ( objElement.className ) {
      var arrList = objElement.className.split(' ');

      // if the new class name may already exist in list
      if ( blnMayAlreadyExist )
         {

         // get uppercase class for comparison purposes
         var strClassUpper = strClass.toUpperCase();

         // find all instances and remove them
         for ( var i = 0; i < arrList.length; i++ )
            {
            // if class found
            if ( arrList[i].toUpperCase() == strClassUpper )
               {
               // remove array item
               arrList.splice(i, 1);
               // decrement loop counter as we have adjusted the array's contents
               i--;
               }
            }
         }

      // add the new class to end of list
      arrList[arrList.length] = strClass;
	  // add the new class to beginning of list
      //arrList.splice(0, 0, strClass);
      objElement.className = arrList.join(' ');

      }
   		// if there was no class
   		else
      {
      // assign modified class name attribute      
      objElement.className = strClass;
      }
}

function RemoveClassName(objElement, strClass){
	// if there is a class
   if ( objElement.className ){

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {
         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper ){
            // remove array item
            arrList.splice(i, 1);

            // decrement loop counter as we have adjusted the array's contents
            i--;
            }
         }

      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   // there is nothing to remove
}
