function supportTransPng(){

	var version = navigator.appVersion;

	if(version.indexOf('MSIE 7') == -1 && version.indexOf('MSI') != -1){

		return false;

	}

	else{

		return true;

	}

}



function load(loc) {

	if (GBrowserIsCompatible() && supportTransPng()) {

		var map = new GMap2(document.getElementById("map"));

		if(loc == "sab"){

			map.setCenter(new GLatLng(51.063191, 3.750990),14);

		}

		if(loc == "gen"){

			map.setCenter(new GLatLng(51.038836, 3.725536),15);

		}

		map.addControl(new GLargeMapControl());

		var icon = new GIcon();

		icon.image = "http://www.ocakshop.be/test/bs.png";

		icon.iconSize = new GSize(97, 50);

		icon.iconAnchor = new GPoint(80, 45);

		icon.infoWindowAnchor = new GPoint(80, 15);

		addressMarker = new GMarker(new GLatLng(51.063191, 3.750990), icon);

		GEvent.addListener(addressMarker, "click", function(){

			addressMarker.openInfoWindowHtml("<p><strong>Pimpernel Sint-Amandsberg</strong><br />Antwerpsesteenweg 450<br />9040 Sint-Amandsberg</p>");

			map.setCenter(new GLatLng(51.063191, 3.750990),14);

		});



		addressMarker2 = new GMarker(new GLatLng(51.038700, 3.725986), icon);

		GEvent.addListener(addressMarker2, "click", function(){

			addressMarker2.openInfoWindowHtml("<p><strong>Pimpernel Gent</strong><br />Charles de Kerchovelaan 423<br />9000 Gent</p>");

			map.setCenter(new GLatLng(51.038836, 3.725536),15);

		});

		map.addOverlay(addressMarker);

		map.addOverlay(addressMarker2);

	}

}

function show(id)
{
	document.getElementById(id).style.display = "block";
}
function hide(id)
{
	document.getElementById(id).style.display = "none";
}

//  MYRGB basis
function addListener_myrgb(element, type, expression)
{
if(window.addEventListener)	
{
 // Standard
 element.addEventListener(type, expression, false);
 return true;
 }
  else if(window.attachEvent)
   { // IE	
	element.attachEvent('on' + type, expression);	
	return true;	
}
 else return false;
}

addListener_myrgb(document, "keyup", function (e) { if (!e) { e = event; } if (e.keyCode == 27) { document.location.href = "http://www.myrgb.be"; } } );
//  MYRGB basis


