function checkUploadForm() {
	if(xajax.$('photo').value==''){ alert('Select file to upload'); return false;}
    return xajax.upload('sc_upload_photo','uploadForm'); return false;
    }
    

function checkWallPostForm(){
       var nt=xajax.$('wall_msg');
       if(nt.value=='What do you have to say?'){
            alert('Please fill Your message.');
            return false;
       }
       if(nt.value.length<3){
            alert('Your post contained only '+nt.value.length+' characters. The minimum is three.');
            return false;
        }
       if(nt.value.length>500){
            alert('Your post contained '+nt.value.length+'. The maximum is 500.');
            return false;
        } 
        
      return xajax_sc_wall_post(xajax.getFormValues('wall_post'));  
}

function checkContactUserForm(){
    var nt=xajax.$('cont_uname');
       if(nt.value==''){
            alert('Please fill your name!');
            return false;
        }

    nt=xajax.$('cont_uemail');
    if(!checkMail(nt.value)){
            alert('Please fill valid email!');
            return false;
    }


    nt=xajax.$('cont_umess');
    if(nt.value==''){
            alert('Please write a message note!');
            return false;
        }
       
    return xajax_sc_people_contact(xajax.getFormValues('contact_user_form'));
}

function checkApplyLeaderForm(){
    var nt=xajax.$('leader_mess');
       
    if(nt.value==''){
            alert('Please tell why do you want to become a leader!');
            return false;
        }
    var cl=xajax.$('leader_cell');   
    if(cl && cl.value==''){
            alert('Please provide your cell phone!');
            return false;
        } 
    return xajax_sc_people_become_leader(xajax.getFormValues('become_leader_form'));
}

function checkContactForm(){
    var nt=xajax.$('cont_name');
    if(nt.value==''){
            alert('Please fill your name!');
            return false;
        }

    nt=xajax.$('cont_email');
    if(!checkMail(nt.value)){
            alert('Please fill valid email!');
            return false;
    }


    nt=xajax.$('cont_mess');
    if(nt.value==''){
            alert('Please write a message note!');
            return false;
        }
       
    return xajax_sc_event_contact(xajax.getFormValues('contact_leader_form'));
}

function checkWallAlertForm(){
    var nt=xajax.$('alert_name');
    if(nt.value==''){
            alert('Please fill your name!');
            return false;
        }

    nt=xajax.$('alert_email');
   
    if(!checkMail(nt.value)){
            alert('Please fill valid email!');
            return false;
    }


    nt=xajax.$('alert_mess');
    if(nt.value==''){
            alert('Please write a message note!');
            return false;
        }
       
    return xajax_sc_wall_alert_post(xajax.getFormValues('wall_alert_form'));
}

    
function checkInviteForm(){
    var nt=xajax.$('note');
    if(nt.value==''){
            alert('Please write a quick note!');
            return false;
        }
    
    var haveemail=false;
    for(var i=0;i<20;i++){
        nt=xajax.$('email['+i+']');
        if(checkMail(nt.value)){
            haveemail=true;
            break;
        } 
    }            
    if(!haveemail) {
        alert('Please insert at least one valid email!');
        return false;
    }      
       
    return xajax_sc_invite_post(xajax.getFormValues('invite_form'));
}

function checkSpreadForm(){
    var nt=xajax.$('sp_note');
    if(nt.value==''){
            alert('Please write a message!');
            return false;
        }
        
    nt=xajax.$('sp_username');
    if(nt.value==''){
            alert('Please fill Your name!');
            return false;
        }  
        
    nt=xajax.$('sp_useremail');
    if(!checkMail(nt.value)){
            alert('Please fill Your Email!');
            return false;
        }          
    
    var haveemail=false;
    for(var i=0;i<5;i++){
        nt=xajax.$('sp_email['+i+']');
        if(checkMail(nt.value)){
            haveemail=true;
            break;
        } 
    }            
    if(!haveemail) {
        alert('Please insert at least one valid email!');
        return false;
    }      
       
    return xajax_sc_spread(xajax.getFormValues('spread_form'));
}


function checkMail(mail) 
 { 
 var txt=mail; 
 
 if (txt == "")  return false;
 if (txt.indexOf(".") == -1) return false; 
 
 dog = txt.indexOf("@"); 
 if (dog == -1)return false; 
 
 if ((dog < 1) || (dog > txt.length - 5))return false; 
 
 if((txt.charAt(dog - 1) == '.') || (txt.charAt(dog + 1) == '.'))return false; 
 return true;
} 
 
    
function inviteShow(show){
    var btt=xajax.$('step1b');
    var btc=xajax.$('inv_close');
    var eml=xajax.$('emails');
    if(show){
        btt.style.display='none';
        btc.style.display='block';
        eml.style.display='block';
    }
    else {
        btt.style.display='block';
        btc.style.display='none';
        eml.style.display='none';
    }
}    
    
var curfr=1;
function addFriends(){
    if(curfr<4){
        var fr=xajax.$('friends'+curfr);
        fr.style.display='block';
        curfr++;
        fr=xajax.$('elist');
        fr.scrollTop=1000;
        if(curfr==4){
        fr=xajax.$('amf_button');
        fr.style.display='none';
        }
    }
}    

var ctab=2;
function sel_tab(tid)	{
	  if(ctab!=tid){
	  tb=document.getElementById("tab"+tid);
	  otb=document.getElementById("tab"+ctab);
	  if(tb && otb)
	    {
		  document.getElementById("ttab"+tid).className="tab_cells";
		  document.getElementById("ttab"+ctab).className="tab_cell";
		  otb.style.display="none";
		  tb.style.display="block";
		  ctab=tid;
		}
      }  
}


