function get_address(pc, hn, doel)
{
	new Ajax.Updater(doel, "/engine.php?func=get_address",{
	method: "post",
	parameters: {pc: pc,
    			 hn: hn
				},
	onComplete: function()
	{
//	
	}				
				
			});	
	return true;

}

function catch_menu()
{
	var it = $('videomenublock').getElementsByTagName('ul')[0].getElementsByTagName('a');
    for (i = 0; i < it.length; i++)
    {
    	it[i].onclick = function()
        {
        	this.rid = this.id.substr(1,this.id.length);
			new Ajax.Updater('menu_inner', "/engine.php?func=get_menu",{
			method: "post",
			parameters: {id: this.rid
					},
			onComplete: function()
			{
				catch_menu();	
			}				
				
			});	
			updateXML('/cache/thumbs' + this.rid + '.xml');
            return false;
	    }
	}
}    

function catch_related()
{
	if ($('related'))
    {
    	var ras = $('related').getElementsByTagName('a');
        for (i = 0; i < ras.length; i++)
        {
        	ras[i].onclick = function()
            {
            	load_video(this.className);
                return false;
            }
        }
    }
}

function catch_disc()
{
	if ($('adddisc'))
    {
    	$('adddisc').onsubmit = function()
        {
        	var err = '';
            if ($('dname').value.length < 2)
            {
            	err += 'Vul een naam in<br />';
            }
            if ($('deml').value.length < 5 || $('deml').value.indexOf('@') == -1)
            {
            	err += 'Vul een emailadres in<br />';
            }
            if ($('dtxt').value.length < 5)
            {
            	err += 'Vul een reactie in<br />';
            }
            if (err != '')
            {
            	$('err').innerHTML = err;
            	return false;
            }
            else
            {
				new Ajax.Updater('err','/engine.php?func=add_disc', 
		        {   
		        	method: 'post', 
		            evalScripts: true,
		            parameters:
		            {
		            	id: $('did').value,
		                txt: $('dtxt').value,
		                name: $('dname').value,
		                eml: $('deml').value
		            },
		            onSuccess: function(transport) 
		            {
		            	//$('err').innerHTML = transport.responseText;
		            
		            } 
		        });                     
            }
            return false;
        }
        
    }
}



function catch_cont()
{
	if ($('addcont'))
    {
    	$('addcont').onsubmit = function()
        {
        	var err = '';
            if ($('naam').value.length < 2)
            {
            	err += 'Vul een naam in<br />';
            }
            if ($('eml').value.length < 5 || $('eml').value.indexOf('@') == -1)
            {
            	err += 'Vul een emailadres in<br />';
            }
            if ($('opmerkingen').value.length < 5)
            {
            	err += 'Vul een reactie in<br />';
            }
            if (err != '')
            {
            	$('err').innerHTML = err;
            	return false;
            }
            else
            {
				new Ajax.Updater('err','/engine.php?func=contact', 
		        {   
		        	method: 'post', 
		            evalScripts: true,
		            parameters:
		            {
		                txt: $('opmerkingen').value,
		                naam: $('naam').value,
		                bnaam: $('bnaam').value,
		                eml: $('eml').value
		            },
		            onSuccess: function(transport) 
		            {
		            	//$('err').innerHTML = transport.responseText;
		            
		            } 
		        });                     
            }
            return false;
        }
        
    }
}


