﻿/*window.addEvent('domready', function() {
    if (Browser.Engine.trident6) {
        $$('select').each(function(el) {
            $(el).setStyles({ "position": "absolute", "left": "-999px" });
        });
    }
});
*/
window.addEvent('load', function() {
    /*$('searchq').addEvent('focus', function() {
    if ($('searchq').value == "zoeken                                        ") {
            $('searchq').value = "";
        }

    });
    $('searchq').addEvent('blur', function() {
        if ($('searchq').value == "") {
            $('searchq').value = "zoeken                                        ";
        }

    });
    
*/
    var externallinks = $$("a").filter(function(el) {
    return (el.rel && el.rel.test(/^external/i)) || (el.href && !el.href.test(/^http:\/\/www.winands\.nl/i) && !el.href.test(/^http:\/\/winands\.nl/i) && el.href.test(/^http/i) && el.href && !el.href.test(/^http:\/\/www.netsupportdemo5\.nl/i) && !el.href.test(/^http:\/\/netsupportdemo5\.nl/i) && el.href.test(/^http/i));
    });

    externallinks.each(function(el) {
        $(el).setAttribute('target', '_blank');
        el.addClass('external');
    });
	
	initCols();
	initGmap();
});



function initCols() {
var textdiv = $('contenttext');
    if (textdiv != null) {
        var textcols = textdiv.getElements('div.col');
		
		if ($(textcols[1]).innerHTML.trim() == "") {
			if (textdiv.getElements('p').length > 1) {
				
				var ps = textcols[0].getElement("p:last-child");
				
				while (($(textcols[0]).getSize().y - ps.getSize().y) > $(textcols[1]).getSize().y + ps.getSize().y) {
					//alert($(textcols[0]).getSize().y + ' ' + ($(textcols[0]).getSize().y - ps.getSize().y) + ' ' + $(textcols[1]).getSize().y + ' ' + ps.getSize().y);
					var e2m = textcols[0].lastChild;
					$(textcols[1]).grab(e2m, 'top');
					ps = textcols[0].getElement("p:last-child");
				}
	
				//$(textcols[1]).setStyle('height', $(textcols[0]).getSize().y + "px");
			}
		}
    }
    
}

var map = null;
var geocoder = null;

function initGmap() {
	var gmap = $('gmap');
	if (gmap != null) { 
		loadgooglemap('gmap');
		showAddressMarker("W Dijkstrastraat 88, Vrouwenparochie, Nederland","<strong>Autobedrijf Winands</strong><br/>Waling Dijkstrastraat 88<br/>9077 SR Vrouwenparochie"); 
	}
}
	function loadgooglemap(id) {
			if (GBrowserIsCompatible()) {
				map = new GMap2(document.getElementById(id));
				map.enableScrollWheelZoom();
				if (geocoder == null) {
					geocoder = new GClientGeocoder();
				}
				
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
				
			}
		}

		function showAddressMarker(address, name) {
			shopaddress = address;
			if (geocoder) {
				geocoder.getLatLng(
	      address,
	      function(point) {
	      	if (!point) {
	      		alert(address + " niet gevonden");
	      	} else {
	      		targetpoint = point;
	      		map.setCenter(point, 12);
	      		var marker = new GMarker(point);
	      		map.addOverlay(marker);
	      		marker.openInfoWindowHtml('<span style="color:#000;">' + name + '</span>');

	      	}
	      }
	    );
			}
		}
