// JavaScript Document
function showBlock(blockID){
	if($(blockID).style.display=='block'){	
		$(blockID).style.display='none';	
	}else{
	$(blockID).style.display='block';		
	}
}
function showBlockz(blockID){
	if($(blockID)){
	if($(blockID).style.display=='table'){	
		$(blockID).style.display='none';	
	}else{
	$(blockID).style.display='table';		
	}
	}
}
function showBlock2(blockID){
	if($(blockID)){
	$(blockID).style.display='block';	
	}	
	
}
function hideBlock(blockID){
	if($(blockID)){
$(blockID).style.display='none';
	}	
}



function doVote(voteID,voteVal){

        JsHttpRequest.query(
            '/ajaxvote.php', // backend
            {
                'voteID': voteID,
				'ans':voteVal			
            },
            function(result, errors) {
                if (result) {
					if(result["q"]=="no_error"){
					document.getElementById("voteMe").innerHTML=""+result["ans"]+"";
					}
                }
            },
            false  // do not disable caching
        )

}

function doCheckfield(voteID){
if(voteID=='username'){
var fillID='reg_usernamecheckitvalue';	
var type='username';
var valu=document.getElementById('reg_username').value;

}else{
var fillID='reg_emailcheckitvalue';	
var type='email';
var valu=document.getElementById('reg_email').value;

}
        JsHttpRequest.query(
            '/ajaxlogin2.php', // backend
            {
				'name':valu,
                'type':voteID ,
				'checkfield':'1'		
            },
            function(result, errors) {
				//alert(errors);
                if (result) {
					//alert(result['q']);
					if(result["q"]=="no_error"){
						$(fillID).innerHTML='<span style="color:#0db100">Ok</span>';
					}else{
						$(fillID).innerHTML='<span style="color:red">'+result['mess']+'</span>';
					}
                }
            },
            false  // do not disable caching
        )

}

function senditTomyFriend(){
	if($('s_emailm')){
		var emval = $('s_emailm').value;
	}else{
		var emval = '';
	}
	JsHttpRequest.query(
	'/ajaxsend.php', // backend
	{
		'link_id': $('s_id').value,
		'email': $('s_email').value,
		'mess': $('s_text').value,
		'emailm': emval,
		'sendtofriend':'1'
					
	},
	function(result, errors) {
		//alert(errors);
		if (result) {
			if(result["q"]){
				var whatis=$('showsendto').innerHTML;
				$('showsendto').innerHTML='<BR><BR><BR><center>'+result['q']+'</center>';
				
				setTimeout(function (){
					$('showsendto').style.display='none';
					$('showsendto').innerHTML=whatis;				 
									 },2000);
			//$('notilink').innerHTML=""+result["q"]+"";
			}
		}
	},
	false  // do not disable caching
)
}

function doNotify(link_id){

        JsHttpRequest.query(
            '/ajaxnotify.php', // backend
            {
                'link_id': link_id
							
            },
            function(result, errors) {
                if (result) {
					if(result["q"]){
					$('notilink').innerHTML=""+result["q"]+"";
					}
                }
            },
            false  // do not disable caching
        )

}
function doNotNotify(link_id){

        JsHttpRequest.query(
            '/ajaxnotify.php', // backend
            {
                'link_id': link_id,
				'not':'no'
							
            },
            function(result, errors) {
                if (result) {
					if(result["q"]){
					$('notilink').innerHTML=""+result["q"]+"";
					}
                }
            },
            false  // do not disable caching
        )

}


function subscribe(){
  JsHttpRequest.query(
            '/ajaxsub.php', // backend
            {
                'email': document.getElementById('youremail').value,
				'type':'1'	
            },
            // Function is called when an answer arrives. 
            function(result, errors) {
			//alert(errors);
                if (result) {
				
				if(result["q"]=="no_error"){
				//alert(result["ans"]);
				//$("messagesub").innerHTML='<div id="response" style="width:auto;display:block;"></div>';
				}
                    $("messagesub").innerHTML = ""+result["ans"]+"";
				
                }
            },
            false  // do not disable caching
        )
}
function unsubscribe(){
  JsHttpRequest.query(
            '/ajaxsub.php', // backend
            {
                'email': document.getElementById('youremail').value,
				'type':'2'	
            },
            // Function is called when an answer arrives. 
            function(result, errors) {
                if (result) {
				
				if(result["q"]=="no_error"){
				//alert(result["ans"]);
				//$("messagesub").innerHTML='<div id="response" style="width:auto;display:block;"></div>';
				}
                    $("messagesub").innerHTML = ""+result["ans"]+"";
				
                }
            },
            false  // do not disable caching
        )
}

