/**
/* @package		Dare to Manage v1.01
/* @copyright	Copyright (C) 2011 Dare to Design, http://www.daretodesign.nl. All rights reserved
**/

// EXPANDING LIST 

function showtr(id,img) {
	
	if( document.getElementById(id) != null ) {
	
		if( document.getElementById(id).style.display == 'none' && document.getElementById(id).style.visibility == 'hidden' ) {
			document.getElementById(id).style.display = '';
			document.getElementById(id).style.visibility = '';
			document.getElementById(img).src = '/cms_files/media/afbeeldingen/contract.gif';
		} else {
			document.getElementById(id).style.display = 'none';
			document.getElementById(id).style.visibility = 'hidden';
			document.getElementById(img).src = '/cms_files/media/afbeeldingen/expand.gif';
		}
		
	}

}

// POPUP
var win=null;

function NewWindow(mypage,myname,w,h) {
	
	myleft=(screen.width)?(screen.width-w)/2:100;
	mytop=(screen.height)?(screen.height-h)/2:100;

	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no,url=no";win=window.open(mypage,myname,settings);

	win.focus();
}

function refreshParent() {
	window.opener.location.href = window.opener.location.href;
	if ( window.opener.progressWindow ) {
		window.opener.progressWindow.close()
	}
	window.close();
}


// TOGGLE FIELD CONTENTS

(function($) {
	$(document).ready(function() {

		$( 'input[type="text"], input[type="password"], textarea' ).each( function(){
		$(this).attr( 'title', $(this).val() )
		 .focus( function(){
			if ( $(this).val() == $(this).attr('title') ) {
			 $(this).val( '' );
			}
		 } ).blur( function(){
			if ( $(this).val() == '' || $(this).val() == ' ' ) {
			 $(this).val( $(this).attr('title') );
			}
		 } );
		} );

	});
})(jQuery);


// Random password generator- by javascriptkit.com
// Visit JavaScript Kit (http://javascriptkit.com) for script
// Credit must stay intact for use

var keylist="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
var temp=''

function generatepass(plength){
	temp=''
	for (i=0;i<plength;i++)
	temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
	return temp
}
function populateform(theField, enterlength){
	if(!enterlength) {
		var enterlength = 5;
	}
	document.getElementById(theField).value=generatepass(enterlength)
}

// CHECK PASSWORD

function checkValue(txt1,txt2) {
	var org = document.getElementById(txt1);
	var chk = document.getElementById("control");
	if(txt1.value !== txt2.value) {
		chk.innerHTML = '<img src="/cms_files/media/afbeeldingen/check_no.gif" width="10" height="10" alt="niet gelijk" />';
	} else {
		chk.innerHTML = '<img src="/cms_files/media/afbeeldingen/check_yes.gif" width="10" height="10" alt="gelijk" />'; 
	}
}

// TOGGLE DIV

function toggleView(targetDiv) {
	$("#"+targetDiv).slideToggle(400, function() {
	// Animation complete.
	});
}


// TIME PICKER

function pickTime(object) {
	var h = document.getElementById('' + object + '_H').value;
	var m = document.getElementById('' + object + '_M').value;
	document.getElementById(object).value = h + ':' + m + ':00';
}
  
function buildTime(timeName) {
	document.write('<select class="timePicker" style="width:50px;" name="' + timeName + '_H" id="' + timeName + '_H" onChange="pickTime(\'' + timeName + '\')">');
	for (var j=0;j<=23;j++) {
		var str = '' + j;
		if(str.length < 2) {
			str = '0' + str;
		}
		document.write('<option rel="none" value="' + str + '">' + str + '</option>');
	}
	document.write('</select>' + String.fromCharCode(13));
	document.write('<select class="timePicker" style="width:50px;" name="' + timeName + '_M" id="' + timeName + '_M" onChange="pickTime(\'' + timeName + '\')">');
	for (var j=0;j<=45;j=j+15) {
		var str = '' + j;
		if(str.length < 2) {
			str = '0' + str;
		}
		document.write('<option rel="none" value="' + str + '">' + str + '</option>');
	}
	document.write('</select>' + String.fromCharCode(13));
	document.write('<input type="hidden" name="' + timeName + '" id="' + timeName + '" />' + String.fromCharCode(13));
}
