

/*******************************************************************
 ** cDialog
 *******************************************************************/

function cDialog(strDialogType) {

  this.html= function(x) {
    html = x;

    //$(".dialog_close").click();

    $("body").append('<div class="dialogwrapper d_'+strDialogType+'" style="top:' + $(window).scrollTop() + 'px;"><div class="d_shadow"><a href="#" id="dialog_close">Stäng</a><div class="dialog_border"><div class="dialog_content">'+html+'</div></div></div></div>');
    $(".dialogwrapper").fadeIn();
    $("#dialog_close").click(function(){
      $(this).parent().parent().fadeOut().remove(1000);
      return false;
    })
  }
}
var cVideoDialog = new cDialog("video");
var cDialog = new cDialog("normal");


function openLogIn() {
  cDialog.html(''
              +'<div style="padding: 10px; width:407px;">'
              +'     <div id="login_dialog_login">'
              +'          <div class="title">Sugen på att logga in?</div>'
              +'          <div style="padding: 10px;">'
              +'               <form action="'+root+'members/login/login.asp" method="post" id="form_dialog_login" onSubmit="return postLogin(this.id)">'
              +'                     &nbsp;&nbsp;<small>Användarnamn</small>'
              +'                     <br /><input type="text" tabindex="101" name="username" style="font-size: 18px; padding: 5px; border: 1px solid #ccc; -moz-border-radius: 5px;-khtml-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;" />'
              +'                     <input type="submit" tabindex="103" class="button small" value="Logga in &raquo;" />'
              +'                     <div class="clear"></div>'
              +'                     &nbsp;&nbsp;<small>Lösenord</small>'
              +'                     <br /><input type="password" tabindex="102" name="password" style="font-size: 18px; padding: 5px; border: 1px solid #ccc; -moz-border-radius: 5px;-khtml-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;" />'
              +'                     <a href="#" onClick="$(\'#login_dialog_login\').fadeOut(300);$(\'#login_dialog_lostpass\').wait(300).fadeIn(300);return false;" style="font-weight: bold;">Glömt lösenordet?</a>'
              +'                     <div class="clear"></div>'
              +'               </form>'
              +'          </div>'
              +'     </div>'
              +'     <div id="login_dialog_lostpass" style="display: none;">'
              +'          <a href="#" onClick="$(\'#login_dialog_lostpass\').fadeOut(300);$(\'#login_dialog_login\').wait(300).fadeIn(300);return false;" style="font-weight: bold;float: right;margin-top:5px;">Jag vill logga in!</a>'
              +'          <div class="title">Glömt lösenordet?</div>'
              +'          <div style="padding: 10px;">'
              +'               Fyll i den epostadress som står angiven i din profil så kommer vi att skicka ett nytt lösenord till dig. Du kan ändra lösenordet senare.'
              +'               <form action="'+root+'members/login/lostpass.asp" method="post" id="form_dialog_lostpass" onSubmit="return postLostpass(this.id)" style="text-align:center;">'
              +'                     <br /><input type="text" tabindex="101" name="username" disabled="disabled" value="Ur funktion" style="font-size: 18px; padding: 5px; border: 1px solid #ccc; -moz-border-radius: 5px;-khtml-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;" />'
              +'                     <input type="submit" class="button small" tabindex="102" value="Skicka nytt lösenord" />'
              +'               </form>'
              +'          </div>'
              +'     </div>'
              +'</div>'
              +'<div style="border-top: 1px solid #ccc; background: #eee; font-weight: bold; padding:10px;">'
              +'     Inget konto? <a href="'+root+'members/register/">Registrera dig</a>!'
              +'</div>'
  )
}


function openLogOut() {
  cDialog.html(''
              +'<div style="padding: 10px;"> '
              +'     <div class="title">Är du säker på att du vill logga ut?</div>'
              +'     <center style="margin:10px 35px 5px;">'
              +'             <a href="'+root+'members/login/logout.asp" class="button">Jajjamän!</a> &nbsp;&nbsp;'
              +'             <a href="#" onClick="$(\'#dialog_close\').click();return false;" class="button">Naeh...</a>'
              +'     </center>'
              +'</div>'
  )
}



