/*
Ringtonio Variabelen:
*/
img_speaker="http://www.ringtonetoko.nl/images/speaker_small.gif";
img_folder="http://www.ringtonetoko.nl/images/folder_closed.gif";
mleft=120;
mtop=20;
bgplay="http://www.ringtonio.nl/images/blank.gif";
bgsend="http://www.ringtonetoko.nl/images/bg_bestel.jpg";
d=document;
bd="http://www.ringtonio.nl";


//loginform /Admin
//wachtwoord HASHEN DMV Password && HIDDEN Random nr
function Encrypt_Login(form) 
	{ 
	var login_code = document.forms[form].elements['login_code'].value; 
	var username = document.forms[form].elements['username'].value; 
	var pwd = hex_sha1(document.forms[form].elements['password'].value); 
	pwd = hex_sha1(pwd + login_code); 
	if(username != '' && login_code != '') 
		{ 
		document.forms[form].elements['password'].value = pwd; 
		document.forms[form].submit(); 
		}
		else 
		{ 
		alert("Alle velden moeten ingevuld worden."); 
		return false;
	} 
} 


function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


function toggle_adult ()
	{
	var adult_cookie = readCookie('adult');

	if (adult_cookie == null)
		{	
		createCookie('adult',0,30);
		document.getElementById("show_adult").src = 'images/adult_off.gif';
		window.alert('Adult Content is nu NIET zichtbaar.');
		window.location.reload();
   	}	

	if (adult_cookie == 0)
		{	
		createCookie('adult',1,30);
		document.getElementById("show_adult").src = 'images/adult_on.gif';
		window.alert('Adult Content is nu WEL zichtbaar.');
		window.location.reload();
   	}
	
	if (adult_cookie == 1)
		{	
		createCookie('adult',0,30);
		document.getElementById("show_adult").src = 'images/adult_off.gif';
		window.alert('Adult Content is nu NIET zichtbaar.');
		window.location.reload();
   	}	
}

function get_stats(guid,site_id)
	{
	referrer = escape(document.referrer); 

	if((referrer == "") || (referrer == "undefined"))
		{
		referrer = ""; 
	} 
	pagina = escape(document.location.href); 
	screens = screen.width + "x" + screen.height; 
	screenc = (navigator.appName.indexOf("Microsoft") > -1) ? screen.colorDepth : screen.pixelDepth; 
	img = "/includes/stats/stats.php?guid=" + guid + "&pagina=" + pagina + "&site_id=" + site_id + "&referrer=" + referrer + "&screensize=" + screens + "&screencolors=" + screenc; 
	img = "<img src=\"" + img + "\" />"; 
	document.write(img);
}

function shuffle_captcha(img_id) {
		document.getElementById(img_id).src = '/includes/captcha.php';
}

function ContactForm()
	{
	var error = 0;
	var error_msg = "De velden met een uitroepteken zijn verplicht.\n\n";

	if (document.form1.email.value == "" ) 
		{
		error_msg += "\t- Het e-mail adres is niet ingevuld\n";
		error = 1;
		form1.email.style.backgroundColor='#FF0000';
		form1.email.style.color='#FFFFFF';
	}
	else
		{
		form1.email.style.backgroundColor='';
		form1.email.style.color='';		
	}
	
	if (document.form1.subject.value == "" ) 
		{
		error_msg += "\t- Er is geen onderwerp ingevuld\n";
		error = 1;
		form1.subject.style.backgroundColor='#FF0000';
		form1.subject.style.color='#FFFFFF';
	}
	else
		{
		form1.subject.style.backgroundColor='';
		form1.subject.style.color='';		
	}
	
	var input=form1.input.value;	
	if (input == ""  || input.length  < 10) 
		{
		error_msg += "\t- Het bericht moet minimal 10 tekens bevatten\n";
		error = 1;
		form1.input.style.backgroundColor='#FF0000';
		form1.input.style.color='#FFFFFF';
		}
		else
		{
		form1.input.style.backgroundColor='';
		form1.input.style.color='';		
	}

	var randVal=form1.randVal.value;	
	if (randVal.length  < 6) 
		{
		error_msg += "\t- Type de code over uit de afbeelding.\n";
		error = 1;
		form1.randVal.style.backgroundColor='#FF0000';
		form1.randVal.style.color='#FFFFFF';
	}
	else
		{
		form1.randVal.style.backgroundColor='';
		form1.randVal.style.color='';		
	}
	
	if (error ==1)
		{
		window.alert(error_msg);	
		return false;
		}
		else 
		{
		//return false;
		form1.Submit.disabled=true
		form1.Submit.value='Bezig met opslaan'
		document.form1.submit(); 
	}
}