if ($('addform'))
{
	$('addform').onsubmit = function()
    {
    // validate form
    	var err = '';
/*        
        if ($('add_name').value == '')
        {
        	err += 'Vul uw naam in<br />';
        }
        if ($('add_eml').value == '' || $('add_eml').value.indexOf('@') == -1)
        {
        	err += 'Vul een geldig emailadres in<br />';
        }
*/        
        if ($('add_title').value == '')
        {
        	err += 'Vul een titel in<br />';
        }
        if ($('add_txt').value == '')
        {
        	err += 'Vul een beschrijving in<br />';
        }
        if ($('add_tags').value == '')
        {
        	err += 'Vul 1 of meer tags (komma-gescheiden) tags in<br />';
        }
        if ($('add_file').value == '')
        {
        	err += 'Selecteer een videobestand<br />';
        }
        $('err').innerHTML = err;
        if (err != '')
        {
            return false;
        }
       	
        // get action
        
		new Ajax.Request('/engine.php?func=yt_get_url', 
        {   
        	method: 'post', 
            asynchronous: false,  
            parameters:
            {
            	title: $('add_title').value,
                txt: $('add_txt').value,
                tags: $('add_tags').value
            },
            onSuccess: function(transport) 
            {
            	if (transport.responseText.indexOf('http') == 0)
                {
                	$('addform').action = transport.responseText.split('||')[0] + '?nexturl=http://www.uitvaart.tv/added.html';
                	$('add_token').value = transport.responseText.split('||')[1];
                	return true;
                }
                else
                {
                	return false;
                }   
            } 
        });         
   	}
}    


if ($('sresults'))
{
	var sr = $('sresults').getElementsByTagName('div');
    for (i = 0; i < sr.length; i++)
    {
    	sr[i].onclick = function()
        {
        	document.location.href = this.getElementsByTagName('a')[0].href;
        }
        
        sr[i].onmouseover = function()
        {
        	this.style.cursor = 'pointer';
            this.style.backgroundColor = '#78ADCB';
        }
        
        sr[i].onmouseout = function()
        {
        	this.style.backgroundColor = '#FFFFFF';
        }
     }
}     


function map_but(thas)
{
		var rubs = $('sitemap').getElementsByTagName('li');
		for (i = 0; i < rubs.length; i++)
		{
			rubs[i].className = '';
			if (thas == rubs[i])
			{
				rubs[i].className = 'current';
			}
		}
}	

function catch_map()
{
	if ($('sitemap'))
	{
		var rubs = $('sitemap').getElementsByTagName('li');
		for (i = 0; i < rubs.length; i++)
		{
			rubs[i].onclick = function()
			{
				filterop(this.getElementsByTagName('a')[0].className);
				map_but(this);
				return false;
			}
		}

				
		var mp = $('sitemap').getElementsByTagName('div');
		
		for (i = 0; i < mp.length; i++)
		{
			mp[i].onclick = function()
			{
				document.location.href = this.getElementsByTagName('a')[0].href;
				return false;
			}
			
			mp[i].onmouseover = function()
			{
				this.old = this.style.backgroundColor;
				this.style.backgroundColor = '#E1EDF6';
				this.style.cursor = 'pointer';
			}
			
			mp[i].onmouseout = function()
			{
				this.style.backgroundColor = this.old;
			}
		}
	}
}

function filterop(r)
{
	var mp = $('sitemap').getElementsByTagName('div');
	
	for (i = 0; i < mp.length; i++)
	{
		if (r == 0 || mp[i].id.indexOf('_'+r+'_') != -1)
		{
			mp[i].style.display = 'block';
		}
		else
		{
			mp[i].style.display = 'none';
		}
	}
}

if ($('addeml'))
{
	$('addeml').onsubmit = function()
	{
		new Ajax.Updater('err','/engine.php?func=addeml', 
        {   
        	method: 'post', 
            evalScripts: true,
            parameters:
            {
                eml: $('eml').value
            },
            onSuccess: function(transport) 
            {
            	//$('err').innerHTML = transport.responseText;
            
            } 
        });		
		return false;		
    }
}	

if ($('menu_inner'))
{
	catch_menu();
}

if (document.body.className != "")
{
	new Ajax.Request('/engine.php?func=stat', 
    {   
    	method: 'post', 
        asynchronous: true,  
        parameters:
        {
            id: document.body.className
        } 
    });	
}

catch_related();
catch_disc();
catch_map();
catch_cont();
    