function openYouTube(yt_id) {
  intPlayerWidth = Math.round(intPlayerHeight*1.7777)
  intYTPlayerHeigth = intPlayerHeight+25
  cVideoDialog.html('<object width="'+intPlayerWidth+'" height="'+intYTPlayerHeigth+'" style="margin-bottom:-4px;"><param name="movie" value="http://www.youtube.com/v/'+yt_id+'&hl=sv&fs=1"></param><param name="wmode" value="opaque"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+yt_id+'&hl=sv&fs=1" type="application/x-shockwave-flash" wmode="opaque" width="'+intPlayerWidth+'" height="'+intYTPlayerHeigth+'" allowscriptaccess="always" allowfullscreen="true"></embed></object>')
}
function openNicoVideo(video_id) {
  cVideoDialog.html('<iframe src="'+root+'_js/nicovideo_iframe.asp?id='+video_id+'" width="495" height="395" style="border:0;"></iframe>')
}

function openVimeo(video_id) {
  intPlayerWidth = Math.round(intPlayerHeight*1.7777)
  cVideoDialog.html('<object width="'+intPlayerWidth+'" height="'+intPlayerHeight+'" style="margin-bottom:-4px;"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+video_id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><param name="wmode" value="opaque"></param><embed wmode="opaque" src="http://vimeo.com/moogaloop.swf?clip_id='+video_id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+intPlayerWidth+'" height="'+intPlayerHeight+'"></embed></object>');
}

function openVideoPlayer(video_id) {
  cVideoDialog.html('<div id="video_title" style="z-index: 10;display: none;position: absolute; top: 2px; left: 20px; font-size: 140%; color: #FFF;"><i>Laddar titel...</i></div>'
  + '<div id="video_title_shadow" style="z-index: 5; display: none; position: absolute; top: 0; left: 0; width: 100%; height: 30px; background: #000;opacity:.6;filter:alpha(opacity=60); "></div>'
  + '<div id="fp_player" style="width:'+Math.round(intPlayerHeight*1.7777)+'px;height:'+intPlayerHeight+'px;">'
  + '     <div style="text-align:center;color:#fff; padding-top:100px;">'
  + '          <span style="font-size:40px;font-weight:bold;letter-spacing:-1px;">Laddar videospelare!</span>'
  + '          <br />Det bör gå ganska fort, tar det dock ett sekel eller två så är det nog någonting som inte fungerar...'
  + '     </div>'
  + '</div>')

  $.getJSON(root + "_ajax/VideoData.asp?id="+video_id,function(data){
        $("#video_title").html(data.title);
        
        //intPlayerHeight = 480;   - Nu definerad detta uppe i toppen
        switch(data.aspect_ratio) {
            case "4:3" : intPlayerWidth = Math.round(intPlayerHeight*1.3333)
          break;
            default : intPlayerWidth = Math.round(intPlayerHeight*1.7777)
        }
        $("#fp_player").height(intPlayerHeight);
        $("#fp_player").width(intPlayerWidth);


        $("#fp_player").html('');
        fpPlayerConfig.clip.url = "http://static.genshiken.se/videos/"+video_id;
        fpPlayerConfig.plugins.content.width = intPlayerWidth-100;
        fpPlayerConfig.plugins.controls.width = intPlayerWidth-110;
        flowplayer("fp_player", fpMetaConfig, fpPlayerConfig );
  });

  $(".d_shadow").hover(
    function () {
      $("#video_title").fadeIn();
      $("#video_title_shadow").fadeIn();
    },
    function () {
      $("#video_title").fadeOut();
      $("#video_title_shadow").fadeOut();
    }
  );
}

/***********************************************************************
 *** cDialog END
 ***********************************************************************/




function infotabs(id) {
      document.getElementById('tab1').className = ""
      document.getElementById('tab2').className = ""
      document.getElementById('tab3').className = ""
      document.getElementById('tab4').className = ""
	  document.getElementById('tab5').className = ""
      document.getElementById('tab' + id).className = "on"
      document.getElementById('tab1Content').style.display = "none"
      document.getElementById('tab2Content').style.display = "none"
      document.getElementById('tab3Content').style.display = "none"
      document.getElementById('tab4Content').style.display = "none"
	  document.getElementById('tab5Content').style.display = "none"
      document.getElementById('tab'+id+'Content').style.display = "block"
}


function changeHTML(from_id,to_id) {
  document.getElementById(to_id).innerHTML = document.getElementById(from_id).innerHTML
}


// RedirectConfirm. OK / Avbryt-ruta dyker upp.
function RedCon(msg, url) {
  if (confirm(msg)) {
    location.href=url;
  }
  return false;
}


function RandomInt() {
  return Math.floor(Math.random()*99999999999);
}

function ajax_notice(formID,inData) {
  strResponseCode = inData.substring(0,1)
  strResponse = inData.substring(2)
  strRandom = RandomInt();

  if(strResponseCode == "1") {
    $("#"+formID).append("<div id='" + strRandom + "' class='abox_positive'>" + strResponse + "</div>")
    $("#"+strRandom).slideDown().wait(3000).slideUp();

  } else if(strResponseCode == "0") {
    $("#"+formID).append("<div id='" + strRandom + "' class='abox_negative'>" + strResponse + "</div>")
    $("#"+strRandom).slideDown().wait(3000).slideUp();
  } else if(strResponseCode == "2") {
    $("#"+formID).append("<div id='" + strRandom + "' class='abox_neutral'>" + strResponse + "</div>")
    $("#"+strRandom).slideDown().wait(3000).slideUp();
  }
  return strResponseCode
}

function postLostpass(formID) {
  $.ajax({
     type: "POST",
     url: root+"members/login/lostpass_a.asp",
     data: "email=" + encodeURIComponent($("#"+ formID + " input[name='email']").val()),
     success: function(msg){
       ajax_notice(formID,msg);
     }
  });
  return false;
}

function postLogin(formID) {

  $.ajax({
     type: "POST",
     url: root+"members/login/login_a.asp",
     data: "username=" + encodeURIComponent($("#" + formID + " input[name='username']").val())
         + "&password=" + encodeURIComponent($("#" + formID + " input[name='password']").val()),
     success: function(msg){
       if (ajax_notice(formID,msg) == 1){
         location.reload(true);
       }
     }
  });
  return false;
}




/*
function viewSeason(intID) {
  document.getElementById('seasonTab' + intID).className = "seasonTabOn"
  document.getElementById('seasonContent').innerHTML = document.getElementById('season'+intID).innerHTML
} */



/*
function RedCon2(msg){
  return confirm(msg);
}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



*/