////////////////////////////////////     2010/12/10 new homepage:
////---->for the google chrome browser !!!!!
var isChrome = window.google && window.chrome;


//1.show dialog window: flash
function show_dialog_window(flash_path,video_title)
{
	var flash_object_html = $('<div style="width:500px; display:none;"><object width="435" height="358" type="application/x-shockwave-flash" data="http://www.ninhao.com/sites/all/modules/ninhao/course/ninhao_flash_player.swf"  style="display:block;margin:auto;visibility: visible;"><param name="movie" value="http://www.ninhao.com/sites/all/modules/ninhao/course/ninhao_flash_player.swf"><param name="wmode" value="transparent"><param name="allowFullScreen" value="true"><param name="flashvars" value="video='+ flash_path +'"></object></div>');
	flash_object_html.dialog({modal:true},{resizable:false},{draggable:false},{title:video_title});
	var modal = flash_object_html.dialog('option', 'modal');
	flash_object_html.dialog('option', 'modal', true);

	//resize the dialog window:
	$('div.ui-dialog:visible').css('width','475px');
	$('div.ui-dialog:visible').css('height','418px');
	var document_width = $(document).width();
	var left = document_width/2 - $('div.ui-dialog:visible').width()/2;

	var aaa = document.documentElement.scrollTop || window.pageYOffset;
	var bbb = document.body.scrollTop;
	if(!isChrome){
		$('div.ui-dialog:visible').css('left',left).css('top',(aaa+100)+'px');
	}else{
		$('div.ui-dialog:visible').css('left',left).css('top',(bbb+100)+'px');
	}
}

//2.remove the hidden dialog window:
function reloop()
{
	var dialog_hidden = $('div.ui-dialog:hidden').html();
	if(dialog_hidden){
		$('div.ui-dialog:hidden').last().remove();
	}
}

//3.show dialog window: div
function show_dialog_window_2(output,text_title)
{
	var flash_object_html = $(output);
	flash_object_html.dialog({modal:true},{resizable:false},{draggable:false},{title:text_title});
	var modal = flash_object_html.dialog('option', 'modal');
	flash_object_html.dialog('option', 'modal', true);

	//resize the dialog window:
	$('div.ui-dialog:visible').css('width','630px');
	$('div.ui-dialog:visible').css('height','480px');
	var document_width = $(document).width();
	var left = document_width/2 - $('div.ui-dialog:visible').width()/2;

	var aaa = document.documentElement.scrollTop || window.pageYOffset;
	var bbb = document.body.scrollTop;
	if(!isChrome){
		$('div.ui-dialog:visible').css('left',left).css('top',(aaa+100)+'px');
	}else{
		$('div.ui-dialog:visible').css('left',left).css('top',(bbb+100)+'px');
	}

	$("div.TextP").scrollTop(0);
}


