document.write('<script language="javascript" src="includes/environment.js"></script>');
//cpoUrl = "http://vwapoproto.cobaltgroup.com/v/vwapo/flash/";//REPLACE THIS
var modelID='';
var modelcode='';

// handoff token to be set only in
// in local development environments
//
// for DEV, QA, VWQA, and VWPRD this
// variable should remain blank
var handoffToken='';

 //alert(Navigator.cookiesEnabled);
 function newImage2(arg) 
    {
        rslt = new Image();
        rslt.src = arg;
        return rslt;    
    }


var tmpcookie = new Date();
chkcookie = (tmpcookie.getTime() + '');
document.cookie = "chkcookie=" + chkcookie + "; path=/";

var envirocheck=location.href;
var envartemp='';
envirocheck=envirocheck.toString();

if(envirocheck.indexOf('config-qa.dev')>-1) envartemp='http://vwdev03.dev.proxicom.com';
if(envirocheck.indexOf('config.dev')>-1) envartemp='http://daggit.dev.proxicom.com';
if(envirocheck.indexOf('cobaltgroup')>-1) envartemp='http://vwdev03.dev.proxicom.com';
if(envirocheck.indexOf('vwcertified')>-1) envartemp='http://vwdev03.dev.proxicom.com';
if(document.cookie.indexOf(chkcookie,0) < 0) location.href= envartemp + '/error/no_cookies.html';



var speedbumptest=false;




var is_mac    = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1); 



var detect = navigator.userAgent.toLowerCase();
var browser='';
var chk=false;

if (checkIt('safari')) browser = "safari";

else if (checkIt('msie')) browser = "explorer";
else if (!checkIt('compatible'))
{
    browser = "netscape";
}
var hidedhtml=false;

if(is_mac && (browser=='netscape' || browser=="safari" || browser=="explorer")) hidedhtml=true;

//alert(hidedhtml);


function checkIt(string)
{
    if(detect.indexOf(string)!=-1) chk=true;
    else chk=false;
    return chk;
}



navAssignments=new Array(0);
navAssignments['models']='navtop';
navAssignments['vwlife']='navbtm';
navAssignments['companyinfo']='navbtm';
navAssignments['cpo']='navtop';
navAssignments['owners']='navtop';
navAssignments['buildquote']='navtop';
navAssignments['testdrive']='navtop';
navAssignments['finddealer']='navtop';
navAssignments['drivergear']='navbtm';
navAssignments['financialserv']='navbtm';
navAssignments['contact']='navbtm_ico';

var navID ="";
if(sectionID &&  sectionID !='privacy' && sectionID!='terms') navID = navAssignments[sectionID] + '_' +  sectionID;

idFinder=new Array(0);
idFinder['menu1']='navtop_cpo';
idFinder['menu2']='navtop_models';
idFinder['menu3']='navtop_owners';
idFinder['menu4']='navbtm_companyinfo';

var isDOM, isIE;
if(document.getElementById) isDOM=true;
if(document.all) isIE=true;
function Navigation(url) 
{
    location.href = url;
}


function NavigationRollover(name,swap,last)
{
    if (swap == 1)
    { 
        isDOM?document.getElementById(name).className = 'globalnavdropon':document.all[name].className='globalnavdropon';
        //if(last) changeimages(last, '/images/_common/' + last + '_on.gif')          

    }
    else 
    { 
        isDOM?document.getElementById(name).className = 'globalnavdrop':document.all[name].className='globalnavdrop';
        //if(last) changeimages(last, '/images/_common/' + last + '.gif')
    }
    window.status = "";
}
    
var menu2h=-137;
var menu2len=145;
var menu3h=-85;
var menu3len=93;

if(!isIE)
{
    
    menu2h-=10;
    menu2len+=6;
    menu3h-=8;
    menu3len+=4;
}
    
new slide('menu1', 'down', 141, 29, 128, 118);
new slide('menu2', 'down', 62, 29, 88, 73);
new slide('menu3', 'down', 260, 29, 126, 56);
new slide('menu4', 'up', 243, menu3h, 108, menu3len);

function setNav()
{
    if(modelID!='') checkModelCookie();
    
    if(sectionID && sectionID !='privacy' && sectionID!='terms') 
    {    
        //alert(sectionID);
        navID = navAssignments[sectionID] + '_' +  sectionID;
        eval('document.' + navID).src= navimgpath + navID + "_sel.gif";
        
        //Inserting IFRAME for form Element Fix.
        if(isIE && !is_mac)
        {
            document.getElementById("frtop").style.display = "inline"; 
			document.getElementById("frtop2").style.display = "inline";
			document.getElementById("frtop3").style.display = "inline";
            document.getElementById("frbot1").style.display = "inline"; 
            document.getElementById("frbot2").style.display = "inline";
        }
    }
}

function navRollOver(id, dir)
{
    if (id==sectionID && dir=="") dir="_sel";
    
        var rollID = navAssignments[id] + '_' +  id;
        eval('document.' + rollID).src= navimgpath + rollID + dir + ".gif";
        
    

}

