var selected = 0;
//}
//Maps labels to menuitem
var menuItem = $H();
var l = window.location.hash;
menuItem.set("home", 0);
menuItem.set("members", 1);
menuItem.set("news", 2);
menuItem.set("contact", 3);

//initiate onLoad
function init()
{
    l = window.location.hash;
    if(l == ""){
        selected=0;
        window.location.hash="#home";
        home();
    }
    else if(l == "home" || l == "#home"){
        selected=0;
        home();
        
    }
    else if(l == "members" || l == "#members"){
        selected=1;
        members();
    }
    else if(l == "news" || l == "#news"){
        //selected=2;
        news();
    }
    else if(l == "contact" || l == "#contact"){
        //selected=3;
        contact();
        
    }else{
        //selected=0;
        window.location.hash="#home";
        home();
    }
    //selected = 0;
    if(accedobroadband.querystring.getValue("mail")=="sent"){
        contact();
        $('page').update(); //cleans page
        el = new Element('div', {
            id:"mail"
        });
        $('page').appendChild(el);
        $('mail').update("<h1>Your mail has been sent. Thanks for your interest.</h1>");
    }
    if(accedobroadband.querystring.getValue("mail")=="failed"){
        contact();
        $('page').update(); //cleans page
        el = new Element('div', {
            id:"mail"
        });
        $('page').appendChild(el);
        $('mail').update("<h1>We failed to deliver your mail!<br />An unknown error has occurred, please try again.</h1>");
    }
    if(accedobroadband.querystring.getValue("mail")=="form"){
        contact();
        $('page').update(); //cleans page
        el = new Element('div', {
            id:"mail"
        });
        $('page').appendChild(el);
        $('mail').update("<h1>We failed to deliver your mail!<br />An unknown error has occurred, please try again.</h1>");
    }
    Cufon.refresh();
//if(accedobroadband.querystring.getValue("mail")==null){
//selected=1;
//home();
//}


}
function checkForm()
{
    //checks if user entered the form correctly
    var name = $F('iName');
    var email = $F('iMail');
    var message = $F('iMessage');
    var state = true;
    
    $('iSubmit').setStyle({
        backgroundImage: "url('img/contact/submit_disabled.png')"
    });
    $('iSubmit').disable();
    $('cName').setStyle({
        color:"white"
    });
    $('cName').update("<b>Your name:</b>");
    $('cMail').setStyle({
        color:"white"
    });
    $('cMail').update("<b>Your Email address:</b>");
    $('cMessage').setStyle({
        color:"white"
    });
    $('cMessage').update("<b>Message:</b>");
    if(name == ""){
        
        $('cName').update($('cName').innerHTML + "<br /><b>Required Field</b>");
        $('cName').setStyle({
            color:"#ff6600"
        });
        state=false;
    }
    if(email == "" || !(email.include('@')) || !(email.include('.'))){
        
        $('cMail').update($('cMail').innerHTML + "<br /><b>Required Field, please enter a valid email. Ex. example@exaple.com</b>");
        $('cMail').setStyle({
            color:"#ff6600"
        });
        state=false;
    }
    if(message == ""){
        
        $('cMessage').update($('cMessage').innerHTML + "<br /><b>Required Field</b>");
        $('cMessage').setStyle({
            color:"#ff6600"
        });
        state=false;
    }
    return state;
}
function checkName(){
    
    
    $('cName').setStyle({
        color:"white"
    });
    $('cName').update("<b>Your name:</b>");
    $('iSubmit').enable();
    $('iSubmit').setStyle({
        backgroundImage: "url('img/contact/submit.png')"
    });
    
}
function checkMail(){
    
    
    $('cMail').setStyle({
        color:"white"
    });
    $('cMail').update("<b>Your Email address:</b>");
    $('iSubmit').enable();
    $('iSubmit').setStyle({
        backgroundImage: "url('img/contact/submit.png')"
    });
}
function checkMessage(){
    
    
    $('cMessage').setStyle({
        color:"white"
    });
    $('cMessage').update("<b>Message:</b>");
    $('iSubmit').enable();
    $('iSubmit').setStyle({
        backgroundImage: "url('img/contact/submit.png')"
    });
    
}
function home(){
 
    window.location.hash = "home";
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected).setStyle({
        visibility:"visible"
    });
    $('page').update(); //cleans page
    selected = 0;
    $('menuItem_'+selected).setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"visible"
    });
    el = new Element('div', {
        id:"bkg"
    });
    $('page').appendChild(el);

    el = new Element('div', {
        id:"lText"
    });
    $('page').appendChild(el);
    $('lText').update("<h1>Connected TV</h1><br /><br />The Connected TV Game Forum strives for open and accessible standards in game development for Connected TV.  On behalf of its members it drives joint requirement gathering towards the Consumer Electronics and platform companies to drive awareness and usage of gaming on the Connected TV platforms.<br /><br />Connected TV Game Forum is an independent industry organization.");

    el = new Element('div', {
        id:"rText"
    });
    $('page').appendChild(el);
    $('rText').update("<h1>News</h1><h2><br /><br />Industry leaders create New Connected TV Game Forum</h2><i> Las Vegas, January 5 2010</i> - A selection of the world\u2019s foremost interactive companies are establishing a new forum for the development of games on connected TV, namely Accedo, Betfair, PlayJam, RallyPoint and Two Way.");
    el = new Element('div', {
        id:"rMore",
        onClick:"news();"
    });
    $('page').appendChild(el);
    $('rMore').setStyle({
        cursor:"pointer"
    })
    $('rMore').update("<h2>Read more</h2>");
        
        
    
 
	
    Cufon.refresh();
}
function members(){

    window.location.hash="#members";
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected).setStyle({
        visibility:"visible"
    });
    $("page").update();
    selected = 1;
    $('menuItem_'+selected).setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"visible"
    });
     
    //accedo
    el = new Element('div', {
        id:"accedo"
    });
    $('page').appendChild(el);
    el = new Element('div', {
        id:"aLogo"
    });
    $('accedo').appendChild(el);

    el = new Element('div', {
        id:"aText"
    });
    $('accedo').appendChild(el);
    $('aText').update("<h1>Accedo Broadband</h1><br /><br />Heliosgatan 11, 120 30 Stockholm, Sweden<br /><a href='http://www.accedobroadband.com' target='_blank'>http://www.accedobroadband.com</a>");
		
    //betfair
    el = new Element('div', {
        id:"betfair"
    });
    $('page').appendChild(el);
    el = new Element('div', {
        id:"bLogo"
    });
    $('betfair').appendChild(el);

    el = new Element('div', {
        id:"bText"
    });
    $('betfair').appendChild(el);
    $('bText').update("<h1>Betfair</h1><br /><br />Betfair Ltd, Winslow Road, Hammersmith, London W6 9HP, UK<br /><a href='http://corporate.betfair.com' target='_blank'>http://corporate.betfair.com</a>");
    //playjam
    el = new Element('div', {
        id:"playjam"
    });
    $('page').appendChild(el);
    el = new Element('div', {
        id:"pLogo"
    });
    $('playjam').appendChild(el);
  
    el = new Element('div', {
        id:"pText"
    });
    $('playjam').appendChild(el);
    $('pText').update("<h1>PlayJam</h1><br /><br />Playjam/Static 2358 Ltd, 2-23 Old Street, London, EC1V 9HL, UK<br /><a href='http://www.playjam.com' target='_blank'>http://www.playjam.com");
    //rallypoint
    el = new Element('div', {
        id:"rallypoint"
    });
    $('page').appendChild(el);
    el = new Element('div', {
        id:"rLogo"
    });
    $('rallypoint').appendChild(el);
       
    el = new Element('div', {
        id:"raText"
    });
    $('rallypoint').appendChild(el);
    $('raText').update("<h1>RallyPoint</h1><br /><br />Rallypoint Systems Ltd, 2800 NE Broadway, Portland, OR 97212, USA<br /><a href='http://www.rallycast.com' target='_blank'>http://www.rallycast.com");
    //twoway
    el = new Element('div', {
        id:"twoway"
    });
    $('page').appendChild(el);
    el = new Element('div', {
        id:"tLogo"
    });
    $('twoway').appendChild(el);
 
    el = new Element('div', {
        id:"tText"
    });
    $('twoway').appendChild(el);
    $('tText').update("<h1>Two Way</h1><br /><br />Two Way Media Limited, 6/7 Princes Court, Wapping Lane, London E1W 2DA, UK<br /><a href='http://www.twowaymedia.co.uk' target='_blank'>http://www.twowaymedia.co.uk");
	

    Cufon.refresh();
}
function news(){
    window.location.hash="#news";
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected).setStyle({
        visibility:"visible"
    });
    $("page").update();
    selected = 2;
    $('menuItem_'+selected).setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"visible"
    });

    el = new Element('div', {
        id:"nText"
    });
    $('page').appendChild(el);
    $('nText').update("<h1>Industry leaders create New Connected TV Game Forum</h1><br /><br />\t\t\t\t\t<b>Las Vegas, January 5 2010 - A selection of the world\u2019s foremost interactive companies are establishing a new forum for the development of games on connected TV, namely Accedo, Betfair, PlayJam, RallyPoint and Two Way Media.</b>\n\t\t\t\t\t<br /><br />Online games are a major driver in the multi-platform digital entertainment arena, attracting 38% of internet users whilst generating billions of downloads via mobile phone applications and digital TV platforms. Moreover, they create new revenue streams from a frequent and loyal user base. For example, gaming on social media sites already generate more than $500M in micro-transactions every year. *  The Forum\u2019s partners believe games will act as a prime motivator for consumers to connect their TVs to the internet. .\n\t\t\t\t\t<br /><br />The Connected TV Game Forum aims to galvanise a common approach to gaming requirements for connected TV devices including functionality, features and open standards. The Forum seeks to voice a clear, collective opinion on the requisite technical and commercial factors for compelling games services, primarily targeting key consumer electronics  platforms. The Connected TV Forum openly invites all companies wishing to work closely on and benefit from this opportunity.\n\t\t\t\t\t<br /><br />Each of the founding partners brings valued experience and insight to the Forum, having created reputable software and applications for interactive platforms.\n\t\t\t\t\t<br /><br /><i>\u201CCasual gaming is clearly one of the great opportunities for Connected TV and has proven consumer interest and willingness to pay,\u201D</i> commented Michael Lantz, CEO, Accedo Broadband. <i>\u201CAt Accedo we remain committed to the vision of Connected TV, and will through the forum jointly drive gaming and application requirements and standards for any online TV solution\u201D.</i>\n\t\t\t\t\t<br /><br /><i>\"Betfair is excited by the opportunity offered by connected television and fully supports the Connected TV Game Forum in its \u00A0promotion of gaming services that can be delivered over this new platform ,\"</i> says Simon Miller, CEO, Betfair TV. <i>\"Games and Gaming applications will become key revenue streams for manufacturers and operators, and we expect the forum will make a strong case for platform standardisation so that new products can be brought to market quickly and distributed easily.\"</i>\n\t\t\t\t\t<br /><br /><i>\u201CThe combination of Internet and the television in the form of \u2018TV Apps\u2019 is a perfect combination for the thirty million die hard fantasy sports gamers that watch live sports broadcasts and track detailed stats on the Internet,\u201D</i> said Jeff Allen. <i>\u201CAs more connected TV platforms come to the market, it is important that device OEMs work with content owners and aggregators to promote common user interfaces and standards so that consumers will not become disenchanted with this huge promise.\u201D</i>\n\t\t\t\t\t<br /><br /><i>\u201CFollowing the success of PlayJam games via digital TV platforms across Europe, Asia and the US, we believe that the next generation of connected TVs presents an even greater commercial opportunity\u201D</i> says PlayJam CEO Jasper Smith. <i>\u201CHowever, it is essential for manufacturers and other developers to gain a more detailed understanding of the economics and technology in order to create an optimal environment that maximises both consumers\u2019 experience and manufacturers\u2019 profits.\u201D</i>\n\t\t\t\t\t<br /><br /><i>\u201CTwo Way has been making games for TV for more than 10 years so we know that the combination of TV and gaming is a compelling consumer proposition,\u201D</i> commented James Turner, CEO of Two Way Media. <i>\u201CWe want to work with others in the industry to ensure that Connected TV is an excellent gaming platform, both to play and to develop for, which will ultimately guarantee its commercial success.\u201D</i>\n\t\t\t\t\t<br /><br />The Connected TV Game Forum invites other companies developing games and gaming related applications to join the forum to provide synchronised requirements to the Connected TV Industry.\n\t\t\t\t\t<br /><br />Read more about the Connected TV Game Forum on<br /><a href=\"http://www.connectedtvgameforum.com\" target=\"_blank\">http://www.connectedtvgameforum.com</a>\n\t\t\t\t\t<br /><br />*Statistics from Casual Connect Kiev Oct 2009\n\t\t\t\t\t<br /><br /><b>About the founding companies</b>\n\t\t\t\t\t<br /><br />Accedo Broadband\n\t\t\t\t\t<br /><a href=\"http://www.accedobroadband.com\" target=\"_blank\">http://www.accedobroadband.com</a>\n\t\t\t\t\t<br /><br />Betfair TV\n\t\t\t\t\t<br /><a href=\"http://corporate.betfair.com\" target=\"_blank\">http://corporate.betfair.com</a>\n\t\t\t\t\t<br /><br />RallyPoint Systems\n\t\t\t\t\t<br /><a href=\"http://www.rallycast.com\" target=\"_blank\">http://www.rallycast.com</a>\n\t\t\t\t\t<br /><br />PlayJam\n\t\t\t\t\t<br /><a href=\"http://www.playjam.com\" target=\"_blank\">http://www.playjam.com</a>\n\t\t\t\t\t<br /><br />Two Way Media\n\t\t\t\t\t<br /><a href=\"http://www.twowaymedia.co.uk\" target=\"_blank\">http://www.twowaymedia.co.uk</a><br />&nbsp;");
   


    Cufon.refresh();
}
function contact(){

    window.location.hash="#contact";
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected).setStyle({
        visibility:"visible"
    });
    $("page").update();
    selected = 3;
    $('menuItem_'+selected).setStyle({
        visibility:"hidden"
    });
    $('menuItem_'+selected+'_Focus').setStyle({
        visibility:"visible"
    });
    el = new Element('div', {
        id:"cText"
    });
    $('page').appendChild(el);
    $('cText').update("Would you like to join the Connected TV Game Forum or get more information about 2010 plans and activities?<br /><br /> Contact the forum using the form below.");
    el = new Element('div', {
        id:"cForm"
    });
    $('page').appendChild(el);
    el = new Element('form', {
        id:"form",
        action:"mail.php",
        method:"post",
        onSubmit:"return checkForm();"
    });
    $('cForm').appendChild(el);
    el = new Element('div', {
        id:"cName"
    });
    $('form').appendChild(el);
    $('cName').setStyle({
        color:"white"
    });
    $('cName').update("<b>Your name:</b>");
    el = new Element('input', {
        id:"iName",
        type:"text",
        name:"name",
        size:"40",
        value:"",
        onkeypress:"checkName();"
    });
    $('form').appendChild(el);
    el = new Element('div', {
        id:"cMail"
    });
    $('form').appendChild(el);
    $('cMail').setStyle({
        color:"white"
    });
    $('cMail').update("<b>Your Email address:</b>");
    el = new Element('input', {
        id:"iMail",
        type:"text",
        name:"email",
        size:"40",
        value:"",
        onkeypress:"checkMail();"
    });
    $('form').appendChild(el);
    el = new Element('div', {
        id:"cMessage"
    });
    $('form').appendChild(el);
    $('cMessage').setStyle({
        color:"white"
    });
    $('cMessage').update("<b>Message:</b>");
    el= new Element('textarea', {
        id:"iMessage",
        type:"text",
        name:"message",
        rows:"10",
        cols:"80",
        onkeypress:"checkMessage();"
    });
    $('form').appendChild(el);
    el= new Element('div', {
        id:"dSubmit",
        type:"submit",
        value:""
    });
    $('form').appendChild(el);
    el= new Element('input', {
        id:"iSubmit",
        type:"submit",
        value:""
    });
    $('dSubmit').appendChild(el);
    $('iSubmit').enable();

    Cufon.refresh();
}