﻿function fontAdjust(doThis)
{           
	if(document.getElementById('col2'))  contentPart = document.getElementById('col2');
        if(document.getElementById('col12')) contentPart = document.getElementById('col12');        
        if(contentPart)
        {           
	        actualSize = parseFloat(contentPart.style.fontSize);
        	if(!actualSize)     { actualSize  = 1.2; }
                        if(doThis=='plus' && actualSize<1.7)        { newSize = actualSize + 0.2;}
                        if(doThis=='min' && actualSize>0.9)         { newSize = actualSize - 0.2;}
                contentPart.style.fontSize = newSize + 'em' ; 
         }
}

/* MENU - IE6 */
startList = function() { 
	if (document.all&&document.getElementById) { 
		navRoot = document.getElementById("menu");
		if(navRoot != null)
		{
		    for (i=0; i<navRoot.childNodes.length; i++) {
			    node = navRoot.childNodes[i];
			    if (node.nodeName=="LI") {
				    node.onmouseover=function() { 
    				
					    this.className+=" over";
					    if(!document.getElementById("experience")) hideSelects("hidden");
				    }
				    node.onmouseout=function() {
					    this.className=this.className.replace(" over", "");
					    if(!document.getElementById("experience")) hideSelects("visible");

				    }
			    }
		    }
		}
	}
}


function hideSelects(action) { 
	//documentation for this script at http://www.shawnolson.net/a/1198/
	//possible values for action are 'hidden' and 'visible'
	if (action!='visible'){action='hidden';}
	if (BrowserDetect.browser=="Explorer" && BrowserDetect.version<7) { 
	for (var S = 0; S < document.forms.length; S++){
	for (var R = 0; R < document.forms[S].length; R++) {
	if (document.forms[S].elements[R].options) {
	document.forms[S].elements[R].style.visibility = action;
	}
	}
	}
	}
}

function activateTab(tabId)
{	
	for(i=1;i<=4;i++)
	{  
	    if(document.getElementById('tab'+i)!=null)
	    {
	        j = document.getElementById(('tab'+i));
		    j.className=j.className.replace("active", "");	
		}
    }
	document.getElementById(('tab'+tabId)).className+=" active";

	for(i=1;i<=4;i++)
	{ 	
	    if(document.getElementById('tabContent'+i)!=null)
	    {
	        j = document.getElementById(('tabContent'+i)); 
		    j.className=j.className.replace("active", "");	
		}
    }
	document.getElementById(('tabContent'+tabId)).className+="active";
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curtop;
}

function swfPopUp(state) {
	if(state=='open')   display = 'block' ; 
	else	            display = 'none';
	
	if(document.getElementById('popupwrapperNoFlash')!=null)   document.getElementById('popupwrapperNoFlash').style.display = display ;
	if(document.getElementById('popupNoFlash')!=null)          document.getElementById('popupNoFlash').style.display = display ;
}

function dealerPopup(state){

	if(state=='open')   display = 'block' ; 
	else	            display = 'none';
	
	if(document.getElementById('popupwrapper2')!=null)   document.getElementById('popupwrapper2').style.display = display ;
	if(document.getElementById('dealerSWFPopup')!=null)          document.getElementById('dealerSWFPopup').style.display = display ;
}

function popUp(url,posY) {
	if(url) { 
		document.getElementById('carPicture').src = url;
		display = 'block' ;
		document.getElementById('popup').style.top = posY-100+'px';
	}
	else	display = 'none';
	
	if(document.getElementById('popupwrapper')!=null)   document.getElementById('popupwrapper').style.display = display ;
	if(document.getElementById('popup')!=null)          document.getElementById('popup').style.display = display ;

}

function showPicture(url,imgNm,thumb) {
	
	if(imgNm != 'plain') {
		var showMedium = "occasionImage";

		if(document.all) {
		    document.images[showMedium].filters.blendTrans.apply();
		}
		
		
		document.images[showMedium].src = url;
		if(document.all) {
		    document.images[showMedium].filters.blendTrans.play();
		}

		a = document.getElementById("occasionThumbs");
		for (i=0; i<a.childNodes.length; i++) {
			node = a.childNodes[i];
			if (node.nodeName=="A") {	node.style.borderColor = '#ffffff';	}
		}
	
		thumb.style.borderColor = '#B81116';
	 	
	}
}


function BPEscape(url) {
	
	return escape(url);
}

function am() 
{   if(document.getElementById("allmodels")!=null)
    {
	    AMRoot = document.getElementById("allmodels");
	    mh=0;
	    j=0;
	    for (i=0; i<AMRoot.childNodes.length; i++) {
		    node = AMRoot.childNodes[i];
		    if (node.className=="AMpanel") {
			    if(node.offsetHeight>mh) mh = node.offsetHeight;
		    }
		    if (node.className=="colend") {
			    for (j=j; j<i; j++) {
				    node = AMRoot.childNodes[j];
					
				    if(node.className=="AMpanel") node.style.height = mh + 'px';;
			    }
			    mh=0;
		    }
	    }
    }
}

function chooseModel(modelId, hfModelId, ddlModelId)
{
	document.getElementById('allmodels').style.display = 'none';
	document.getElementById('col1').style.display = 'block';
	document.getElementById('col2').style.visibility = 'visible';
	document.getElementById('content').style.backgroundImage = "url('../img/bg_hoofdnavigatie.gif')";
	hideSelects('visible');
	
	//model opslaan in HiddenField
	document.getElementById(hfModelId).value = modelId;
	//model selecteren in dropdown
	if (ddlModelId != '')
	{
		el = document.getElementById(ddlModelId);
		for (i=0; i< el.options.length; i++)
		{
			if (el.options[i].value == modelId)
			{
				el.options[i].selected = true;
			}
		}
	}
	// site layout opnieuw opbouwen
	setupGrid();
}

function changeModelTypeImage(imageUrl, imageId)
{
	document.getElementById(imageId).setAttribute("src", imageUrl);
}

function imageCheckDownload(ImageId, placeholder)
{
    //alert(ImageId);
    loadHtmlSnippet('/layouts/press/cpm/DownloadHandler.aspx?imageId=' + ImageId +'&a=' + escape(new Date()), null, '');    
   
}