function changeimages()
{
    for (var i=0; i<changeimages.arguments.length; i+=2) 
    {
        document[changeimages.arguments[i]].src = changeimages.arguments[i+1];
    }
}
var sCookie = document.cookie;
sCookie=unescape(sCookie);

arr=sCookie.split('*');
var showCookie="";
for(i=1;i<arr.length;i++)
{
    showCookie+=i + ":" + arr[i] + "  ";
}
//alert(showCookie);
//alert(sCookie);

function testconfigmodel(loc)
{
    modnav=new Array(0);
    
    modnav['golf']='golf';
    modnav['gti']='gti';         
    modnav['jettawagon']='jwagon';
    modnav['jetta']='jetta';
    modnav['newbeetlecon']='nbc';
    modnav['newbeetle']='nb';
    modnav['passatwagon']='pwagon';
    modnav['passat']='passat';
    modnav['phaeton']='phaeton';
    modnav['touareg']='touareg';
    
    for(x in modnav)
    {
        if(loc.indexOf(x)>-1)return modnav[x];
    }        
         
}
function checkModelCookie()
{
    var sCookie = document.cookie;
    sCookie=unescape(sCookie);
    
    arr=sCookie.split('*');
    
    //alert(testconfigmodel(modelID));
    if(arr[3])
    {
        if(arr[3]!=testconfigmodel(modelID))    
        {
            //alert(arr[3]);
            eval("Delete_Cookie('ASC%5FConfigStateCookie', '/', \"" + cookieEnVar + "\")");
            window.location.reload(false);
        }
    }
}
var configbump=false;
//arr[6]=1;

function goTo(loc)    
{
    var rCookie = document.cookie;
    rCookie=unescape(rCookie);
    
    arr=rCookie.split('*');
    
    
    //alert('speedbumptest:' + speedbumptest + ' step:' + arr[6] + ' testconfigmodel' + testconfigmodel());
    loc=envar + loc;
    if(speedbumptest==false) location.href=loc;
    else if( arr[6]>=1 && arr[4])
    {
        if(arr[3])
        {
            
            var mod=arr[3];
            if(testconfigmodel(loc)==mod)location.href=loc;
            //if(loc.indexOf(mod)>-1)location.href=loc;
            else bumpfunctiontest(loc);
        }
        else bumpfunctiontest(loc);
    }
    else  location.href=loc;
        
}


function popWin(popurl, popname, wth, hgt, resize, scroll)
{
    var windowopenstring;
    windowopenstring="window.open('" + popurl + "', '" + popname + "', 'height=" + hgt + ",width=" + wth
    if(resize) windowopenstring+=",resizable"
    if(scroll) windowopenstring+=",scrollbars"
    windowopenstring  += "')"
    newWindow=eval(windowopenstring);    

return;
}

var newWin;
function popup(url) {
    if(newWin == null || newWin.closed) {
        newWin = window.open (url, "newWin", "toolbar=0,menubar=0,location=no,scrollbars=no,resizable=no,width=620,height=630,top=150,left=45")
    } else {
        newWin.close()
        newWin = window.open (url, "newWin", "toolbar=0,menubar=0,location=no,scrollbars=no,resizable=no,width=620,height=630,top=150,left=45")
    }
	while (newWin.document.forms['datacapture'] == null){}
}


function searchsubmit()
{
    document.searchmain.submit();
}

function envTypeCom(modelName){
    //OFI #1472 added GQOrigin=GN --- Venkata.
    popWin(autoDataServer+ autoDataComparePage + "?HT=" + handoffToken + "&GQOrigin=GN&model=" + modelName,'config','770','470','resize','scroll')
}        
function envType(modelName){
    location.href = autoDataServer + autoDataBuildPage + "?HT=" + handoffToken + "&AppID=GNQ&model=" + modelName;
}
function envTypeVC(modelName)
{
  location.href = autoDataServer + autoDataBuildPage + "?HT=" + handoffToken + "&AppID=VCQ&model=" + modelName;
}
function envCpo(){
    location.href = cpoUrl;
}        

var newWinBank;
function popUpBank(url) {
    if(newWinBank == null || newWinBank.closed) {
        newWinBank = window.open (url, "newWinBank", "toolbar=1,menubar=1,location=yes,scrollbars=yes,resizable=yes,top=150,left=45")
        window.newWinBank.focus();
    } else {
        //newWinBank.close()
        newWinBank = window.open (url, "newWinBank", "toolbar=1,menubar=1,location=yes,scrollbars=yes,resizable=yes,top=150,left=45")
        window.newWinBank.focus();
    }
}

function switchPrintStyle()
{
    if (isIE && !is_mac)
    {
         var checkSheet=document.styleSheets[0].href;
         checkSheet=checkSheet.toString();
         if (checkSheet.indexOf('config1')>-1 ) setActiveStyleSheet('vw_redesign_config2');     
    }
    else setActiveStyleSheet('vw_redesign_config2');
}