function sendInvitations(){

  JsHttpRequest.query(
            '/ajaxinvite.php', // backend
            {
                'name': $('name').value,
				'safe_name':$('safe_name').value,
				'group_mailer':$('group_mailer').value	
            },
            // Function is called when an answer arrives. 
            function(result, errors) {
			//alert(errors);
             //   if (result) {
					$("messinv").innerHTML = "TAK!";
					$('name').value='';
					$('safe_name').value='';
					$('group_mailer').value='';
					window.location.reload();
					//setTimeout(showBlock,1000,'invitef');
             //   }
            },
            false  // do not disable caching
        )
}



function sendBug(){
var mozno="da";
$('bugmess').style.border = '';
var bugtype=$('bugtype').value;
var bugmess=$('bugmess').value;
var pageloc=window.location;
var browser_info=$('browser_info').value;
if($('user_l_id').value!='' && $('user_l_id').value!='0' ){
	var userID=$('user_l_id').value;
	var userName=$('user_l_login').value;
}else{
	var bugemail=$('bugemail').value;
	$('bugemail').style.border = '';
		if(bugemail=='' || bugemail=='your@email.com'){
			mozno="ne";
			$('bugemail').style.border = '3px solid #e30121';
		}
}
if(bugmess==''){
	$('bugmess').style.border = '3px solid #e30121';
	mozno="ne";
}

if(mozno=="da"){
	 JsHttpRequest.query(
				'/ajaxbug.php', // backend
				{
					'bugtype':bugtype,
					'bugmess':bugmess,
					'pageloc':pageloc,
					'browser_info':browser_info,
					'userID':userID,
					'userName':userName,
					'bugemail':bugemail
				},
				// Function is called when an answer arrives. 
				function(result, errors) {
				///alert(errors);
					if (result) {
					$('bugboxinfo').innerHTML='<center>Tak for din tilbagemelding, vi vender tilbage hurtigst muligt</center>';
					setTimeout(function(){
					hideBlock('bugbox');
					$('bugmess').value='';
					$('bugboxinfo').innerHTML='';
					},1000);
					}
				},
				false  // do not disable caching
			)
	}
}

function sendMessage(){
var mozno="da";
$('sendmess').style.border = '';
var bugtype=$('sendtype').value;
var bugmess=$('sendmess').value;
var pageloc=window.location;
var browser_info=$('browser_info').value;
if(bugmess==''){
	$('sendmess').style.border = '3px solid #e30121';
	mozno="ne";
}

if(mozno=="da"){
	 JsHttpRequest.query(
				'/ajaxsend.php', // backend
				{
					'sendtype':bugtype,
					'sendmess':bugmess,
					'pageloc':pageloc,
					'browser_info':browser_info
				},
				// Function is called when an answer arrives. 
				function(result, errors) {
				//alert(errors);
					if (result) {
						
					$('sendboxinfo').innerHTML='<center>Tak for din tilbagemelding, vi vender tilbage hurtigst muligt</center>';
					}
				},
				false  // do not disable caching
			)
	}

}




function checkusers(val){
if(val.length>2){
var mozno='da';	
}
if(mozno=="da"){
	$('m_user_id').innerHTML='loading';
	 JsHttpRequest.query(
				'/ajaxlogin2.php', // backend
				{
					'username':val,
					'getusernames':'1'
				},
				// Function is called when an answer arrives. 
				function(result, errors) {
				///alert(errors);
					if (result) {
					$('m_user_id').innerHTML=result["q"];
					}
				},
				false  // do not disable caching
			)
	}
}

function deleteFunction(delText,navwhere){
	if (confirm(delText)) {window.location=navwhere;}
}