﻿// ONE JAPAN //
//
//
var vdo = true;
var newbutton = "submit_box_";
$(document).ready(function(){
	//
	// Video Area Setup
	$("#video_area").mouseover(function(){$(this).toggleClass("video_area_off")});
	$("#video_area").mouseout(function(){$(this).toggleClass("video_area_off")});
	$("#video_area").click(function(){
		if(vdo){
			addVideo()
		}
	});
	//
	// Join Form
	addForm("登録はこちらから","x|x|x|x");
	//
	// Act Now Button
	$("#act_now").addClass("act_now_on");
	$("#act_now").mouseover(function(){$(this).toggleClass("act_now_off")});
	$("#act_now").mouseout(function(){$(this).toggleClass("act_now_off")});
	$("#act_now").click(function(){window.location=Path + "act"});
	//
	//
	var GetCurrentLink = "";
	$(".leader_row").mouseover(function(){
		$(this).css("cursor","pointer");	
		GetCurrentLink = $(this).children('.leader_text').children('a').attr('href');
		$(this).children('.leader_text').children('h4').css("color", "#0099ff");
		$(this).children('.leader_text').children('a').css("color", "#0099ff");
	});
	$(".leader_row").mouseout(function(){
		$(this).css("cursor","pointer");	
		GetCurrentLink = $(this).children('.leader_text').children('a').attr('href');
		$(this).children('.leader_text').children('h4').css("color", "#000");
		$(this).children('.leader_text').children('a').css("color", "#000");
	});
	$(".leader_row").click(function(){
		window.location = GetCurrentLink;
	});
	//
});
//
//
//
function addForm(msg,pass){
	Pass = pass.split("|");
	var Form = "";
	
	FormHead1 = '<div><img title="Join The Fight" src="' + Path + 'images/form/join_one.gif" />';
	FormHead2 = '<div><img title="Join The Fight" src="' + Path + 'images/form/join_one_d.png" />';
//NB	Form += '<form action="/jp/sidebar_signup.pl" method="post" name="joinform" id="sidebarform">';
	  Form +='<style> li {margin:0;}</style>';
	 Form +='<script type="text/javascript">actionkit.forms.initPage()</script>';
	 Form +=   '<form id="signup-form" class="signup-form ak-form" name="joinone_jp" method="POST" action="http://one.actionkit.com/act/" accept-charset="utf-8">';
	 Form +='  <input type="hidden" name="required" value="name" />   ';
//NB Form += '<form action="' + Path + 'join" method="post" name="joinform" id="sidebarform">';
	Form += '<div id="msg_box">' + msg + '</div>';
	Form +='  <p style="display: block;"  id="ak-errors" class="error signup-errors"></p><br style="clear:both"/>';
	Form += '<input type="hidden" name="country" value="Japan">';
	Form += '<input type="hidden" name="source" value="Japan Site">';
	if(Pass[0]==""){
		Form += '<div id="name_box" style="color:#ff0000;">';
	}else{
		Form += '<div id="name_box">';
	}
	if(Pass[0]=="x"){Pass[0]=""}
	Form += 'お名前</div><input class="join_in" type="text" name="name" value="' + Pass[0] + '" />'
	if(Pass[1]==""){
		Form += '<div id="email_box" style="color:#ff0000;">';
	}else{
		Form += '<div id="email_box">';
	}
	if(Pass[1]=="x"){Pass[1]=""}
	Form += 'Eメール</div><input class="join_in" type="text" name="email" value="' + Pass[1] + '" />';
	if(Pass[2]==""){
		Form += '<div id="address_box" style="color:#ff0000;">';
	}else{
		Form += '<div id="address_box">';
	}
	//if(Pass[2]=="x"){Pass[2]=""}
		//Form += 'ご住所</div><textarea spellcheck="false" type="text" name="address">' + Pass[2] + '</textarea>';
	//if(Pass[3]==""){
		//Form += '<div id="national_box" style="color:#ff0000;">';
	//}else{
		//Form += '<div id="national_box">';
	//}
	//if(Pass[3]=="x"){Pass[3]=""}
	//Form += '国籍</div><input class="join_in" type="text" name="nationality" value="' + Pass[3] + '" />';
	//Form += '<div id="option1_box"><input class="" type="checkbox" name="option_1"/>ONEに参加する</div>';
	Form += '<div id="option2_box"><input class="" type="checkbox" name="english"/>ONEからのお知らせメール（英語）配信を希望する</div><br>';
	//NB Form += '<div class="submit_box" onmouseover="$(this).toggleClass(newbutton)" onmouseout="$(this).toggleClass(newbutton)" onclick="validate(document.joinform)"></div>';
	Form +=' <input type="image" class="submit rollover" src="/jp/images/join_button_off.gif" width="109" height="25" alt="Join One Now" />        <input type="hidden" name="lists" value="1" />   <input type="hidden" name="page" value="joinone_jp">';
	
	Form += '</form>';
	Form += '  <script type="text/javascript">actionkit.forms.contextRoot = "http://one.actionkit.com/context/"; actionkit.forms.initForm("joinone_jp");</script> ';
	Form += '</div>';
	$("#join_form").html(FormHead1+Form);
	$("#join_form_d").html(FormHead2+Form);
}
//
//
//
function addVideo(){
	vdo = false;
	var flashvars = {};
	var params = {wmode:"transparent"};
	var attributes = {id:"video"};
	//if($.browser.webkit){
		//$("#video_area").html("<video autoplay='autoplay' src='images/video/onevoice.m4v' controls='controls' width='590' height='326'><div id='video_placeholder'></div></video>")
	//}else if($.browser.mozilla){
		//$("#video_area").html("<video autoplay='autoplay' src='images/video/onevoice.ogv' controls='controls' width='590' height='326'><div id='video_placeholder'></div></video>")
	//}else{
		swfobject.embedSWF(Path + "images/video/video.swf", "video_placeholder", "590", "326", "10.0.0", false, flashvars, params, attributes);
	//}
	
}
//
//
//
function addPrivacy(){
	var WinPolicy = "";
	WinPolicy += '<div style="position:absolute;top:85px;margin-left:100px;background-color:#fff;padding:5px;border:#000 solid thin;"><div onclick="$(this).parent().remove()" style="background:url(' + Path + 'images/nav/close.gif) no-repeat right;cursor:pointer;width:680px;height:30px;padding:15px;"><h1>プライバシーに関する考え方</h1></div><iframe src="' + Path + 'join/privacy.html" width="704" height="620"></iframe></div>';
	$("#main").append(WinPolicy);
	$('html, body').animate({scrollTop:0}, 'fast');
}
//
//
//
function addCampaigns(){
	var WinCampaign = "";
	WinCampaign += '<div style="position:absolute;top:85px;margin-left:100px;background-color:#fff;padding:5px;border:#000 solid thin;"><div onclick="$(this).parent().remove()" style="background:url(' + Path + 'images/nav/close.gif) no-repeat right;cursor:pointer;width:680px;height:30px;padding:15px;"><h1>Past Campaigns</h1></div><iframe src="' + Path + 'about/campaigns.html" width="688" height="620" style="padding-left:15px;"></iframe></div>';
	$("#main").append(WinCampaign);
	$('html, body').animate({scrollTop:0}, 'fast');
}
//
// 
//
function validate(form){

	var Pass="";
	
	if(form.name.value==''){
		Pass+="|";
	}else{
		Pass+=form.name.value+"|";
	}
	if(form.email.value==''){
		Pass+="|";
	}else{
		if(form.email.value.indexOf("@")>-1&&form.email.value.indexOf(".")>-1 ){
			Pass+=form.email.value+"|";
		}else{
			Pass+="|";
		}
	}
	//if(form.address.value==''){
		//Pass+="|";
	//}else{
		//Pass+=form.address.value+"|";
	//}
	//if(form.nationality.value==''){
	//}else{
		//Pass+=form.nationality.value+"|";
	//	}
	
	if(Pass.indexOf("||")>-1){
		addForm("<div style='color:#ff0000;margin-top:-6px;margin-bottom:-7px;'>入力内容に誤りがあります。<br/>ご確認の上、もう一度入力してください。</div>",Pass);
	}else{
		form.submit();
	}
	
}

