/*
jQuery Script for socialnurse.jp
Subject: socialnurse.common
Author : TANAKA Hirohito by CVP(http://cvp-web.net/)
Date   : 2009.12.07
--------------------------------------*/


(function($) {


jQuery().ready(function() {
  return init();
}); //ready


var init = function() {
  this.obj1 = scrollBody();
  this.obj2 = openSendMagazine("https://s.blayn.jp/bm/p/f/tf.php?id=seikatsu_kagaku","#sendMagazine");
  this.obj3 = openSendMobile(".openSendMobile");
  return this;
}


var scrollBody = function() {
  //var h = Math.floor($("#container").height() / 1.5);
  var h = 1250;
  //$(".chk").text(h);
  jQuery("a[href*=#]").click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var $target = jQuery(this.hash);
      $target = $target.length && $target || jQuery("[name=" + this.hash.slice(1) +"]");
      if ($target.length) {
        var targetOffset = $target.offset().top;
        jQuery('html,body').animate({ scrollTop: targetOffset }, h);
        return false;
      }
    }
  });
}


var openSendMagazine = function(url,value) {
  $(value).submit(function() {
		var newWin = window.open(
			"about:blank", //ダミーの移動先
	    'SendMagazine', //ターゲット名（formタグのtargetと同じ値にする）
	    'width=470,height=590,top=0,left=0,status=0,scrollbars=yes,menubar=0,location=0,toolbar=0,resizable=no'
		);
		var f = document.sendMagazine; //フォームオブジェクト取得
		f.action = url; //移動先
		f.submit();
		newWin.focus();
  });
}


var openSendMobile = function(value) {
  hoverCursor(value);
  $(value).click(function() {
    window.open(
      'https://secure424b.sakura.ne.jp/socialnurse.jp/send-mobile/',
      'SendMobile',
      'width=450,height=600,top=0,left=0,status=0,scrollbars=yes,menubar=0,location=0,toolbar=0,resizable=no'
    );
    return false;
  });
}


var windowSize = function(){
  this.w  = window.innerWidth || self.innerWidth || (document.documentElement&&document.documentElement.clientWidth) || document.body.clientWidth;
  this.h = window.innerHeight || self.innerHeight || (document.documentElement&&document.documentElement.clientHeight) || document.body.clientHeight;
  return this;
}


var hoverCursor = function(value){
  $(value).hover(function(){
    $(this).css("cursor","pointer");
  },function(){
    $(this).css("cursor","default");
  });
}


})(jQuery);
