if(parent.frames.length > 0) 
{
    parent.location.href = location.href;
}
function flashLoader(mv, id, w, h)
{
   var so = new SWFObject(mv, 'Loader_movie_' + id, w, h, '6', '#b2d2e7');
   so.addParam('quality', 'high');
   so.addParam('wmode', 'transparent');
   so.addParam('scale', 'noscale');
   so.addParam('allowScriptAccess', 'sameDomain');
   so.addParam('swLiveConnect', 'true');
   so.write(id);
}
function swapimg(img, act){
	if(act == 1) {
		$(img).src = $(img).src.replace('menu_black', 'menu_red');
	}
	if(act == 0) {
		$(img).src = $(img).src.replace('menu_red', 'menu_black');
	}
}
if(parent.frames.length > 0) 
{
    parent.location.href = location.href;
}

function SelAgency(){
	var selBox = document.getElementById("Agency");
	var Id = selBox.options[selBox.selectedIndex].value;
	
    new Ajax.Request( '/ajax/GetAgency.php?Id=' + Id,
            { method: 'get', 
	          onSuccess: setAgency,
			  encoding: 'ISO-8859-1',
			  evalScripts: true
		    });
}

function setAgency(xmlObj){
	document.getElementById('AgencyDetails').innerHTML = xmlObj.responseText;    
}

function SendFriend(){

	var Recipient = document.getElementById("TellFriendAfzender").value;
	var TellFriendName = document.getElementById("TellFriendName").value;
	var TellFriendEmail = document.getElementById("TellFriendEmail").value;
	
	httpObject = getHTTPObject();    
	
	if(httpObject != null) {        
		httpObject.open("GET", '/ajax/tellafriend.php?Afzender='+Recipient+'&Name='+TellFriendName+'&Email=' + TellFriendEmail, true);       
		httpObject.send(null);   
		httpObject.onreadystatechange = SendMailConfirm;        
	}
}
function GetSendFriend() {
    new Ajax.Request( '/tellafriend.php',
            { method: 'get', 
	          onSuccess: showTellaFriend,
			  encoding: 'ISO-8859-1',
			  evalScripts: true
		    });
}
function showTellaFriend(xmlObj) 
{
	$('TellaFriendContainer').update(xmlObj.responseText);
	$('TellaFriendContainer').show();
}
function hideTellaFriend(xmlObj) 
{
	$('TellaFriendContainer').update('');
	$('TellaFriendContainer').hide();
}
function SendMailConfirm(){
	if(httpObject.readyState == 4){        
		document.getElementById('TellaFriendContainer').innerHTML = '<div style="padding: 10px;float:none;">' + httpObject.responseText + '</div>'; 
	} 
}
function GoogleMap(b, l) {

	var BreedteGraad = b;
	var LengteGraad = l;
	
	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("StoreMap"));
        map.setCenter(new GLatLng(52.0772377501922, 4.908571243286133), 13)
		map.addControl(new GLargeMapControl());
      	map.addControl(new GMapTypeControl());
		
		var gmarker = new GMarker( new GLatLng(52.0772377501922, 4.908571243286133));
		map.addOverlay(gmarker);
	}		
}
function getHTTPObject(){   
	if (window.ActiveXObject){       
		return new ActiveXObject("Microsoft.XMLHTTP"); 
	}  	
	else if (window.XMLHttpRequest){        
		return new XMLHttpRequest();   
	}
	else {      
		return null;   
	}
}
function GetCities(CountryId){
	var pid = 0;
	if(document.getElementById('reffid')) {
		pid = parseInt(document.getElementById('reffid').value);
	}
    new Ajax.Request( '/ajax/GetCities.php',
            { method: 'get', 
    	      parameters: 'CountryId=' + CountryId + '&reffid=' + pid,
			  onSuccess: setOutput,
			  encoding: 'ISO-8859-1',
			  evalScripts: true
		    });
}
function GetStores(pid){
	var selBox = document.getElementById("CountrySelector");
	var CountryId = selBox.options[selBox.selectedIndex].value;
	
	selBox = document.getElementById("CitySelector");
	var CityId = selBox.options[selBox.selectedIndex].value;
	
	if(document.getElementById('reffid')) {
		pid = parseInt(document.getElementById('reffid').value);
	}
	document.location.href = "/index.php?mod=front_locator&CountryId="+CountryId+"&CityId="+CityId+"&reffid="+pid;
}
function formFillSelectBox(elmId, data)
{
    if(document.getElementById(elmId)) {
    
        var elm = document.getElementById(elmId);
        
        var m = data.split('|');
        
        for(var k, k=elm.options.length-1; k >= 0; k--) {
        	elm.remove(k);
        }

        for(var k, k=0; k < m.length; k += 2) {
		    var option = document.createElement('option');
		    option.appendChild(document.createTextNode(m[k + 1] ));
		    option.setAttribute('value', m[k] );
		    elm.appendChild(option);
		}
		
        return true;
    }
    return false;
}
function setOutput(xmlObj){
	var data =  xmlObj.responseText;
	formFillSelectBox('CitySelector', data);
}
function rp(p)
{
    window.location = p;
}
function nw(p)
{
    window.open(p);
}
function stayAlive()
{
    new Ajax.PeriodicalUpdater('stayalive', 
                               '/index.php?mod=keepalive',   
                               {method:    'get',     
                                frequency: 60,
                                decay:     1}); 
}
function swClass(id, classname, action)
{
    if(action == 1) {
    	Element.addClassName(id, classname);
    }
    else {
   		Element.removeClassName(id, classname);
   	}
}
function highLiteCode(id)
{
    var f = document.getElementById(id);
    f.select();
}
function textCounter(field,cntfield,maxlimit) 
{ 
	if (field.value.length > maxlimit) { 
		field.value = field.value.substring(0, maxlimit); 
	} 
	else { 
		cntfield.value = maxlimit - field.value.length; 
	}
}
function showFlashMovie(movie)
{
	alert(movie);
}
function download(movie)
{
	window.location = movie;
}