/* Uudelleenkäytettävä Ajax-alustus */
function ajaxInit() 
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Selaimesi ei tue Ajaxia!");
        return false;
        }
      }
    }
    return xmlHttp;
  }
 

function Blogit(sivu, lahtoid)
  {
    xmlHttp = ajaxInit();
    xmlHttp.onreadystatechange=function()
	  {
	  if(xmlHttp.readyState==4)
	    {
	    kohde = document.getElementById("nosto_blogit");
	    kohde.innerHTML=xmlHttp.responseText + '<div class="clear_both"></div>';
	    }
    }

    xmlHttp.open("GET",sivu,true);
    xmlHttp.send(null);
    return false;
  }

  
  
function koti_kerro() {
      var kerropopup = window.open('http://www.mtv3.fi/ohjelmat2009/kerro.shtml?' + escape(window.location.href),'kerropopup','width=250,height=160,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
      kerropopup.focus();
}

function jaa_twitter() {
	var url = location.href;
	var title = document.title;
	var jaapopup = window.open('http://twitter.com/home?status='+title+' '+url,'kerropopup','width=850,height=600,resizable=yes,location=yes,menubar=no,toolbar=no,titlebar=no,personalbar=no,directories=no,fullscreen=no, scrollbars');
	jaapopup.focus();
}

jQuery(document).ready(function() {

  // Oikean laidan listausten hover-vaihdot
  jQuery(".nostovaihto a").hover(function() {
    var idname = jQuery(this).attr("rel");
     if ( jQuery("#" + idname).is(":hidden") ) {
      jQuery(".nostovaihto .active").removeClass("active");
      jQuery(".oikealistaus").hide();
      jQuery("#" + idname).show();
    }
    jQuery(this).attr("class", "active");
    jQuery(this).parent().attr("class", "active");
  }, function() {});
  

  // Alalaidan listausten hover-vaihdot
  jQuery(".nostovaihto_ala a").hover(function() {
    var idname = jQuery(this).attr("rel");
     if ( jQuery("#" + idname).is(":hidden") ) {
      jQuery(".nostovaihto_ala .active").removeClass("active");
      jQuery(".alalistaus").hide();
      jQuery("#" + idname).show();
    }
    jQuery(this).attr("class", "active");
    jQuery(this).parent().attr("class", "active");
  }, function() {});
  
  // Disabloidaan klikit
  jQuery(".nostovaihto a").click(function() { return false; });

//  var h = jQuery("#nosto_paauutiset").height();
//  jQuery(".body_uutiset .alalistaus").css("height", h + "px") ; 

  jQuery(".karuselli").cycle({
    fx: 'scrollLeft',
    timeout: 4000,
    speed: 500,
    pause: 1
  });

    // Tulosta ja kerro kaverille
  jQuery(".artikkelinapit .nappi_facebook a").click(function() {
    jQuery(this).blur();
    var jaa = window.open('http://www.facebook.com/sharer.php?u=' + escape(window.location.href) ,'popup','width=640,height=480,resizable=no,location=no,menubar=no,toolbar=no,titlebar=no,personalbar=no,personalbar=no,directories=no,fullscreen=no');
    jaa.focus();
    return false;
  });
  jQuery(".artikkelinapit .nappi_myspace a").click(function() {
    jQuery(this).blur();
    GetThis(document.title, '&nbsp;', window.location.href, 3);
    return false;
  });
  jQuery(".artikkelinapit .nappi_kerro a").click(function() {
    koti_kerro();
    return false;
  });
  jQuery(".artikkelinapit .nappi_twitter a").click(function() {
    jaa_twitter();
    return false;
  });
  
  jQuery(".artikkelinapit .nappi_jaa a").click(function() { 
		if ( jQuery(".artikkelinapit .nappi_jaa").hasClass("over") ) {
			jQuery(".artikkelinapit .nappi_jaa").removeClass("over");
		} else {
			jQuery(".artikkelinapit .nappi_jaa").addClass("over");
		}
		return false;
  });
	
  jQuery(".artikkelinapit .nappi_jaa ul li a").click(function() { 
		jQuery(".artikkelinapit li").removeClass("over");
		return false;
  });

});

function checkbox(form){
if(form.kuittaus.checked){
 return true;
}
else{
 alert("Et voi l&auml;hett&auml;&auml; hakemusta hyv&auml;ksym&auml;tt&auml; ehtoja -  ole hyv&auml; ja palaa t&auml;st&auml; hakemukseen.");
 return false;
}
}