Drupal.behaviors.ninhao_month=function(context) {
	//1. binding the event:
	$('#video_01').click(function(){
		var flash_path	= $('#show_window #video_1_show').attr('flash_path');
		var video_title	= $('#show_window #video_1_show').attr('video_title');
		show_dialog_window(flash_path,video_title);
	});
	$('#video_02').click(function(){
		var flash_path	= $('#show_window #video_1_show').attr('flash_path');
		var video_title	= $('#show_window #video_1_show').attr('video_title');
		show_dialog_window(flash_path,video_title);
	});
	$('#video_03').click(function(){
		var flash_path	= $('#show_window #video_1_show').attr('flash_path');
		var video_title	= $('#show_window #video_1_show').attr('video_title');
		show_dialog_window(flash_path,video_title);
	});
	$('#video_04').click(function(){
		var flash_path	= $('#show_window #video_2_show').attr('flash_path');
		var video_title	= $('#show_window #video_2_show').attr('video_title');
		show_dialog_window(flash_path,video_title);
	});
	$('#video_2').click(function(){
		var flash_path	= $('#show_window #video_2_show').attr('flash_path');
		var video_title	= $('#show_window #video_2_show').attr('video_title');
		show_dialog_window(flash_path,video_title);
	});
	$('#video_3').click(function(){
		var flash_path	= $('#show_window #video_3_show').attr('flash_path');
		var video_title	= $('#show_window #video_3_show').attr('video_title');
		show_dialog_window(flash_path,video_title);
	});
	$('#text_1').click(function(){
		var output = $('#show_window #text_1_show').html();
		var text_title	= $('#show_window #text_1_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});
	$('#text_1_1').click(function(){
		var output = $('#show_window #text_1_show').html();
		var text_title	= $('#show_window #text_1_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});
	$('#text_2').click(function(){
		var output = $('#show_window #text_2_show').html();
		var text_title	= $('#show_window #text_2_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});
	$('#text_2_1').click(function(){
		var output = $('#show_window #text_2_show').html();
		var text_title	= $('#show_window #text_2_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});
	$('#text_3').click(function(){
		var output = $('#show_window #text_3_show').html();
		var text_title	= $('#show_window #text_3_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});
	$('#text_4').click(function(){
		var output = $('#show_window #text_4_show').html();
		var text_title	= $('#show_window #text_4_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});
	$('#text_4_1').click(function(){
		var output = $('#show_window #text_4_show').html();
		var text_title	= $('#show_window #text_4_show').attr('text_title');
		show_dialog_window_2(output,text_title);
	});

	///2. make dialog window always in window's center :
	$(window).scroll(function(){
		var aaa = document.documentElement.scrollTop || window.pageYOffset;
		var bbb = document.body.scrollTop;
		if(!isChrome){
			$('div.ui-dialog:visible').css('top',(aaa+100)+'px');
		}else{
			$('div.ui-dialog:visible').css('top',(bbb+100)+'px');
		}
		
	});

	///3. clear the hidden dialog window:
	setInterval("reloop()",100);

	


	///4. study center page click:
	$('#detail_click').click(function(){
		var output = "<div id=\"refund_policy_content\"><span id=\"line_1\">Ninhao provides refunds*, no questions asked, to those who are not satisfied with their purchases.</span><span id=\"line_2\">* The refunds differ according to the different product types:</span><span id=\"line_3\">1.<span id=\"video_course_title\">Video Courses:</span> Ninhao's online video course subscriptions can be fully refunded within 30 days of purchase. </span><span id=\"line_4\">2.Online Tools: Ninhao's online tools can be fully refunded within 30 days of purchase.</span><span id=\"line_5\">3.Live Tutor Courses: Ninhao's Live Tutor courses can be refunded only before 3 classes have been completed. On cancellation, you will be charged only the classes you have completed.</span><span id=\"line_6\">4.Books: Ninhao's Chinese learning books can be refunded within 30 days of arrival. Delivery fees are non-refundable.</span><span id=\"line_7\">5.To request a refund on any of these products, please contact <a href=\"mailto:care@ninhao.com\">care@ninhao.com</a> within the time limit/class limit specified.</span></div>";
		show_dialog_window_2(output,'Refund Policy');
	});
	$('#defund_content').click(function(){
		var output = "<div id=\"refund_policy_content\"><span id=\"line_1\">Ninhao provides refunds*, no questions asked, to those who are not satisfied with their purchases.</span><span id=\"line_2\">* The refunds differ according to the different product types:</span><span id=\"line_3\">1.<span id=\"video_course_title\">Video Courses:</span> Ninhao's online video course subscriptions can be fully refunded within 30 days of purchase. </span><span id=\"line_4\">2.Online Tools: Ninhao's online tools can be fully refunded within 30 days of purchase.</span><span id=\"line_5\">3.Live Tutor Courses: Ninhao's Live Tutor courses can be refunded only before 3 classes have been completed. On cancellation, you will be charged only the classes you have completed.</span><span id=\"line_6\">4.Books: Ninhao's Chinese learning books can be refunded within 30 days of arrival. Delivery fees are non-refundable.</span><span id=\"line_7\">5.To request a refund on any of these products, please contact <a href=\"mailto:care@ninhao.com\">care@ninhao.com</a> within the time limit/class limit specified.</span></div>";
		show_dialog_window_2(output,'Refund Policy');
	});
	$('#check_click').click(function(){
		var output = '<div class="Discount_wrap"><h1>Discount Rates: <span>(Does not include Live Tutors)</span></h1><table width="580" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="382" class="Discount_title"><p>Amount&nbsp; required to spend (in USD)</p></td><td width="197" class="Discount_title"><p>Discount</p></td></tr><tr><td>$45-$80</td><td>9%</td></tr><tr><td>$80-$100</td><td>12%</td></tr><tr><td>$100-$150</td><td>15%</td></tr><tr><td>$150 and over</td><td>20%</td></tr></tbody></table><h1>Terms &amp; Conditions:</h1><ul><li>To be eligible for a discount, amount must be spent at one time.</li><li>Discounts are not available on Live Tutor services <span>(i.e. Live Tutor services purchased individually that are over $45 will not receive a discount. In addition, if another Ninhao product is purchased with Live Tutors, and the combined total is over $45, no discount will be awarded.)</span></li></ul></div>';
		show_dialog_window_2(output,'Discount Rates');
	});
}






