/****** TRIVIA ******/

function trivia_open() {
window.open('http://www.mtv3.fi/helmi/trivia/seksivisa/trivia.shtml','trivia','width=600,height=500,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
}

function matkatesti_open() {
window.open('http://mainos2.mtv3.fi/mainoskuvat/lomatesti2006/trivia_matkailu.html','trivia','width=790,height=500,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
}


/****** HAKU ******/
function haku(){
  if (document.lom.sel[0].checked == true){
     location = 'http://altavista.mtv3.fi/cgi-bin/query?mss=search&sel=mtv3&kl=&x=19&y=8&q='+lom.q.value;
  } else if (document.lom.sel[1].checked == true){
     location = 'http://bonus.mtv3.fi/google/index.shtml?hl=fi&ie=latin-1&oe=utf-8&client=mtv3&output=xml_no_dtd&num=10&start=0&cr=fi&ad=w5n2&adsafe=high&ip=1.1.1.1&useragent=Mozilla&lr=&q='+lom.q.value;
  } else if (document.lom.sel[2].checked == true){
     location = 'http://bonus.mtv3.fi/fonecta/index.shtml?'+lom.q.value;
  } 
  return false
}

function haku2(lom){
     location = 'http://altavista.mtv3.fi/cgi-bin/query?mss=search&sel=mtv3&kl=&x=19&y=8&q='+lom.q.value+'#tulos';
     return false
}
/****** HAKU ******/

/****** KUVAGALLERIAT ******/
function galleria(osio) {
  if(osio=="ohjelmat_viihde_suuri_seikkailu_2005"){
    var galleria = window.open("http://www.mtv3.fi/galleria/flash/kuvagalleria.html?"+osio,"galleria2005","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=728,height=590");
    galleria.focus();
  }
  else if(osio){
    var galleria = window.open("http://www.mtv3.fi/galleria/flash/kuvagalleria.html?"+osio,"galleria2005","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=588,height=500");
    galleria.focus();
  }
  else{
    return false;
  }
}

function galleria_open(osio,kansio) {
  if(!osio){
	var osio = "f1";
  }
  if(!kansio){
	var kansio = "Kimi";
  }
  if(osio=="f1"){
    window.open("http://www.mtv3.fi/cgi-bin/click?adid=976&url=http://www.mtv3.fi/urheilu/f12005/galleria.html","f1galleria","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=648,height=582");
  }
  else if(osio=="uutiset"){
      window.open('http://www.mtv3.fi/uutiset/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="urheilu"){
      window.open('http://www.mtv3.fi/urheilu2003/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="koris"){
      window.open('http://www.mtv3.fi/urheilu/koris/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="nhl"){
      window.open('http://www.mtv3.fi/urheilu/nhl/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="alppihiihto"){
      window.open('http://www.mtv3.fi/urheilu/alppihiihto/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="mmalppihiihto"){
      window.open('http://www.mtv3.fi/urheilu/mmalppihiihto/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="mmyleisurheilu"){
      window.open('http://www.mtv3.fi/urheilu/mmyleisurheilu2005/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  } 
  else if(osio=="makihyppy"){
      window.open('http://www.mtv3.fi/urheilu/makihyppy2004/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="wtyyli"){
      window.open('http://www.mtv3.fi/ohjelmat/wtyyli2004/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="salatutelamat2005"){
      window.open('http://www.mtv3.fi/ohjelmat/salatutelamat/kuvagalleria2005.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="salatutelamat2004"){
      window.open('http://www.mtv3.fi/ohjelmat/salatutelamat/kuvagalleria2004.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }

  else if(osio=="futis"){
      window.open('http://www.mtv3.fi/urheilu/futis2004/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="f1kuskit"){
      window.open('http://www.mtv3.fi/urheilu/f1/kuvagalleria.html?'+kansio,'galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="suuriseikkailu"){
      window.open('http://www.mtv3.fi/suuriseikkailu/kuvagalleria.html','galleria','width=640,height=550,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  }
  else if(osio=="em_futis" || osio=="emfutis"){
      window.open('http://www.mtv3.fi/urheilu/emfutis2004/kuvagalleria.html','galleria','width=640,height=550,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
}
  else if(osio=="olympialaiset" || osio=="Olympialaiset"){
      window.open('http://www.mtv3.fi/urheilu/olympialaiset2004/kuvagalleria.html','galleria','width=640,height=550,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
}
  else if(osio=="mmhiihto"){
      window.open('http://www.mtv3.fi/urheilu/mmhiihto2005/kuvagalleria.html','galleria','width=640,height=512,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
}
  else {}
}
/****** KUVAGALLERIAT ******/

/****** ERILAISET POPUP-IKKUNAT ******/
function jump (url,name,args) {
 popup = window.open (url,name,args);
}

function suomen_syke() {
  var syke_popup = window.open('http://bonus.mtv3.fi/syke','syke_popup','width=600,height=800,scrollbars=yes,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no,resizable=yes');
  syke_popup.focus();
}

function open_video(url,video){
    window.open('/video/real.shtml?' +video,'videoclip','width=400,height=400,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
}

function livepopup(osio) {
  if(!osio){
	var osio = "f1";
  }	
  var livepopup = window.open('/urheilu/' + osio + '/live','livepopup','width=620,height=600,scrollbars=yes,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no,resizable=yes');
  livepopup.focus();
}

function helmi_kartat(osio) { 
  if(!osio){ 
        var osio = "http://www.mtv3.fi/helmi/kuudesaisti"; 
  } 
  var nettitv = window.open(osio,'Kartat','width=850,height=650,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no,scrollbars');
  nettitv.focus();
} 

function nettitv(osio) {
  if(!osio){
	var osio = "http://nettitv.mtv3.fi/mtv3";
  }
  var nettitv = window.open(osio,'NettiTV','width=990,height=680,resizable=no,screenX=50,screenY=50,left=50,top=50,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  nettitv.focus();
}

function ohjelmatiedot(osio) {
  var ohjelmatieto_popup = window.open(osio,'ohjelmatietopopup','width=300,height=400,scrollbars=yes,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no,resizable=yes');
  ohjelmatieto_popup.focus();
}

function helmitesti(osio) {
  var helmitesti_popup = window.open('http://naiset.almamedia.fi/helmi/testit/testikone/flash.shtml?'+osio,'helmitestipopup','width=780,height=610,scrollbars=yes,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no,resizable=yes');
  helmitesti_popup.focus();
}

function open_chat(osio) {
  if(!osio){
	var osio = "musiikki";
  }
  window.open('http://www.mtv3.fi:8004/lgn?c='+osio,'chat'+osio,'width=800,height=600,toolbar=no,resizable=yes,scrollbars=yes');
}

function mobiili(osio) {
      var mobiilipopup = window.open(osio,'mobiilipopup','width=770,height=500,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no,scrollbars=yes');
      mobiilipopup.focus();
}



/****** ERILAISET POPUP-IKKUNAT ******/


/****** FLASH ******/
function do_flashbanner(name,adid,url,width,height){
 document.write(' <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
 document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
 document.write(' ID=banner WIDTH="'+width+'" HEIGHT="'+height+'"> ');

 document.write(' <PARAM NAME=src VALUE="' + name + '?clk=http://www.mtv3.fi/cgi-bin/click%3fadid%3d' + adid + '%26url%3d' + url + '">');
 document.write(' <param name="Autostart" value="true"> ');
 document.write(' <param name="quality" value="autohigh"> ');

 document.write(' <EMBED SRC="' + name + '?clk=http://www.mtv3.fi/cgi-bin/click%3fadid%3d' + adid + '%26url%3d' + url + '" ');
 document.write(' swLiveConnect=TRUE WIDTH="'+width+'" HEIGHT="'+height+'" quality=autohigh');
 document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');

 document.write(' </EMBED> ');
 document.write(' </OBJECT> ');
}
/****** FLASH ******/

/****** ??NESTYS ******/
function gallup(form){
        var lomake = form;
        var radio = 0;
        var checked_radio = 0;
        var checkbox = 0;
        var checked_checkbox = "";
        // k?yd??n kaikki elementit l?pi
        for(i=0;i<lomake.elements.length;i++){
                var nimi = lomake.elements[i].name;
                var tyyppi = lomake.elements[i].type;
                var arvo = lomake.elements[i].value;
                // kuinka monta radio-button kysymyst? on kaiken kaikkiaan
                if(tyyppi=="radio" && arvo=="1"){
                        radio++;
                }
                // tarkistetaan, etta jotain on valittu
                if(tyyppi=="radio"){
                        if(lomake.elements[i].checked){
                                checked_radio++;
                        }
                }
                // kuinka monta checkbox kysymyst? on kaiken kaikkiaan
                var pubid = new Array();
                pubid = nimi.split("_");
                if(tyyppi=="checkbox" && pubid[0]!=edellinen){
                        checkbox++;
                }
                // tarkistetaan, etta jotain on valittu jokaiseen checkbox kysymykseen
                // muodostetaan merkkijono, joka on muotoa: '12345#56789#'
                if(tyyppi=="checkbox"){
                        if(lomake.elements[i].checked){
                                if(checked_checkbox.indexOf(pubid[0]) == -1){
                                        if(checked_checkbox.length != 0){
                                                checked_checkbox += "#";
                                        }
                                        checked_checkbox += pubid[0];
                                        //alert(checked_checkbox);
                                }
                        }
                }
                edellinen = pubid[0];
        }
        // jos ei ole vastattu jokaiseen radio-button elementtiin
        if(radio == 1 && radio != checked_radio){
                alert("Vastaa ensin kysymykseen.");
                return false;
        }
        if(radio > 1 && radio != checked_radio){
                alert("Vastaa kaikkiin kysymyksiin.");
                return false;
        }
        var box = new Array;
        box = checked_checkbox.split('#');
        //alert(box[0].length+";"+box[1]);
        if(checkbox == 1 && (box[0].length <= 0 || checkbox != box.length)){
                alert("Vastaa ensin kysymykseen.");
                return false;
        }
        if(checkbox > 1 && (box[0].length <= 0 || checkbox != box.length)){
                alert("Vastaa kaikkiin kysymyksiin.");
                return false;
        }
        else{
                return true;
        }
}

function gallup_kommentti(form){
        var lomake = form;
        if(lomake.nimi.value == ""){
                alert("Nimimerkki puuttuu!");
                lomake.nimi.focus();
                return false;
        }
        if(lomake.teksti.value == ""){
                alert("Perustelu puuttuu!");
                lomake.teksti.focus();
                return false;
        }
        return true;
}

function gallup_kuva(url,width,height) {
  var w = width + 20;
  var h = height + 20;
  var imagepopup = window.open(url,'imagepopup','width='+w+',height='+h+',scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
  imagepopup.focus();
}
/****** ??NESTYS ******/

/****** SEKALAISET ******/
// ensin kuvan nimi ja toiseksi kuvan url
function hover(which,pic) {
  var nn=false;
  // tarkistetaan selainversio
  if (browser_name == "Netscape" && browser_version >= 3.0 ||
      browser_name == "Microsoft Internet Explorer" && browser_version >= 4.0) {
	nn = true; }
  if(nn)
	document.images[which].src = pic;
}
/****** SEKALAISET ******/
