/*COIN API-Copyright (c)2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G
このプログラムの無断転載と無断利用、複製、流用、改ざん、改変、転載、リバースエンジニアリング、並びにそれに伴う本サイトプログラムの無断での使用を禁じます。
 */

(function(){
var coIn=function(){$o=this;return this instanceof coIn ? this.create() : new coIn();};
window.coIn=coIn;
coIn.prototype={
	create:function(){
		$j.inherit(coIn,coinDI);
		var self=this;
		this.initDI("template/signin.tpl");
		var d=this.imgDir;
		$o.wizNew={};
		$o.noChange=true;

		jQuery(function(){
			/*@cc_on
			eval((function(props) {var code = [];for (var i = 0,l = props.length;i<l;i++){var p = props[i];window['_'+p]=window[p];code.push(p+'=_'+p);}return 'var '+code.join(',');})('document self top parent alert setInterval clearInterval setTimeout clearTimeout'.split(' ')));
			@*/
			$j("#top_btnWhats").click(function(){
				$j.IE6form(false);
				$j("#whats").fadeIn(600);
			});

			$j("#btnWhatsClose").click(function(){
				$j("#whats").fadeOut(600);
				$j.IE6form(true);
			}).oHover();
			$j(".btnFlare").oHover();
			$j("#top_btnSignUp,#top_btnNewAccount").click(function(){
				$j.IE6form(false);
				$o.wizCreateAccount(function(){$j.IE6form(false);});
			});
			$j("#top_btnSignIn").click(function(){
				$j(this).parent("form").unbind('submit').submit();
			});
			$j("#top_btnJump").click(function(){$o.jump();});
			$j("#top_btnSearch").click(function(){location.href=$o.baseDir + 'search/guest';}).find("a").attr("href","javascript:void(0)");
			$j("#top_btnTour").click(function(){window.open('/ipex/tour.html', 'newwin', 'width=524,height=550,scrollbars = yes');}).find("a").attr("href","javascript:void(0)");

			$j().oDecoButton();
			var err = document.signinActionForm.error.value;
			if (err!="") {
				var mess = (err=="signin incorrect")?$o._.err_signinIncollect:$o._.err_needSignin;
				$j().oDialog("error",mess,$o._.ok);
			}

			if ($o.IE6) {
				jQuery(".btnFlat").hover(function(){
					jQuery(this).css("color", "red");
				}, function(){
					jQuery(this).css("color", "black");
				});
				jQuery(".btnText").hover(function(){
					jQuery(this).css("color", "red");
				}, function(){
					jQuery(this).css("color", "gray");
				});
			}
		});
	},
	partsViewer:function(no){
		if (typeof($o.nowInfos.parts)!="object") return;
		_o.player.div.hide();
		var jQW=jQuery("#oWizard"),p=$o.nowInfos.parts[no][0],
				m=p.match(/width="([0-9]+)".*height="([0-9]+)"/),w=Number(m[1]),h=Number(m[2]);
		w=(isNaN(w))?478:w+50;
		h=(isNaN(h))?400:h+53;
		jQW.html($o.jTmp._templates.partsViewer.get({},[],document.body));
		jQuery(".oMessage",jQW).height(h-50);
		jQW.oDecoButton().oWizard(null,1,{mode:"",step:1,modal:["on"],width:w,height:[h]},function(){
			jQuery("#oParts_parts").html("" + p).show();
		});
		jQuery("#oParts_btnClose").click(function(){jQW.oWizard("close");});
	},

	jump:function(){
		var cd = document.frmJump.sid.value;
		if ($o.isNotFound(1,cd)) return;
		CoinApi.checkCD(cd,function(ct){
			if (!$o.isNotFound(ct,cd)) location.href=$o.baseDir+$o.playerPath+cd;
		});
	},
	checkAccount:function(name,email){
		ln = name.length;
		CoinApi.checkAccount(name,email,function(ck){
			var ok="";
			if ((ck & 1)>0){
				$j("#userName_tip").show().find("div.tipInner").text($o._.vld_dupAccount);
			}else if (ln>5){
				ok =$o._.accountOk;
			}
			if ((ck & 2)>0){
				$j("#email_tip").show().find("div.tipInner").text($o._.vld_dupAccount);
			}
			$j("#wzAc_checkOk").text(ok).ifShow(ok!="");
		});
	},
	wizCreateAccount:function(){
		var fntMode={b:false,i:false};
		$o.wizNew={mode:"",step:1,modal:["on"],width:470,height:[274]};
		jQuery.extend($o.wizCreateAccount,{
			close:function(md,fn){
				close(md,fn);
			}
		});
		var jQW=jQuery("#oWizard");
		jQW.html($o.jTmp._templates.createAccount_wiz.get({},[],document.body)).oDecoButton().hide();
		$o.jA = $j("#frmNewAccount");
		jQW.find("#wzAc_btnPostCancel").click(function(){close("esc");}).end()
		.find("#wzAc_btnPostAccount").click(function(){
			if($j("div.validationTip:visible").length>0) {
				$j().oDialog('error',$o._.err_invalidForm,$o._.ok);
			}else{
				$j().oDialog('wait',$o._.diag_wait);
				$o.jA.unbind('submit').submit();
			};
		}).end()
		.oWizard(null,1,$o.wizNew,function(){
			$o.jA.validation();
			$j("#wzAc_btnCheck",jQW).click(function(){
				var fm=document.signinActionForm2;
				$o.checkAccount(fm.userName.value,fm.email.value);
			});
		});
		function close(md,refresh){
			$j("div.validationTip,#dlgmat,#dlg").remove();
			jQW.find(".oDisable").show();
			jQW.fadeOut($o.noIE(200),function(){
				$j(this).empty();
			});
		}
	}
};})();


$j(document).ready(function(){
		if ((typeof($o)=="undefined")||(!_o.mode)) new coIn();

});