function checkAll(){
	cBoxes=document.getElementById('cBoxes');
	var boxes = cBoxes.getElementsByTagName("input");
	for (var i = 0; i < boxes.length; i++) {
		myType = boxes[i].getAttribute("type");
		if ( myType == "checkbox") {
			boxes[i].checked=1;
		}
	}
}

function checkNone(){
	cBoxes=document.getElementById('cBoxes');
	var boxes = cBoxes.getElementsByTagName("input");
	for (var i = 0; i < boxes.length; i++) {
		myType = boxes[i].getAttribute("type");
			if ( myType == "checkbox") {
				boxes[i].checked=0;
			}
	}
}

function hide_all(){
	var a
 a=document.getElementById('form_detalii_firma')
 if(a!=null)
	 a.style.display = 'none';
	 
 b=document.getElementById('form_adresa_user')
 if(b!=null)
	 b.style.display = 'none';
}
function show_div(param){
 var a
 a=document.getElementById(param)
 a.style.display = 'block';
}

function hide_div(param){
 var a
 a=document.getElementById(param)
 a.style.display = 'none';
}

function display_div(){
	var a
	a=document.getElementById('statut_juridic').selectedIndex
	
	if (a == 'Persoana fizica') {
		hide_all();
		show_div('form_adresa_user');
	}
	
	if (a == 'Persoana juridica') {
		hide_all();
		show_div('form_detalii_firma');
		show_div('form_adresa_user');
	}
		
}

function bifeaza_statut(param){
	var a
	a=document.getElementById(param)
	a.checked=true
	
}

function confirmaStergere(delUrl) {
  if (confirm("Sunteti sigur(a) ca doriti sa stergeti?")) {
    document.location = delUrl;
  }else{
  	//window.alert("Stergerea a fost anulata!");
  }
}

function CreateBookmarkLink() {

 title = "ClubContabilitate.ro"; 
 url = "http://www.clubcontabilitate.ro/";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
		
	if (window.external) {
	  document.write('<a href = "javascript:CreateBookmarkLink()");">Add to Favorites</a>'); 
	  } else  if (window.sidebar) {
	  document.write('<a href = javascript:CreateBookmarkLink()");">Bookmark Page</a>'); 
	 } else if (window.opera && window.print) {	
	   document.write('<a href ="javascript:CreateBookmarkLink()");">Add Bookmark</a>');
	 }	
	
 }
 
 function exista_email(){
	var email;
	email=document.getElementById('email_inregistrare').value;
	
	/*Prototype*/
	/*
	new Ajax.Updater('verifica_existenta_email', '/inc/ajax.verifica_email.php', {
  	method: 'get',
  	parameters: {email: email}
  	});
  	*/

	/*jQuery*/
	$('#verifica_existenta_email').load('/inc/ajax.verifica_email.php',{'email':email});
}

function exista_username(){
	var username;
	username=document.getElementById('username').value;
	
	/*Prototype*/
	/*
	new Ajax.Updater('verifica_existenta_username', '/inc/ajax.verifica_username.php', {
  	method: 'get',
  	parameters: {username: username}
  	});
  	*/
	
	/*jQuery*/
	$('#verifica_existenta_username').load('/inc/ajax.verifica_username.php',{'username':username});

}

function procesare_abonare_nws(){
	var email;
	var sursa;
	var accept_comunicari;
	
	email=document.getElementById('email').value;
	sursa=document.getElementById('sursa').value;
	accept_comunicari=document.getElementById('accept_comunicari').value;
	
	document.getElementById('newsletterProcess').style.display='block';
	
	/*Prototype*/
	/*
	new Ajax.Updater('newsletterProcess', '/inc/newsletter.subscriber.ajax.php', {
  	method: 'get',
  	parameters: {email: email, sursa:sursa, accept_comunicari:accept_comunicari}
  	});
  	*/
	
	/*jQuery*/
	$('#newsletterProcess').load('/inc/newsletter.subscriber.ajax.php',{'email':email , 'sursa':sursa, 'accept_comunicari':accept_comunicari});

}

function uncheck(id_checkbox){
	document.getElementById(id_checkbox).checked=false;
}

function flag(qa_id){
	$('#dialog_flag').dialog();

}

function display_form_answer(qa_id_fk, answ_id_fk, answer_form_id){
	/*jQuery*/
	$('#'+answer_form_id).load('/inc/ajax.display_form_answer.php',{'qa_id_fk':qa_id_fk , 'answ_id_fk':answ_id_fk});
	$('#'+answer_form_id).show();
}

function follow_topic(id, process_div){
	$('#'+process_div).load('/inc/ajax.follow_topic_process.php',{'follow_id_fk':id});
}

function follow_qa(qa_id){
	$('#follow_qa_process').load('/inc/ajax.follow_qa_process.php',{'follow_id_fk':qa_id});
	$('#follow_qa_process').show('slow');
}

function follow_user(id_user){
	$('#follow_user_process').load('/inc/ajax.follow_user_process.php',{'follow_id_fk':id_user});
	$('#follow_user_process').show('slow');
}

function voteaza_raspuns(answ_id_fk, flag_type){
	$('#rate_answer_'+answ_id_fk).load('/inc/ajax.voteaza_raspuns.php',{'answ_id_fk':answ_id_fk , 'flag_type':flag_type});
}

$(document).ready(function(){

	$("#login_link").click(function(){
		$("#div_login").toggle('slow');
	});
	
	$("#close_login").click(function(){
		$("#div_login").hide('slow');
	});
	
	$("#div_login > input").focus(function(){
		$(this).css({"background-color":"#FBF9EA", "border":"1px solid #EAE094"});
	});
	
	$("#div_login > input").blur(function(){
		$(this).css({"background-color":"#FFFFFF", "border":"1px solid #EEEEEE"});
	});
	
	$("#login_submit").css({"background-color":"transparent", "border":"none"});
	
	/*
	$('#tabel_user_details > tr').mouseover(function() {
		$('#tabel_user_details > tr > td').css({"background-color":"#ddd"});
	});
	*/

});
