﻿// JScript File


function changeVeldTekst(obj, tekst){
        if (obj.value == tekst){
                obj.value = '';
        }
}

function haalGRM(){
    
    $.post("http://www.wise-automatisering.nl/mr_onr/grm/", {search:document.forms['aspnetForm'].zoekveld.value, action:'search'}, function(data){
		test(data)
	});
}

function test(data){    
    $("#zoekResults").html(data);
    $("#zoekResults table:first").remove();
    
    $("#zoekResults img").attr("src","http://www.wise-automatisering.nl/mr_onr/grm/img/item.gif");
    
    var $arrLinks = $("#zoekResults td A");
    var deStr = '';
    var hetID = ''
    $arrLinks.each(function(){    
        deStr = $(this).attr("href");
        hetID = deStr.substr(deStr.search('k=()')+2)
        $(this).attr("href", "javascript:verwerkWWWItem(" + hetID + ")");
        //$(this).attr("onClick", "verwerkWWWItem(" + hetID + ")");
        //$(this).attr("onClick", "alert('hoi');");
        
        //alert(Mid(deStr,1,1));
        //alert(deStr.search('k=()'));
    
    });
    
    //alert($("#zoekResults td A").attr("href"));
}





   
function noenter(){
    //return !(window.event && window.event.keyCode == 13); 
}
    
    
function toonLVDiv(lvID){
    $("#lvDIV_"+lvID).toggle("slow");
    return false;
}    

function toonwww(kantoorID){        
    $.get("getKantoorInfo.aspx", {id:kantoorID}, function(data){    
		toonWWWItem(data, kantoorID)
	});
    return false;

}

function toonWWWItem(data, kantoorID){

  $("#lvDIVwww_"+kantoorID).html(data);
  $("#lvDIVwww_"+kantoorID).toggle("slow");
  $("#lvDIVwww_"+kantoorID + " img").attr("src","App_Themes/Default/Images/Iconen/persoon.gif");
}



function printPagina(){

    parent.print();
    return false;

}

// Custom Validator takes two arguments, sender and args
function IconFileIsPic(sender, args) {
    // use the client id of the file upload
     var fuIcons = document.getElementById('ctl00_ContentPlaceHolder1_fvCategories_fuIcon');

     // empty upload  control is valid
     var isValid = (fuIcons.value.length = 0)
     if (! isValid) {
         isValid = FileTypeValidator(fuIcons.value, ['jpg', 'gif', 'jpeg'])
     }
     args.IsValid = isValid;
}

// test for valid file types based on the file extension
function FileTypeValidator(fileName, fileTypes) {
    if (!fileName) return;

    arr = fileName.toLowerCase().split(".")
    fileType = "." + arr[arr.length-1];
    var valid;
    if (fileTypes.join(".").indexOf(fileType) != -1) {
        valid = true; 
    } else {
        valid = false;
    }
    return valid;
}


function linkTargetnaarBlank(){
    var $arrLinks = $(".replydiv a");
    
    for(i = 0; i < $arrLinks.length; i++){		
    
        $arrLinks.eq(i).removeAttr("target");
        $arrLinks.eq(i).attr('target','_blank');
    }
}