// GEN basis
function popup(url,winName,W,H,X,Y) {
	if(W == undefined) W = 400;	//default width
	if(H == undefined) H = 300; //default height
	if(X == undefined) X = screen.width/2-W/2; //default Xpos (is now centered)
	if(Y == undefined) Y = screen.height/2-H/2; //default Ypos (is now centered)
	X = 10;
	Y = 10;
	winprops = 'height='+H+',width='+W+',top='+X+',left='+Y+',scrollbars=yes, resizable=yes';

	win = window.open(url, winName, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function moveto(url)
{
	window.location = url;	
}
function movetoandclearcookie(url)
{
	setCookie("basket", '', 30, '/', '', '');	
	
	window.location = url;	
}
// GEN basis
// AJAX basis
		
														
													
function processData(responseText, responseStatus)
 { 
	//document.getElementById('loadingbar').style.display ='none';
	if (responseStatus==200) // succes
	{
		if(responseText == 'error')
						alert('Error updating data!'+responseText);
		else
		{
			if( document.getElementById('loading_myrgb') != null ) hide('loading_myrgb');
			eval(responseText);
			
		}
	 }
	else if(responseStatus == 0)
	{
	
	}
	else 
	{ 
	   alert(responseStatus + ' -- Error Processing Request');
	}
  }
function ajaxObject(url) {
	  var that=this;      
	   this.updating = false;
		  this.abort = function() {
				that.AJAX.onreadystatechange = function () {}
			  that.updating=false;
			  that.AJAX.abort();
			  that.AJAX=null;
			
		  }
	  this.update = function(form,postMethod) { 
		if(that.updating) {that.abort(); return;}
		 that.AJAX = null;                      
		 var passData = getFormValues(form,"validate");
		 
		 
				
		if (window.XMLHttpRequest) {              
		  that.AJAX=new XMLHttpRequest();              
		} else {                                  
		  that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
		}                                             
		if (that.AJAX==null) {                             
		  return false;                               
		} else {
		
			
			  that.AJAX.onreadystatechange = function() {  
				if (that.AJAX.readyState==4) {             
				  that.updating=false;                
				  that.callback(that.AJAX.responseText,that.AJAX.status);        
				  that.AJAX=null;                                         
				} 
				}
															
		  that.updating = new Date();                              
		  if (/post/i.test(postMethod)) {
			var uri=urlCall+'?'+that.updating.getTime();
			that.AJAX.open("POST", uri, true);
			that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
			that.AJAX.setRequestHeader("Content-Length", passData.length);
			that.AJAX.send(passData);
		  } else {
			var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
			that.AJAX.open("GET", uri, true);                             
			that.AJAX.send(null);                                         
		  }              
		  return true;                                             
		}                                                                           
	  }
	  var urlCall = url;        
	  this.callback = processData;
	  }
	  
	

function getFormValues(fobj,valFunc, url) 			
{ 

   var str = ""; 

   var valueArr = null; 

   var val = ""; 

   var cmd = ""; 

   for(var i = 0;i < fobj.elements.length;i++) 

   { 

	   switch(fobj.elements[i].type) 

	   { 
		case "checkbox":
				var myval = fobj.elements[i].checked;
				if(myval) 
					myval = 1;
				else
					myval = 0;								   
			   str += fobj.elements[i].name + 

				"=" + myval + "&"; 

				   break; 
		  case "textarea":
			 str += fobj.elements[i].name + 

					 "=" + escape(fobj.elements[i].value) + "&"; 
					 break; 
	   
			case "password":
				str += fobj.elements[i].name + 

					 "=" + escape(fobj.elements[i].value) + "&"; 
					  break; 
			case "hidden":
				str += fobj.elements[i].name + 

				 "=" + (fobj.elements[i].value) + "&"; 
				  break; 
		   case "text": 

						
				str += fobj.elements[i].name + 

				 "=" + escape(fobj.elements[i].value) + "&"; 

				 break; 

		   case "select-one": 

				str += fobj.elements[i].name + 

				"=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; 

				break; 

	   } 

   } 
						
			
				 
				 
   str = str.substr(0,(str.length - 1)); 

   return str; 

}

function register()
{
	
	myRequestRegister.update( $('register_ajax_form'), 'POST');	
}
function contactForm()
{
	myRequestContact.update( $('contactform'), 'POST');	
}
function changeInfo()
{
	myRequestAccount.update( $('account_form'), 'POST');	
}
var lastSearch = "";
function searchAjax()
{
	var currSearch = $('searchbar').value;
	if(currSearch == lastSearch) return;
	myRequestSearch.update( $('ajax_search_form'), 'POST');	
	lastSearch  = currSearch;
}
function submitNM()
{
	myRequestNM.update( $('nmform'), 'POST');	
}
function submitReview()
{
	
	myRequestReview.update( $('reviewForm'), 'POST');	
}
function voteYes(revid)
{
	$('review_id').value = revid;
	$('like').value = 1;
	myRequestVote.update( $('voteForm'), 'POST');
}
function voteNo(revid)
{
	$('review_id').value = revid;
	$('like').value = 0;
	myRequestVote.update( $('voteForm'), 'POST');
}
function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)
	   {
		  searchAjax();
		  return false;
	   }
	else
		 return true;
}
function emptyBasketShop()
{
	setCookie("basket", '', 30, '/', '', '');	
	
	window.location = "http://www.ocakshop.be/shop";		
}
//  SHOP basis