var win = null;
function NewWindow(mypage,myname,w,h,scroll)
	{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no'
	win = window.open(mypage,myname,settings)
}

function CheckSimpleSearchForm()
	{
	var error = 0;
	var trefwoord=search_form.trefwoord.value;
	if (trefwoord.length  < 3) 
		{
		var vraag = window.alert('Het trefwoord moet uit minimaal 3 tekens bestaan.');
		document.search_form.trefwoord.focus();
		return false;
		error = 1;
	}
	
	if (document.search_form.trefwoord.value =="" || document.search_form.trefwoord.value =="   Trefwoord" ) 
		{
		window.alert('Vul een Trefwoord in.');
		document.search_form.trefwoord.focus();
		return false;
		error = 1;
	}
	
	if (error == 0)
		{
		trefwoord = trefwoord.replace(' ', "+")
		trefwoord = trefwoord.replace('/', "|")
		window.location.href="/search/simple/"+trefwoord;	
	}
}

function CheckADVSearchForm()
	{
	var error = 0;
	var trefwoord=search_form_adv.trefwoord.value;
	if (trefwoord.length  < 3) 
		{
		var vraag = window.alert('Het trefwoord moet uit minimaal 3 tekens bestaan.');
		document.search_form_adv.trefwoord.focus();
		return false;
		error = 1;
	}
	
	if (document.search_form_adv.trefwoord.value =="" || document.search_form_adv.trefwoord.value =="   Trefwoord" ) 
		{
		window.alert('Vul een Trefwoord in.');
		document.search_form_adv.trefwoord.focus();
		return false;
		error = 1;
	}
	
	if (error == 0)
		{
		var monoT = 0;
		var polyT = 0;
		var realT = 0;
		var trueT = 0;
		var nameT = 0;
		var wallT = 0;
		var miniT = 0;
		if (document.search_form_adv.monoT.checked) { var monoT = 1; } 
		if (document.search_form_adv.polyT.checked) { var polyT = 1; } 
		if (document.search_form_adv.realT.checked) { var realT = 1; } 
		if (document.search_form_adv.trueT.checked) { var trueT = 1; } 
		if (document.search_form_adv.nameT.checked) { var nameT = 1; } 
		if (document.search_form_adv.wallT.checked) { var wallT = 1; } 
		if (document.search_form_adv.miniT.checked) { var miniT = 1; } 

		trefwoord = trefwoord.replace(' ', "+")
		trefwoord = trefwoord.replace('/', "|")
	
		window.location.href="/search/advanced/"+monoT+"/"+polyT+"/"+realT+"/"+trueT+"/"+nameT+"/"+wallT+"/"+miniT+"/"+trefwoord;	
	}
}

