﻿//var arrValue=["http://specials.uk.msn.com/vauxhall/agila/","http://specials.uk.msn.com/vauxhall/antara/","http://specials.uk.msn.com/vauxhall/astra/","http://specials.uk.msn.com/vauxhall/astra-tt/","http://specials.uk.msn.com/vauxhall/corsa/","http://specials.uk.msn.com/vauxhall/corsa-vxr/","http://specials.uk.msn.com/vauxhall/insignia/","http://specials.uk.msn.com/vauxhall/meriva/","http://specials.uk.msn.com/vauxhall/tigra/","http://specials.uk.msn.com/vauxhall/zafira/"];
//var arrText=["Agila","Antara","Astra","Astra TT","Corsa","Corsa VXR","Insignia","Meriva","Tigra","Zafira"];

var arrValue=["http://specials.uk.msn.com/vauxhall/agila/","http://specials.uk.msn.com/vauxhall/corsa/","http://specials.uk.msn.com/vauxhall/meriva/","http://specials.uk.msn.com/vauxhall/tigra/","http://specials.uk.msn.com/vauxhall/astra/","http://specials.uk.msn.com/vauxhall/astra-tt/","http://specials.uk.msn.com/vauxhall/zafira/","http://specials.uk.msn.com/vauxhall/insignia/","http://specials.uk.msn.com/vauxhall/antara/","http://specials.uk.msn.com/vauxhall/corsa-vxr/"];
var arrText=["Agila","Corsa","Meriva","Tigra","Astra","Astra TwinTop","Zafira","New Insignia","Antara","Corsa VXR"];


var idValue=["homepagepg","Agilapg","Antarapg","Astrapg","AstraTTpg","Corsapg","CorsaVXRpg","Insigniapg","Merivapg","Tigrapg","Zafirapg"];
var imgSrc=["http://amch.questionmarket.com/adsc/d447525/9/447703/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447704/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447712/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447710/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447711/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447708/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447709/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447713/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447707/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447706/adscout.php?ord=[randnum]","http://amch.questionmarket.com/adsc/d447525/9/447705/adscout.php?ord=[randnum]"];
var clkTag=["http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.62;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.31;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.34;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.37;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.40;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.43;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.46;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.49;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.52;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.55;sz=1x1;ord=[timestamp]?","http://ad.uk.doubleclick.net/ad/N2121.MSN.caratintuk/B3008773.56;sz=1x1;ord=[timestamp]?"];