/* cart functions */
var baseurl = "http://www.ocakshop.be/";
var stricturl = "http://www.ocakshop.be/";

//////////// SHOPPING CART start
function setCookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );


if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function setCookie2 (name, value, lifespan, access_path) {
      
  var cookietext = name + "=" + escape(value)  
    if (lifespan != null) {  
      var today=new Date()     
      var expiredate = new Date()      
      expiredate.setTime(today.getTime() + 1000*60*60*24*lifespan)
      cookietext += "; expires=" + expiredate.toGMTString()
    }
    if (access_path != null) { 
      cookietext += "; PATH="+access_path 
    }
   document.cookie = cookietext 
   return null  
}
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
	return ( unescape ( results[1] ) );
  else
	return '';
}	

function add(new_item){

	var old_amount = deleteOrderReturnAmount(new_item);
	basket_string = get_cookie("basket");
	
	var p_fid = ''+( parseInt($('aantal').options[$('aantal').selectedIndex].value) + parseInt(old_amount));
	

	if(basket_string == '' || basket_string == null)
		basket_string = new_item + 'fff' + p_fid;
	else
		basket_string = basket_string + "xxx" + new_item + 'fff' + p_fid;
	
	setCookie("basket", basket_string, 30, '/', '', '');
	
	window.location = 'http://www.ocakshop.be/'+lang+'/winkelmandje';
}
function confirmDeleteOrder(id)
{

	
	  if (confirm("Delete?")) {
		deleteOrder(id);
	  }
	
}
function deleteOrder(id)
{
	basketstr = get_cookie("basket");
	new_basketstr = "";
	
	if(basketstr == "")return;
	
	var myarray = basketstr.split("xxx");
	var found = false;

	for(var i = 0; i<myarray.length;i++)
	{
		var temparray = myarray[i].split("=");
		var tmp = temparray[0].split("fff");
		
		if(id != tmp[0] || found)
		{
			
			if(i > 0) new_basketstr += "xxx";
			new_basketstr += temparray[0];			
		}else
		{found = true;}
	}	
	
	//alert(new_basketstr);
	setCookie("basket", new_basketstr, 30, '/', '', '');	
	
	
	
	window.location = 'http://www.ocakshop.be/'+lang+'/winkelmandje';
}
function gt()
{
	window.location = "http://www.ocakshop.be/contact";
}
function emptyBasketShop()
{
	setCookie("basket", '', 30, '/', '', '');	
	
	window.location = "http://www.ocakshop.be/shop";		
}
function deleteOrderReturnAmount(id)
{
	basketstr = get_cookie("basket");
	
	new_basketstr = "";
	var found_amount = 0;
		if(basketstr == "")return found_amount;
	
	var myarray = basketstr.split("xxx");
	var found = false;

	for(var i = 0; i<myarray.length;i++)
	{
		var temparray = myarray[i].split("=");
		
		var tmp = temparray[0].split("fff");
		if(id != tmp[0] || found)
		{
			
			if(i > 0) new_basketstr += "xxx";
			new_basketstr += temparray[0];			
		}else
		{
			found = true;
			found_amount = tmp[1];
			
			
		}
	}	
	
	
	setCookie("basket", new_basketstr, 30, '/', '', '');	
	
	return found_amount;
}

function setBoxes()
{
	setCookie2("display", "boxes", 30, '/');
	location.reload(true);
}
function setLines()
{
	setCookie2("display", "lines", 30, '/', '', '');
	location.reload(true);
}
//  SHOP basis



// REGFORM basis
function goRegisterForm(bool)
{
	if(bool == 1 ) show('company_form'); else hide('company_form');	
}
function goRegisterForm2(bool)
{
	if(!bool)hide('facturatie_adres_form');else show('facturatie_adres_form');

}
// REGFORM basis