function SaveFilter()
	{
	//Filter opslaan bij ADV zoeken. De checkboxes worden opgeslagen, zodat je bij de volgende zoek opdracht niet de vinkjes hoeft aan te passen
	if (document.search_form_adv.monoT.checked) { createCookie('FilterMono',1,30); } else { createCookie('FilterMono',0,30); }
	if (document.search_form_adv.polyT.checked) { createCookie('FilterPoly',1,30); } else { createCookie('FilterPoly',0,30); }
	if (document.search_form_adv.realT.checked) { createCookie('FilterReal',1,30); } else { createCookie('FilterReal',0,30); }
	if (document.search_form_adv.trueT.checked) { createCookie('FilterTrue',1,30); } else { createCookie('FilterTrue',0,30); }
	if (document.search_form_adv.nameT.checked) { createCookie('FilterName',1,30); } else { createCookie('FilterName',0,30); }
	if (document.search_form_adv.wallT.checked) { createCookie('FilterWall',1,30); } else { createCookie('FilterWall',0,30); }
	if (document.search_form_adv.miniT.checked) { createCookie('FilterMini',1,30); } else { createCookie('FilterMini',0,30); }
	window.alert('Deze Selectie is opgeslagen.\nBij de volgende zoekopdracht staan de vinkjes weer op deze manier.');
}

/*Open Popup met Ringtonio iFrame*/
function send(ordernr)
	{
	NewWindow('/order/send/'+ordernr,'Bestel', '605', '470', 'no')	
}

function play(ordernr)
	{
	NewWindow('/order/play/'+ordernr,'Bestel', '300', '160', 'no')	
}


function CheckEmailFriendForm() 
	{
	var error = 0;
	var error_msg = "De velden met een uitroepteken zijn verplicht.\n\n";

	if (document.FriendForm.naam.value == "" ) 
		{
		error_msg += "\t- Er is geen naam ingevuld\n";
		error = 1;
		document.FriendForm.naam.style.backgroundColor='#FF0000';
		document.FriendForm.naam.style.color='#FFFFFF';
	}
	else
		{
		document.FriendForm.naam.style.backgroundColor='';
		document.FriendForm.naam.style.color='';		
	}

	if (document.FriendForm.ontvanger.value == "" ) 
		{
		error_msg += "\t- Er is geen Ontvanger naam ingevuld\n";
		error = 1;
		document.FriendForm.ontvanger.style.backgroundColor='#FF0000';
		document.FriendForm.ontvanger.style.color='#FFFFFF';
	}
	else
		{
		document.FriendForm.ontvanger.style.backgroundColor='';
		document.FriendForm.ontvanger.style.color='';		
	}
	
	if (document.FriendForm.email.value == "" ) 
		{
		error_msg += "\t- Er is geen E-mail adres ingevuld\n";
		error = 1;
		document.FriendForm.email.style.backgroundColor='#FF0000';
		document.FriendForm.email.style.color='#FFFFFF';
	}
	else
		{
		document.FriendForm.email.style.backgroundColor='';
		document.FriendForm.email.style.color='';		
	}
	
	if (error ==1)
		{
		window.alert(error_msg);	
		return false;
		}
		else 
		{
		//return false;
		document.FriendForm.Submit.disabled=true
		document.FriendForm.Submit.value='Bezig met Versturen'
		document.FriendForm.submit(); 
	}
}

