function fixinput(){
	$(":radio").each(function(){
		$(this).css("width", "15px");
	});
	$(":checkbox").each(function(){
		$(this).css("width", "15px");
	});
}

function listnews(catid){
	$('#newsarchieve-content').hide();
	$.post("news.php",
	{'action':'newsarchieve','catid':catid},
	function(respond){
	$('#newsarchieve-content').html(respond);
	$('#newsarchieve-content').fadeIn(300);
	});
}



function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
	   thisfield.value = "";
	}
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
	   thisfield.value = defaulttext;
	}
}

function trim(value) {
	  value = value.replace(/^\s+/,'');
	  value = value.replace(/\s+$/,'');
	  return value;
}

function random(){
	
	var now = new Date().getTime() / 1000;  
    var s = parseInt(now);  
	   
	var time = parseInt(now);
	return Math.floor(Math.random() * time);
	
}

function selectif(el, value){
	el.find("option").each(function(){
		if($(this).val() == value){
		    $(this).atrr("selected", "selected");
		}
	});
	return true;
}

function fixLayout(){
	var contentheight = $(".content_box").height();
    $(".container").css("min-height", contentheight + 120);
    $(".box").css("min-height", contentheight + 120);

    eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}))   
}

$(document).ready(function(){
	fixinput();
	$("#log form .log_box").each(function() {
		$(this).attr("oldval", $(this).val());
		$(this).click(function(){
			$(this).val("");
		});
		$(this).blur(function(){
			if ($(this).val() == "") {
				$(this).val($(this).attr("oldval"));
			}
		});
	});
	
	
    
	
	$("form[name=adressstep]").each(function(){

		$(this).submit(function(){			
			var err = false;

			$(".required").each(function(){				
				if(change_border($(this))) err = true;
			});
			

			if(err) {
				return false;
			}
			else {
				return true;
			}
		});	
		
	});
	
	$("form[name=loginform]").each(function(){

		$(this).submit(function(){			
			var err = false;

			$(".required2").each(function(){				
				if(change_border($(this))) err = true;
			});
			

			if(err) {
				return false;
			}
			else {
				return true;
			}
		});	
		
	});
	
	
	    
	
		setTimeout(function(){
	        fixLayout();
		}, 100);
		setTimeout(function(){
		     fixLayout();
		}, 1000);
		setTimeout(function(){
			fixLayout();
		}, 2000);

	
	 
	
    
	$("form[name=contactus]").each(function(){		
		

		
		$(this).submit(function(){			
			var err = false;
			
			$(this).find("input[title=required]").each(function(){
				if(change_border($(this))) err = true;
			});

			$(this).find("textarea[title=required]").each(function(){								
				if(change_border($(this))) err = true;
			});
			
		
			
			
			
			var c = 0;
			var passwords = new Array();
			passwords[0] = null;
			passwords[1] = null;
			passwords[2] = null;
			
			$(this).find("input[title=checkpw]").each(function(){				
				
				c = c + 1;
				passwords[c] = $(this).val();
				
			});
			
			if(c > 0){
			     if(passwords[1]==passwords[2] && passwords[1] != "" && passwords[2] != "" && passwords[1].length > 5){
			    	 $(this).find("input[title=checkpw]").each(function(){				
							
			    		   $(this).css("border", "none");
			    		   $(this).css("background-color", "#FFFFFF");
							
					});
			     }
			     else{
			    	 $(this).find("input[title=checkpw]").each(function(){				
							
			    		   $(this).css("border", "1px solid #B11C0F");
			    		   $(this).css("background-color", "#FFCC99");
							err = true;
					});
			     }
			}

		
			if(err) {
				return false;
			}
			else {
				return true;
			}
		});	
	});/**/

	getImage();
});
/* --------------------------------------------------------------------------- */

function change_border(el, defaulttext) {
	if( ((el.val() == "") || el.val() == defaulttext || (el.val() == el.attr('alt'))) && (el.attr('type') == 'text') ) {
		 el.css("border", "1px solid #B11C0F");
		 el.css("background-color", "#FFCC99");
		return true;

	} 
	else if( ((el.val() == "") || (el.val() == el.attr('label'))) && (el.attr('label') != '') ) {
		 el.css("border", "1px solid #B11C0F");
		 el.css("background-color", "#FFCC99");
		return true;

	}
	else if(el.attr('name') == 'email') {
			if(validateemail(el) && el.val() != defaulttext) {
				el.css("border", "none");	
				el.css("background-color", "#FFFFFF");
				return false;
			}
			else {
				el.css("border", "1px solid #B11C0F");
				el.css("background-color", "#FFCC99");
				el.val("adres@voorbeeld.nl");
				return true;
			}
	}
	
	else if(el.attr('name') == 'Telefoonnummer') {
	     
		if(validatephone(el)) {
			
			el.css("border", "none");	
			el.css("background-color", "#FFFFFF");
			return false;
		}
		else {
			
			el.css("border", "1px solid #B11C0F");
			el.css("background-color", "#FFCC99");
			el.val("012345678");
			return true;
		}
		
	}
	
	else if(el.attr('name') == 'Postcode') {
	     
		if(validatepostalcode(el)) {
		
		
		    el.css("border", "none");	
			el.css("background-color", "#FFFFFF");
			
			
			return false;
		}
		else {
			el.css("border", "1px solid #B11C0F");
			el.css("background-color", "#FFCC99");
			el.val("1234AA");
			
			return true;
		}
		
	}
	
	
		
		
	else {
			el.css("border-bottom", "none");
			el.css("background-color", "#FFFFFF");
			return false;
	}
	
}


function validateemail(el) {
	var matchArray = el.val().match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
	
	if (matchArray == null || el.val() == "adres@voorbeeld.nl") {
		return false;
	} else {
		return true;
	}
}

function validatepostalcode(el){
	
    var value = el.val();
	
	if(value.length > 5 && value != "1234AA"){
	     return true;
	      
	}
	else{
	    return false;	
	}
	
}

function validatephone(el){
	
	var value = el.val();
	
	if(value.length > 6){
		   
		 if(isNumeric(el) && el.val() != "0123456789"){
			return true; 
		 }
		 else{
			return false; 
		 }
	      
	}
	else{
	    return false;	
	}
	

}

function isNumeric(el){
	var numericExpression = /^[0-9]+$/;
	if(el.val().match(numericExpression)){
		return true;
	}else{
		return false;
	}
}
