var open_submenu = "";

function lnk_menu(link)
{
    alert("todo-> menu: " + link); //anscheinend momentan nicht benoetigt
}

function lnk_popup(link)
{
	if(open_submenu!=null) {
		$('#'+open_submenu).css('visibility','hidden');
		open_submenu=null;
	}
		
	if($('#div_popup').css('display')!='none') {
  	$('#div_popup').hide();
  	$('#div_blendout').hide();
	}
	else {
    $.ajax({
      url:'popups/'+link+'.html',
      success:function(popup){
    	  if(popup!='') {
        	$('#div_popup').html('<div class="popup_closebtn" onclick="lnk_popup();" style="z-index:2050;width:26px;height:26px;top:13px;left:437px;position:absolute;color:#ffffff;font-family:Arial;">&nbsp;</div>'+popup);
        	$('#div_popup').show();
        	$('#div_blendout').show();
    	  }
      }
    });
	}
}


function ShowSubMenu(submenu)
{

	if(open_submenu == submenu)
	{
		$('#'+open_submenu).css('visibility','hidden');
		open_submenu=null;
	}
	else
	{
  	if(open_submenu!=null) {
  		$('#'+open_submenu).css('visibility','hidden');
  		open_submenu=null;
  	}

  	
		if($('#'+submenu).css('visibility') != 'visible')
		{
			$('#'+submenu).css('visibility', 'visible');
			open_submenu=submenu;
		}
		else
		{
			$('#'+submenu).css('visibility','hidden');
			open_submenu=null;
		}
	}
}

function createplayer(video)
{
  var flashvars = {
    file: "videos/"+video
  }
  var params = {
    menu: "false",
    wmode: "transparent"
  };
  var attributes = {
    id: "player1",
    name: "player1"
  };

  swfobject.embedSWF("flvplayer.swf", "player1", "400", "311", "9.0.0","expressInstall.swf", flashvars, params, attributes);
}

function changebgcolor(cell)
{
  if($('#'+cell).css('background-color') == 'transparent')
  {
    $('#'+cell).css('background-color', '#6D787F');
  }
  else
  {
    $('#'+cell).css('background-color', 'transparent');
  }
}

function lightbox(picbox)
{
	if(open_submenu!=null) {
		$('#'+open_submenu).css('visibility','hidden');
		open_submenu=null;
	}

	if($('#'+picbox).css('display')!='none') {
  	$('#'+picbox).hide();
  	$('#div_blendout').hide();
	}
	else {
  	$('#'+picbox).show();
  	$('#div_blendout').show();
		$('#'+picbox).css('z-index') = 2000;
		$('#div_blendout').css('z-index') = 1999;
	}
}

function checkform()
{
	if((document.contact_form.emailadres.value == '') || (document.contact_form.naam.value == '') || (document.contact_form.emailadres.value == '') || (document.contact_form.uwreactie.value == ''))
	{
		alert('Vul het onderstaande formulier in. Velden met een * zijn verplicht.');
	}
	else
	{
		document.contact_form.submit();
	}
}


/**
 * @author PO Chassay
 */

function searchHandler(){
  var error = 0;
  $('#img_waiting').show();
  $('#rightContent').empty();
  var strContent_header = '<b>Verdelers in uw provincie:<\/b><br><br>';
  var strContent = "";
  var count = 0;

  $.ajax({
        url: 'dealers.xml',
        type: 'GET',
        dataType: 'xml',
        error:
        function(){
              alert('Error loading XML document');
              $('#img_waiting').hide();
          },
        success:
        function(xmlData){
          var selected_region = $('#region').val().toUpperCase();
          $("RECORD",xmlData).each(function(){
            if ($("province",this).text() == selected_region) {
              strContent += "<b>"+$("name",this).text()+"<\/b><br\/>";
              strContent += $("street",this).text()+"<br\/>";
              strContent += $("zip",this).text()+' '+$("city",this).text() +"<br\/><br\/>";
              count += 1;
            }
          });
          strContent = strContent_header+strContent.toUpperCase();
          if ( count == 0) {
            strContent = strContent_header + "Voor de gekozen provincie, kunnen we u geen verdeler aanwijzen.";
          }
          $('#rightContent').html(strContent);
          $('#img_waiting').hide();
        }
  });
}

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20031821-1']);
_gaq.push(['_setDomainName', 'polyfilla.be']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async =
true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