function CheckLinkPartnerForm() 
	{
	var error = 0;
	var error_msg = "De velden met een uitroepteken zijn verplicht.\n\n";

	if (document.linkpartner.title.value == "" ) 
		{
		error_msg += "\t- Er is geen titel (weergavenaam) ingevuld\n";
		error = 1;
		document.linkpartner.title.style.backgroundColor='#FF0000';
		document.linkpartner.title.style.color='#FFFFFF';
	}
	else
		{
		document.linkpartner.title.style.backgroundColor='';
		document.linkpartner.title.style.color='';		
	}

	if (document.linkpartner.url.value == "" ) 
		{
		error_msg += "\t- Er is geen Hyperlink ingevuld\n";
		error = 1;
		document.linkpartner.url.style.backgroundColor='#FF0000';
		document.linkpartner.url.style.color='#FFFFFF';
	}
	else
		{
		document.linkpartner.url.style.backgroundColor='';
		document.linkpartner.url.style.color='';		
	}
	
	if (document.linkpartner.contact_name.value == "" ) 
		{
		error_msg += "\t- Er is geen Naam ingevuld\n";
		error = 1;
		document.linkpartner.contact_name.style.backgroundColor='#FF0000';
		document.linkpartner.contact_name.style.color='#FFFFFF';
	}
	else
		{
		document.linkpartner.contact_name.style.backgroundColor='';
		document.linkpartner.contact_name.style.color='';		
	}

	if (document.linkpartner.contact_mail.value == "" ) 
		{
		error_msg += "\t- Het e-mail adres is niet ingevuld\n";
		error = 1;
		document.linkpartner.contact_mail.style.backgroundColor='#FF0000';
		document.linkpartner.contact_mail.style.color='#FFFFFF';
	}
	else
		{
		document.linkpartner.contact_mail.style.backgroundColor='';
		document.linkpartner.contact_mail.style.color='';		
	}

	var randVal=linkpartner.randVal.value;	
	if (randVal.length  < 6) 
		{
		error_msg += "\t- Type de code over uit de afbeelding.\n";
		error = 1;
		linkpartner.randVal.style.backgroundColor='#FF0000';
		linkpartner.randVal.style.color='#FFFFFF';
	}
	else
		{
		linkpartner.randVal.style.backgroundColor='';
		linkpartner.randVal.style.color='';		
	}
	

	if (!document.linkpartner.informatie.checked) 
		{
		error_msg += "\t- Als je de Extra Informatie hebt gelezen kan je dit d.m.v. de checkbox opgeven\n";
		error = 1;
	}
	
	
	if (error ==1)
		{
		window.alert(error_msg);	
		return false;
		}
		else 
		{
		//return false;
		document.linkpartner.Submit.disabled=true
		document.linkpartner.Submit.value='Bezig met opslaan'
		document.linkpartner.submit(); 
	}
}

//show hide DIV
function obj(menu)
	{
	return (navigator.appName == "Microsoft Internet Explorer")?this[menu]:document.getElementById(menu);
}
function togglevisible(treepart)
	{
	if (this.obj("T"+treepart).style.visibility == "hidden")
	{
	this.obj("T"+treepart).style.position="";
	this.obj("T"+treepart).style.visibility="";
	document["I"+treepart].src="images/stats_visible.gif";
	}
	else
	{
	this.obj("T"+treepart).style.position="absolute";
	this.obj("T"+treepart).style.visibility="hidden";
	document["I"+treepart].src="images/stats_hidden.gif";
	}
}

function togglevisibleNoIMG(treepart)
	{
	if (this.obj("T"+treepart).style.visibility == "hidden")
	{
	this.obj("T"+treepart).style.position="";
	this.obj("T"+treepart).style.visibility="";
	}
	else
	{
	this.obj("T"+treepart).style.position="absolute";
	this.obj("T"+treepart).style.visibility="hidden";
	}
}

function CheckEmailRingtone()
	{
	var error = 0;
	var error_msg = "De velden met een uitroepteken zijn verplicht.\n\n";


	var trefwoord=search_form_adv.trefwoord.value;
	if (trefwoord.length  < 3) 
		{
		error_msg += "\t- Het trefwoord moet minimaal 3 tekens bevatten\n";
		error = 1;
		document.search_form_adv.trefwoord.style.backgroundColor='#FF0000';
		document.search_form_adv.trefwoord.style.color='#FFFFFF';
	}
	else
		{
		document.search_form_adv.trefwoord.style.backgroundColor='';
		document.search_form_adv.trefwoord.style.color='';		
	}
	
	if (document.search_form_adv.email.value == "" ) 
		{
		error_msg += "\t- Er is geen E-mail adres ingevuld\n";
		error = 1;
		document.search_form_adv.email.style.backgroundColor='#FF0000';
		document.search_form_adv.email.style.color='#FFFFFF';
	}
	else
		{
		document.search_form_adv.email.style.backgroundColor='';
		document.search_form_adv.email.style.color='';		
	}
	
	var randVal=search_form_adv.randVal.value;	
	if (randVal.length  < 6) 
		{
		error_msg += "\t- Type de code over uit de afbeelding.\n";
		error = 1;
		search_form_adv.randVal.style.backgroundColor='#FF0000';
		search_form_adv.randVal.style.color='#FFFFFF';
	}
	else
		{
		search_form_adv.randVal.style.backgroundColor='';
		search_form_adv.randVal.style.color='';		
	}

	if (error ==1)
		{
		window.alert(error_msg);	
		return false;
		}
		else 
		{
		//return false;
		document.search_form_adv.Submit.disabled=true
		document.search_form_adv.Submit.value='Bezig met opslaan'
		document.search_form_adv.submit(); 
	}
}