function createSelectSub()
{
    var target=document.getElementById("ddlist");
    
    var select=document.createElement("select");
    
    var lable=document.createElement("label");
    lable.setAttribute("id","lblcars");
    
    //set style for added element
    
    lable.style.display="block";
    lable.style.paddingTop="1px";
    lable.style.paddingBottom="7px";
    lable.style.color="#fff";
    lable.style.fontSize="12px";
    lable.style.fontWeight="bold";
    lable.style.marginLeft="26px";
    
   // target.style.marginLeft="4px";
    target.style.paddingBottom="0px";
    target.style.color="#07519a";
    
    select.style.width="162px";
    select.style.height="20px";
    select.style.marginLeft="26px";
    select.style.padding="0";
    
    var lableText=document.createTextNode("SEE THE VAUXHALL RANGE");
    lable.appendChild(lableText);
    target.appendChild(lable);
    
    select.setAttribute("id","ddlBmsSubHd");
    select.appendChild(createOption("","----CHOOSE A MODEL----"));
    for(var i=0,length=arrValue.length;i<length;i++)
    {
        select.appendChild(createOption(arrValue[i],arrText[i]));
    }
    
    target.appendChild(select);
    select.onchange=function()
    {
        var tempUrl=this.options[this.selectedIndex].value;
        if(tempUrl!="")
        {
            window.location.href=tempUrl;
        }
    };
}
function createSelectPage()
{
    var target=document.getElementById("ddlistpg");
    
    var select=document.createElement("select");
    
    // target.style.marginLeft="4px";
    target.style.paddingBottom="0px";
    target.style.color="#07519a";
    
    select.style.width="152px";
    select.style.height="20px";
//    select.style.marginLeft="26px";
    select.style.padding="0";
    
    select.setAttribute("id","ddlBmsPg");
    select.appendChild(createOption("","----CHOOSE A MODEL----"));
    for(var i=0,length=arrValue.length;i<length;i++)
    {
        select.appendChild(createOption(arrValue[i],arrText[i]));
    }
    
    target.appendChild(select);
    select.onchange=function()
    {
        var tempUrl=this.options[this.selectedIndex].value;
        if(tempUrl!="")
        {
            window.location.href=tempUrl;
        }
    };
}            
function createOption(value,text)
{
    var option=document.createElement("option");
    var text=document.createTextNode(text);
    option.appendChild(text);
    option.setAttribute("value",value);
    return option;
}
function addImage()
{
    var target=document.getElementById("pgtracking");
    if(target)
    {
        var x;
        /*if (navigator.appName != 'Microsoft Internet Explorer')
        { 
	         x=target.childNodes[1].attributes.getNamedItem("id");
        }
        else 
        {*/
	        x=target.firstChild.attributes.getNamedItem("id");
        //}
        var img=document.createElement("img");
        var img1=document.createElement("img");
        
        for(var i=0,length=idValue.length;i<length;i++)
        {
            if(x.value==idValue[i])
            {
                img.setAttribute("src",imgSrc[i]);
                img1.setAttribute("src",clkTag[i]);
                break;
            }
        }
        img.setAttribute("height","1");
        img.setAttribute("width","1");
        img.setAttribute("border","0");
        img1.setAttribute("height","1");
        img1.setAttribute("width","1");
        img1.setAttribute("border","0");
        target.appendChild(img);
        target.appendChild(img1);
    }
}
var imgSrc1=["Little_Agila.jpg","Little_Antara.jpg","Little_Astra.jpg","Little_AstraTT.jpg","Little_Corsa.jpg","Little_CorsaVXR.jpg","Little_Insignia.jpg","Little_Meriva.jpg","Little_Tigra.jpg","Little_Zafira.jpg"];
var imgAlt=["Agila","Antara","Astra","Astra TwinTop","Corsa","Corsa VXR","Insignia","Meriva","Tigra","Zafira",];
function randomImage()
{
    var target=document.getElementById("ranimg");
    var imgNo= Math.floor(Math.random()*10);
    var basePath="http://st.sand.msn-int.com/br/DD/britishmotorshow/RandomImages/";
    if(target)
    {
         var imgTag = target.getElementsByTagName("img")[0];
         if(imgTag)
         {
            imgTag.setAttribute("src",basePath+imgSrc1[imgNo]);
            imgTag.setAttribute("height","130");
            imgTag.setAttribute("width","152");
            imgTag.setAttribute("alt",imgAlt[imgNo]);
            img.setAttribute("title",imgAlt[imgNo]);
         }
         else
         {
            var newDiv=document.createElement("div");
            newDiv.setAttribute("class","img");
            var img=document.createElement("img");
            img.setAttribute("src",basePath+imgSrc1[imgNo]);
            img.setAttribute("height","130");
            img.setAttribute("width","152");
            img.setAttribute("alt",imgAlt[imgNo]);
            img.setAttribute("title",imgAlt[imgNo]);
            newDiv.appendChild(img);
            target.appendChild(newDiv);
         }
     }    
}
function breakLine()
{
    var target=document.getElementById("extlinks");
     if(target)
    {
         var liTag = target.getElementsByTagName("a")[1];
         
         if(liTag && navigator.appName != 'Microsoft Internet Explorer')
         {
//            alert('hi');
            liTag.innerHTML="BRITISH INTERNATIONAL<br/>MOTOR SHOW"   
         }
     }
}
createSelectSub();
createSelectPage();
addImage();
randomImage();
breakLine();