/*Guestbook Form controleren*/
function check_GB_form()
	{
	if (document.form1.naam.value == "" ) 
		{
		var vraag = window.alert('Vul eerst een naam in');
		document.form1.naam.focus();
		return false;
	}
	
	max_length = 750;
	var value=document.form1.input.value;	
	var length = value.length;
	
	if(length > 750)
		{	
		alert("Het bericht is te groot.\nMaximaal 750 tekens.\n"+length+" tekens gebruikt.");
		document.form1.input.focus();
		return false;
	}
	
	if(length<5)
		{	
		alert('Het bericht is te klein.\nMinimaal 5 tekens.');
		document.form1.input.focus();
		}		
	
	else 
	{
	form1.submit_button.disabled=true
	document.form1.submit(); 
	}
}

/*Gastenboek Tekst Functies:*/

function setThis(varBegin,varEnd) 
	{
	myTextRange = document.selection.createRange();
	SelectionObject = myTextRange.parentElement();

	if (SelectionObject.tagName == "TEXTAREA") 
		{
		strSelection = document.selection.createRange().text
		if (strSelection != "") 
			{
			document.selection.createRange().text = varBegin + strSelection + varEnd
			return;
			}
		}
		else 
			{
			alert('Maak eerst een selectie in de tekst!');
	}
}

/*Plaatje toevoegen*/
function Add_img(theform,thefield)
	{
    my_link = '';
    while (my_link == '') {
		my_link = prompt("Voer de URL van het plaatje in.","http://");
		if (!(my_link == '' || my_link == 'http://' || my_link == null)) {
			varBegin = "[img]";
			varEnd = "[/img]";
			document.forms[theform].elements[thefield].value += varBegin + my_link + varEnd;
			document.forms[theform].elements[thefield].focus();	return;
		}
	}
}

/*Hyperlink Toevoegen*/
function AddLink(type_of_format,theform,thefield) {
   prompt_text_1 = '';
   prompt_text_2 = '';
   text_to_format_1 = '';
   text_to_format_2 = '';
   switch (type_of_format) {
      case 'url':
         prompt_text_1 = "Geef de url op.";
         prompt_text_2 = "Geef de naam voor de url op.";
         prompt_contents = "http://";
		 break;
      case 'email':
         prompt_text_1 = "Geef het e-mail adres op.";
         prompt_text_2 = "Geef een naam voor het e-mail adres op.";
         prompt_contents = "";
         break;
   };
    while (text_to_format_1 == '') {
      text_to_format_1 = prompt(prompt_text_1,prompt_contents);
      if (!(text_to_format_1 == '' || text_to_format_1 == null)) {
         text_to_format_2 = prompt(prompt_text_2,text_to_format_1);
         if (!(text_to_format_2 == '' || text_to_format_2 == null)) {
			new_message = "["+type_of_format+"="+text_to_format_1+"]"+text_to_format_2+"[/"+type_of_format+"] ";

			document.forms[theform].elements[thefield].value += new_message;
			document.forms[theform].elements[thefield].focus();
         };
      };
   };
}