﻿// Common scripts
$(document).ready(function(){
	var lang = getLang()[0];
	if ( $("#output li.flip_top").length > 0 )
	{
		$("#output li.flip_top").remove();
		$("#tabs li:last:visible").remove();
	}
	if ( getPage()[0]=="recharge" )
	{
		$("span.notes_category").eq(1).find("li").eq(2).hide()
	}
	if ( getPage()[0]=="gift" )
	{
		var _host = document.location.host.replace(/\./g,"\\.");
		var patt = /brastel/;
		var brastelDotCom = patt.test(_host);
		var acr = getLang()[1];
		var _prot = "";
		var _domain = "";
		if ( brastelDotCom )
		{
			_prot = "https://";
			_domain = "www2.brastel.com";
		}
		var myAccUrl = _prot+_domain+"/web/WIMS/Manager.aspx?style=1&service=1&xslFile=cyber_login.xsl&redXsl=spc_services_international_gift_service.xsl&redAct=ReturnGiftVoucherInfo&acr="+acr;
		$("#bodyContent_main .simplelist li a").attr({"href":myAccUrl,"target":"_myaccount"});
		if ( lang=="jpn") $("#bodyContent_main li a").attr({"href":myAccUrl,"target":"_myaccount"});
	}
	// Delta campaign results
	/*
	if ( (lang == "esp" || lang =="por" ) && getPage()[0] == "home" )
	{
		$('<div class="campaignResults" id="delta_campaign" />').appendTo("body");
		$('<div class="open_close" />').appendTo("#delta_campaign");
		$('<div class="tab_arrow" />').appendTo("#delta_campaign .open_close");
		$('<div class="tab" />').appendTo("#delta_campaign");
		$('<img alt="" />').attr("src","/GenericFiles/4.0/img/home/delta/tab_"+lang+".png").appendTo("#delta_campaign .tab");
		
		$('<div class="winners" />').appendTo("#delta_campaign");
		$('<img alt="" class="list" />').attr("src","/GenericFiles/4.0/img/home/delta/winners_"+lang+".png").appendTo("#delta_campaign .winners");
		$('<img alt="" class="details" />').attr("src","/GenericFiles/4.0/img/home/delta/details_"+lang+".png").appendTo("#delta_campaign .winners");
		
		$(document).oneTime(3000,function(){
			if ( $.cookie("closeDeltaSlide") == "yes" )
			{
				$("#delta_campaign").animate({bottom:-209},1000,function(){
					$("#delta_campaign .open_close .tab_arrow").css("background-position","0 0");
				});
			}
			else
			{
				$("#delta_campaign").animate({bottom:0},1000,function(){
					$("#delta_campaign .open_close .tab_arrow").css("background-position","0 bottom");
				});
			}
		});
	}
	$("#delta_campaign .open_close").live("click",function(){
		if ( $("#delta_campaign").css("bottom") == "0px" )
		{
			hideDeltaSlide();
		}
		else
		{
			showDeltaSlide();
		}
	});
	$("#delta_campaign .tab").live("click",function(){
		openDeltaPage();
	});
	$("#delta_campaign .winners").live("click",function(){
		openDeltaPage();
	});
	*/
						   
	if ( getPage()[0] == "about" )
	{
		if (getLang()[0] == "eng" )
		{
			$("table.factsfigures td:odd").each(function(){
				var _html = $(this).html();
				_html = _html.replace("03‐5637‐5900","050-6860-1900");
				$(this).html(_html)
			});
		}
		else if (getLang()[0] == "jpn" )
		{
			$("#bodyContent_main table td:odd").each(function(){
				var _html = $(this).html();
				_html = _html.replace("03‐5637‐5490","050-6860-1900");
				$(this).html(_html)
			});
		}
	}
	
	$("#ifrFooterPrivacy").css("display","none");
	if ( window.parent.location == window.location ) window.name = "brMain"; // Name window
	var lang = getLang()[0];
	var acr = getLang()[1];
	
	if ( !$("body").hasClass(lang) ) $("body").addClass(lang);
	
	var showImtSurvey = false;
	
	if ( $("#ifrHeader").length > 0 && showImtSurvey )
	{
		var parentDiv = $("div.corp_banner:first").parent("div");
		$("div.corp_banner:visible").each(function(i){
			if ( i > 1 )
			{
				$(this).hide();
			}
		});
		var src = "/web/WIMS/Manager.aspx?xslFile=survey_imt.xsl&Service=1&Style=1&acr="+acr;
		$('<iframe id="imt_survey" height="130" width="230" scrolling="no" frameborder="0" />')
			.attr("src",src)
			.css("margin-bottom","10px")
			.prependTo(parentDiv);
	}
	
	// Set css lang
	secure = document.location.href.indexOf("https");
	domain = "";
	if ( secure != -1 ) domain = "https://www2.brastel.com";
	var cssLang = getLang()[0];
	$("#langCss").attr("href", domain + "/GenericFiles/4.0/css/styles_"+ cssLang + ".css")
	$("#fontsCss").attr("href", domain + "/GenericFiles/4.0/css/fonts/fonts_"+ cssLang + ".css")
	
	// ITFS page iframe size
	if ( window.parent.location == window.location )
	{
		var page = getPage()[0];
		if ( page == "FromOthersCountries" )
		{
			var $ifr = $("div#bodyContent_main iframe");
			
			$ifr.css({
				"overflow":"hidden",
				"height":3000
			})
		}
	}
	$("li.donation a").hover(
		function(){
			var img = $(this).find("img");
			var imgSrc = img.attr("src");
			var hovSrc = "";
			if ( imgSrc.indexOf("hover") != -1 ) hovSrc = imgSrc;
			else hovSrc = imgSrc.replace(".png","_hover.png");
			img.attr("src",hovSrc)
		},
		function(){
			var img = $(this).find("img");
			var imgSrc = img.attr("src");
			var hovSrc = imgSrc.replace("_hover","")
			img.attr("src",hovSrc)
		}
	);
	
	var links = document.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++) { 
   links[i].onfocus=function(){this.blur()}
	}
	
	// for Home page featureList
	if ( $("#tabs li a").length > 0 )
	{
		$('#tabs li a').featureList({
			output				:	'#output li',
			start_item			:	0,
			transition_interval	: 	18000,
			first_interval		:	18000
		});
		$("#output .apps a.details").attr("href","https://www2.brastel.com/web/WIMS/Manager.aspx?xslFile=apps.xsl&Style=personal&Service=1&acr="+getLang()[1])
	}
	
	$('.hdg2Link').click(function(){
		var $h2Contents = $(this).next("div.hdg2ContentsHidden");
		var $target = $(this);
		var $target2 = $("h2:first");
		if ($h2Contents.is(":visible")){
			$h2Contents.animate({opacity:0},500).slideUp(500,function(){
				if ( $target2.is(":above-the-top") ){
					$.scrollTo($target2,700);}
			}).animate({opacity:1},500);}
		else
			{
				if ($("div.hdg2ContentsHidden:visible").length)
					{	
						var $visibleDiv = $("div.hdg2ContentsHidden:visible");
						var $indexOfClicked = $("h2.hdg2Link").index(this);
						var $prevH2 = $("div.hdg2ContentsHidden:visible").prevAll(".hdg2Link:first");
						var $indexOfVisible = $("h2.hdg2Link").index($prevH2) ;
						var $visibleDivHeight = $visibleDiv.height();
						var $h2ContentsHeight = $h2Contents.height();
						
						if ( $indexOfClicked > $indexOfVisible )
							{
								var $nextTitles = $visibleDiv.nextAll("h2.hdg2Link");
								
								if ($visibleDivHeight>$h2ContentsHeight)
									{
										var $difference = $visibleDivHeight - $h2ContentsHeight;
										$("div#adjuster").height($difference).animate({opacity:1},500).show(1);
									}
								
								$nextTitles.animate({opacity:0},500);
								$(this).animate({opacity:0},500).animate({opacity:1},500);
								$visibleDiv.animate({opacity:0},500).hide(1).animate({opacity:1},500);
								$h2Contents.animate({opacity:0},500).show(1);
								$("h2.hdg2Link:first").fadeTo(1000,1,function(){
									$.scrollTo($target,500);
									$("h2.hdg2Link:first").fadeTo(500,1,function(){
										$h2Contents.animate({opacity:1},500);
										$("h2.hdg2Link").animate({opacity:1},500);
										$("div#adjuster").hide(1000);
									});
								});
							}
						else
							{
								$h2Contents.fadeIn(500);
								$visibleDiv.hide();
							}							
					}
				else
					{
						$h2Contents.fadeIn(500);
					}
			}
	});
	
	/*
	$('.spcTitleLogoHolder').gradient({
			from:      'FBF8C8',
			to:        'F8EE4F',
			direction: 'vertical'
	});	
	$('.generalNotesTitle p').gradient({
			from:      'FFFFFF',
			to:        'E6F3FF',
			direction: 'horizontal'
	});
	*/
	
	setIfrSources();
	
	// close special holidays calendar
	$("div.specialHolidaysP img.close").live("click",function() {
		$("div.specialHolidaysP").slideUp();
	});
	// close customer service language menu
	$("div#csvLangMenu img.close").live("click",function() {
		$("div#csvLangMenu").slideUp();
	});
	
	// change customer service language
	$("div#csvLangMenu ul li a").live("click",function() {
		$("div#csvLangMenu").slideUp();
		var freeDialSpan = "div#" + $(this).attr("class") + " span.freedial";
		var freeDialNum = $(freeDialSpan).html();
		var notfreeDialSpan = "div#" + $(this).attr("class") + " span.notfreedial";
		var notfreeDialNum = $(notfreeDialSpan).html();
		var faxSpan = "div#" + $(this).attr("class") + " span.fax";
		var faxNum = $(faxSpan).html();
		var emailSpan = "div#" + $(this).attr("class") + " span.email";
		var emailAddr = $(emailSpan).html().replace("punto",".");
		var nameSpan = "div#" + $(this).attr("class") + " span.name";
		var langName = $(nameSpan).html();

		$titleDiv = $("iframe#ifrFooter").contents().find("div.title");
		$freedialSpan = $("iframe#ifrFooter").contents().find("span#freedial");
		$notfreeSpan = $("iframe#ifrFooter").contents().find("span#notfreedial");
		$faxSpan = $("iframe#ifrFooter").contents().find("span#fax");
		$tables = $("iframe#ifrFooter").contents().find("div.csvInfoHolder");
		$langLink = $("iframe#ifrFooter").contents().find("div.langMenuLink");

		$titleDiv.animate({opacity:0},500);
		$tables.animate({opacity:0},500);
		$langLink.animate({opacity:0},500);
		
		
		$(this).oneTime(500, function () {
			$("iframe#ifrFooter").contents().find("span#freedial").html(freeDialNum);
			$("iframe#ifrFooter").contents().find("span#notfreedial").html(notfreeDialNum);
			$("iframe#ifrFooter").contents().find("span#fax").html(faxNum);
			$("iframe#ifrFooter").contents().find("span#email").html(emailAddr);
			$("iframe#ifrFooter").contents().find("span#name").html(langName);
			$("iframe#ifrFooter").contents().find("span#emailLink").attr({href:"mailto:" + emailAddr});
		});
		$(this).oneTime(500, function () {
			$titleDiv.animate({opacity:1},500);
			$tables.animate({opacity:1},500);
			$langLink.animate({opacity:1},500);
		});
	});
	
	// show brastel location menu
	
	var hashval = SWFAddress.getValue().replace(/\/*(.*)\/*/,"$1");
	var selectedLocation = $.cookie("brastel_selected_loc");
	if ( hashval == "location" && !selectedLocation ) {
		$("body").prepend('<div id="selCountrySpacer"></div><div id="selectCountry"><div class="_wrapper"><img src="/GenericFiles/4.0/img/country_sel/logo.png" alt="Brastel Telecom" class="logo" /></div></div>');
		$("div#selectCountry div._wrapper").append('<img class="text" src="/GenericFiles/4.0/img/country_sel/select_location.png" alt="Select your location" />');
		$("div#selectCountry div._wrapper").append('<div class="buttons"></div>');

		var buttons = '<div id="selCountryHelpBtn" class="btnHelp"></div>' +
		//'<div id="selectUSA" class="button"></div>' +
		'<div id="selectBrazil" class="button"></div>' +
		'<div id="selectJapan" class="button"></div>';
		$("div#selectCountry div._wrapper div.buttons").append(buttons);
		
		$("body").append('<div id="opaqueBg"></div>');
		$("div#opaqueBg").animate({opacity:0});
		var bodyHeight = $("body").outerHeight();
		var selCountryHeight = $("div#selectCountry").height();
		
		$(document).oneTime(6000,function(){
			$("div#selectCountry").slideDown();
			$("div#selCountrySpacer").slideDown();
			$("div#header_bg").slideUp();
			$("div#opaqueBg").oneTime(700,function(){
			$(this).show().css({"top":selCountryHeight+1,"height":bodyHeight-selCountryHeight}).animate({opacity:0.7},500);
			});
		});
		
		var helpHtml = 	'<div id="selCountryHelp">'+
							'<div class="_wrapper">'+
								'<img class="arrowUp" src="/GenericFiles/4.0/img/country_sel/arrow_up.png" alt="">'+
								'<img class="close" src="/GenericFiles/4.0/img/common/close.png" alt="" />'+
								'<div class="contents">'+
									'<p class="text">Select the country where your Brastel Card was issued.<br />'+
									'If you do not have a Brastel Card yet, select the country where you reside.</p>'+
									'<div class="langMen">'+
										'<div class="menu selected eng">English<span>Select the country where your Brastel Card was issued.<br />If you do not have a Brastel Card yet, select the country where you reside.</span></div>'+
										'<div class="menu por">Português<span>Selecione o país onde seu Cartão Brastel foi emitido.<br />Se você ainda não possui um Cartão Brastel, selecione o país onde você mora.</span></div>'+
										'<div class="menu jpn">日本語<span>現在お住まいの国またはブラステルカードの発行国をお選びください。</span></div>'+
										'<div class="menu ind">Indonesia<span>Pilih negara dimana Kartu Brastel anda diterbitkan.<br />Jika anda belum memiliki Kartu Brastel, pilih negara dimana anda bertempat tinggal.</span></div>'+
										'<div class="menu esp">Español<span>Seleccione el país donde su Brastel Card fue emitida. <br />i aún no tiene una Brastel Card, seleccione el país en donde reside.</span></div>'+
										/*'<div class="menu chi">中國語<span></span></div>'+*/
										'<div class="menu rus">Русский<span>Выберите страну, в которой Вы приобрели карточку Брастел. Если у Вас еще нет карточки Брастел, выберите страну проживания.</span></div>'+
										'<div class="menu tha">ไทย<span>เลือกประเทศที่คุณทำการออกบัตรบรัสเทล<br />หากคุณยังไม่มีบัตรบรัสเทล กรุณาเลือกประเทศที่คุณอาศัยอยู่</span></div>'+
										'<div class="menu kor">한국어<span>브라스텔 카드가 발행된 국가를 선택해 주십시오.<br />브라스텔 카드가 없는 고객은 거주하고 계신 국가를 선택해 주십시오.</span></div>'+
										'<div class="menu tag">Tagalog<span>Piliin ang bansa kung saan ang inyong Brastel Card ay na-issue.<br />Kung kayo ay wala pang Brastel Card, piliin lamang ang bansa kung saan kayo ay naninirahan.</span></div>'+
										/*'<div class="menu vie">Tiếng Việt<span></span></div>'+*/
										/*'<div class="menu fre">Français<span></span></div>'+*/
										/*'<div class="menu rom">Română<span></span></div>'+*/
										/*'<div class="menu tur">Türkçe<span></span></div>'+*/
									'</div>'+
								'</div><br style="clear:both" />'+
							'</div>'+
						'</div>';
		$("body").append(helpHtml);
		$("div#selCountryHelp").css({"top":selCountryHeight-8});
	}
	else if ( hashval == "location" && selectedLocation == "br" ) {
		$.cookie("brastel_selected_loc","br", {expires: 365, path: '/'});
		window.location.href = ("http://www.brastel.com.br/")
	}
	else if ( hashval == "location" && selectedLocation == "us" ) {
		$.cookie("brastel_selected_loc","us", {expires: 365, path: '/'});
		window.location.href = ("http://www.brastel.net/")
	}
	else {
		$.cookie("brastel_selected_loc","jp", {expires: 365, path: '/'});
	}
	
	$("div#selectJapan").click(function(){
		hideCountrySel();
		_gaq.push(['_trackEvent', 'Country selection', 'from slide-down menu', 'Japan']);
		$.cookie("brastel_selected_loc","jp", {expires: 365, path: '/'});
	});
	$("div#selectBrazil").click(function(){
		_gaq.push(['_trackEvent', 'Country selection', 'from slide-down menu', 'Brazil']);
		$.cookie("brastel_selected_loc","br", {expires: 365, path: '/'});
		window.location.href = ("http://www.brastel.com.br/")
	});
	$("div#selectUSA").click(function(){
			_gaq.push(['_trackEvent', 'Country selection', 'from slide-down menu', 'U\.S\.A\.']);
			$.cookie("brastel_selected_loc","us", {expires: 365, path: '/'});
			window.location.href = ("http://www.brastel.net/")
	});
	
	$("div#opaqueBg").click(function(){
		hideCountrySel();
		$.cookie("brastel_selected_loc","jp", {expires: 365, path: '/'});
	});
	
	$("div#selCountryHelpBtn").click(function(){
		$("div#selCountryHelp").fadeIn();
	});
	$("#selCountryHelp .menu").mouseover(function(){
		var txt = $(this).find("span").html();
		$("#selCountryHelp p.text").animate({opacity:0},150).oneTime(150,function(){
			$(this).html(txt).animate({opacity:1},1)
		});
		$("#selCountryHelp .menu.selected").toggleClass("selected");
		$(this).toggleClass("selected");
	});
	$("#selCountryHelp img.close").click(function(){
		$("div#selCountryHelp").hide();
	});
	
	//Set event gallery iframe src
	var eventGalleryIfrSrc = "http://" + domain + "/web/WIMS/Manager.aspx?xslFile=event_gallery.xsl&xmlPreview=event_gallery.xml&Style=1&Service=1&acr=" + acr;
	$("iframe#eventGalleryIfr").attr("src",eventGalleryIfrSrc)
	
	// Embed FLIP campaign flash
	var swfFile = "/GenericFiles/4.0/swf/flip_campaign/flip_" + lang + ".swf";
	var flipFlashParams = {
		wmode:"transparent"
	}
	swfobject.embedSWF(swfFile, "flipCampaignFlash", "739", "509", "9.0.0",false,false,flipFlashParams,false,false)


	$("img[src$='mobile1.jpg']").parent().css("position","relative").append('<img src="/GenericFiles/4.0/img/common/mobile/sold_out.png" alt="sold out" class="soldOut" /><img src="/GenericFiles/4.0/img/common/mobile/sold_out.png" alt="sold out" class="soldOut2" />');
	
	if ($("img[src$='FlipPhoneACT.jpg']").length > 0)
	{
		var actImgParent = $("img[src$='FlipPhoneACT.jpg']").parent()[0].nodeName.toLowerCase();
		if ( actImgParent = "a" )
		{
			$("img[src$='FlipPhoneACT.jpg']").parent().css({"position":"relative","display":"block"}).append('<img src="/GenericFiles/4.0/img/common/mobile/sold_out.png" alt="sold out" class="soldOutACT" />');
		}
		else
		{
			$("img[src$='FlipPhoneACT.jpg']").parent().css("position","relative").append('<img src="/GenericFiles/4.0/img/common/mobile/sold_out.png" alt="sold out" class="soldOutACT" />');
		}
		$("img.soldOutACT").css({
			"position":"absolute",
			"top":"45px",
			"left":"50px",
			"border":"0"
		});
	}
	if ($("img[src$='FlipPhone_.jpg']").length > 0)
	{
		var actImgParent = $("img[src$='FlipPhone_.jpg']").parent()[0].nodeName.toLowerCase();
		if ( actImgParent = "a" )
		{
			$("img[src$='FlipPhone_.jpg']").parent().css({"position":"relative","display":"block"}).append('<img src="/GenericFiles/4.0/img/common/mobile/sold_out.png" alt="sold out" class="soldOutFlipPhone" />');
		}
		else
		{
			$("img[src$='FlipPhoneACT.jpg']").parent().css("position","relative").append('<img src="/GenericFiles/4.0/img/common/mobile/sold_out.png" alt="sold out" class="soldOutFlipPhone" />');
		}
		$("img.soldOutFlipPhone").css({
			"position":"absolute",
			"top":"45px",
			"left":"50px",
			"border":"0"
		});
	}
	
	// Set FLIP, Webphone, Brastel Mobile rates iframe source
	if ($("iframe.ratesIfr").length > 0)
	{
		setRatesIfrSrc(acr);
	}
	if ( $("iframe.smsIfr").length > 0 )
	{
		$("iframe.smsIfr").attr("src","/web/WIMS/Manager.aspx?xslFile=sms.xsl&Service=1&Style=1&xmlPreview=sms.xml&acr="+acr);
	}
	if ( $("iframe.appsIfr").length > 0 )
	{
		$("iframe.appsIfr").attr("src","/web/WIMS/Manager.aspx?xslFile=mobile_devices.xsl&Service=1&Style=1&xmlPreview=mobile_devices_country_list.xml&acr="+acr);
	}
	
	if ( getPage()[0] == "spcrates" )
	{
		$("#bodyContent_main iframe").attr("height",1300)
	}
	
	var page = getPage()[0];
	if ( lang == "jpn" && page == "home" )
	{
		var dateFrom = new Date();
		var dateUntil = new Date();
		dateFrom.setFullYear(2010,10,29);
		dateUntil.setFullYear(2010,11,25);
		var today = new Date();
		
		if ( today >= dateFrom && today <= dateUntil )
		{
			$("div.corp_banner.igsXmas").show()
		}
	}
	
	var xMas = xMasSeason();
	var newYear = newYearSeason();
	if ( xMas || newYear )
	{
		$("div#header_bg").css("background",'url("/GenericFiles/4.0/img/header/xmas/sides_bg.png") repeat scroll 0 0 transparent')
	}
	
	var condolenceTxt = [
		["eng","Brastel and its staff would like to express our sincere condolences to those who have been afflicted by the devastating earthquake and subsequent tsunami that struck Northeastern Japan on Friday, March 11, 2011."],
		["fre","Brastel et son personnel voudraient exprimer leurs sincères condoléances  à tous ceux qui ont été affligés par le tremblement de terre et le tsunami qui ont frappé le Nord-Est du Japon le Vendredi 11 Mars 2011."],
		["ind","Brastel and its staff would like to express our sincere condolences to those who have been afflicted by the devastating earthquake and subsequent tsunami that struck Northeastern Japan on Friday, March 11, 2011."],
		["jpn","\u6771\u5317\u5730\u65B9\u592A\u5E73\u6D0B\u6C96\u5730\u9707\u306B\u304A\u304D\u307E\u3057\u3066\u3001\u4EA1\u304F\u306A\u3089\u308C\u305F\u65B9\u3005\u3068\u305D\u306E\u3054\u907A\u65CF\u306E\u7686\u3055\u307E\u306B\u5BFE\u3057\u3001\u6DF1\u304F\u304A\u6094\u3084\u307F\u3092\u7533\u3057\u4E0A\u3052\u307E\u3059\u3068\u3068\u3082\u306B\u3001\u88AB\u707D\u3055\u308C\u305F\u7686\u3055\u307E\u306B \u5FC3\u3088\u308A\u304A\u898B\u821E\u3044\u7533\u3057\u4E0A\u3052\u307E\u3059\u3002"],
		["kor","\uB3D9\uBD81\uC9C0\uBC29 \uD0DC\uD3C9\uC591 \uC9C0\uC9C4\uC73C\uB85C \uB3CC\uC544\uAC00\uC2E0 \uBD84\uB4E4\uACFC \uC720\uC871\uBD84\uAED8 \uBA85\uBCF5\uC744 \uBE4C\uBA70 \uC7AC\uD574\uB97C \uC785\uC740 \uBD84\uB4E4\uAED8\uB3C4 \uC9C4\uC2EC\uC73C\uB85C \uC704\uB85C\uC758 \uB9D0\uC500\uB4DC\uB9BD\uB2C8\uB2E4."],
		["esp","Brastel y todos sus funcionarios, expresamos nuestras sentidas condolencias a todas las personas que han sido afectadas por el devastador terremoto y maremoto que azot\u00F3 el noreste de Jap\u00F3n, el pasado 11 de marzo de 2011."],
		["tag","Ang Brastel at lahat ng staff nito ay taos pusong nakikiramay sa mga nasalanta at napinsala ng lindol at tsunami na naganap sa Northeastern Japan noong Biyernes, ika-11 ng Marso 2011."],
		["tha","\u0E17\u0E32\u0E07\u0E1A\u0E23\u0E34\u0E29\u0E31\u0E17\u0E41\u0E25\u0E30\u0E1E\u0E19\u0E31\u0E01\u0E07\u0E32\u0E19\u0E02\u0E2D\u0E07\u0E1A\u0E23\u0E31\u0E2A\u0E40\u0E17 \u0E25\u0E17\u0E38\u0E01\u0E04\u0E19 \u0E02\u0E2D\u0E41\u0E2A\u0E14\u0E07\u0E04\u0E27\u0E32\u0E21\u0E40\u0E2A\u0E35\u0E22\u0E43\u0E08\u0E41\u0E01\u0E48\u0E1C\u0E39\u0E49\u0E1B\u0E23\u0E30\u0E2A\u0E1A\u0E20\u0E31\u0E22\u0E1E\u0E34\u0E1A\u0E31\u0E15\u0E34\u0E17\u0E38\u0E01\u0E17\u0E48\u0E32\u0E19 \u0E43\u0E19\u0E40\u0E2B\u0E15\u0E38\u0E01\u0E32\u0E23\u0E13\u0E4C\u0E41\u0E1C\u0E48\u0E19\u0E14\u0E34\u0E19\u0E44\u0E2B\u0E27\u0E41\u0E25\u0E30\u0E04\u0E25\u0E37\u0E48\u0E19\u0E2A\u0E36\u0E19\u0E32\u0E21\u0E34 \u0E40\u0E21\u0E37\u0E48\u0E2D\u0E27\u0E31\u0E19\u0E28\u0E38\u0E01\u0E23\u0E4C\u0E17\u0E35\u0E48 11 \u0E21\u0E35\u0E19\u0E32\u0E04\u0E21 2554 \u0E17\u0E32\u0E07\u0E20\u0E32\u0E04\u0E15\u0E30\u0E27\u0E31\u0E19\u0E2D\u0E2D\u0E01\u0E40\u0E09\u0E35\u0E22\u0E07\u0E40\u0E2B\u0E19\u0E37\u0E2D\u0E02\u0E2D\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28\u0E0D\u0E35\u0E48\u0E1B\u0E38\u0E48\u0E19"],
		["rus","\u041A\u043E\u043C\u043F\u0430\u043D\u0438\u044F \u0411\u0440\u0430\u0441\u0442\u0435\u043B \u0432\u044B\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0441\u043A\u0440\u0435\u043D\u043D\u0438\u0435 \u0441\u043E\u0431\u043E\u043B\u0435\u0437\u043D\u043E\u0432\u0430\u043D\u0438\u044F \u0447\u043B\u0435\u043D\u0430\u043C \u0441\u0435\u043C\u0435\u0439, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u043F\u043E\u0442\u0435\u0440\u044F\u043B\u0438 \u0441\u0432\u043E\u0438\u0445 \u0431\u043B\u0438\u0437\u043A\u0438\u0445 \u0438\u043B\u0438 \u043F\u043E\u0441\u0442\u0440\u0430\u0434\u0430\u043B\u0438 \u043E\u0442 \u0440\u0430\u0437\u0440\u0443\u0448\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0433\u043E \u0437\u0435\u043C\u043B\u0435\u0442\u0440\u044F\u0441\u0435\u043D\u0438\u044F \u0438 \u043F\u043E\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0433\u043E \u0437\u0430 \u043D\u0438\u043C \u0446\u0443\u043D\u0430\u043C\u0438, \u043E\u0431\u0440\u0443\u0448\u0438\u0432\u0448\u0438\u0445\u0441\u044F \u043D\u0430 \u0441\u0435\u0432\u0435\u0440\u043E-\u0432\u043E\u0441\u0442\u043E\u043A \u042F\u043F\u043E\u043D\u0438\u0438 \u0432 \u043F\u044F\u0442\u043D\u0438\u0446\u0443, 11 \u043C\u0430\u0440\u0442\u0430 2011 \u0433\u043E\u0434\u0430."],
		["chi","\u5411\u6771\u5317\u2027\u95DC\u6771\u5927\u5730\u9707\u7684\u53D7\u707D\u8005\u6DF1\u8868\u54C0\u60BC\u3002"],
		["vie","Ch\u00FAng t\u00F4i xin chia bu\u1ED3n c\u00F9ng v\u1EDBi t\u1EA5t c\u1EA3 n\u1EA1n nh\u00E2n thi\u00EAn tai v\u00F9ng \u0110\u00F4ng B\u1EAFc - Nh\u1EADt B\u1EA3n v\u00E0o ng\u00E0y 11 th\u00E1ng 3 v\u1EEBa qua."],
		["por","A Brastel e seus funcion\u00E1rios expressam as mais profundas condol\u00EAncias a todas as v\u00EDtimas do devastador terremoto e subsequente maremoto que assolaram o nordeste do Jap\u00E3o, no \u00FAltimo dia 11 de mar\u00E7o de 2011."]
	]
	
	if ( page == "home" && parent.document.location == document.location )
	{
		for ( var i = 0; i < condolenceTxt.length; i++ )
		{
			if ( condolenceTxt[i][0] == lang )
			{
				$('<div class="condolences before" />').html(condolenceTxt[i][1]).insertBefore("#feature_list");
				//$('<div class="condolences after" />').html(condolenceTxt[i][1]).insertAfter("#feature_list");
				break;
			}
		}
	}
	
	// Donations link
	if ( $("#output li.donation").length > 0 )
	{
		showDonationsLink();
		$("div.condolences").live("click",function(){
			openDonationPage();
			pageTracker._trackPageview('/clicks/home/top_banner/'+lang+'/earthquake_donations_text_msg');
		});
		$("li.donation").click(function(){
			openDonationPage();
			pageTracker._trackPageview('/clicks/home/top_banner/'+lang+'/earthquake_donations_banner');
		});
	}
	
}); //-- $(document).ready end

function xMasSeason()
{
	var dateFrom = new Date();
	var dateUntil = new Date();
	dateFrom.setFullYear(2010,11,11);
	dateUntil.setFullYear(2010,11,31);
	var today = new Date();
	
	if ( today >= dateFrom && today <= dateUntil )
	{
		return true;
	}
	else
	{
		return false;
	}
}
function newYearSeason()
{
	var dateFrom = new Date();
	var dateUntil = new Date();
	dateFrom.setFullYear(2011,0,1);
	dateUntil.setFullYear(2011,0,11);
	var today = new Date();
	
	if ( today >= dateFrom && today <= dateUntil )
	{
		return true;
	}
	else
	{
		return false;
	}
}


function setRatesIfrSrc(acr)
{
	var page = getPage()[0];
	var ifrsrc = "/web/WIMS/Manager.aspx?xslFile=rates.xsl&Style=1";
	var acr = "&acr="+acr;
	var rateSystemCode = "&rateSystemCode=";
	var subSystem = "";
	if ( page == "webphonerates" ) rateSystemCode += "SPCWEBINT";
	else if ( page == "fliprates" ) rateSystemCode += "SPCFLIP";
	else if ( page == "bmobilerates" ) rateSystemCode += "SPCEMC";
	else if ( page == "appsrates" )
	{
		rateSystemCode += "SPCWEBINT";
		subSystem = "&sub=app";
	}
	
	$("iframe.ratesIfr").attr("src",ifrsrc+acr+rateSystemCode+subSystem);
}
function hideCountrySel(){
	$("div#selCountryHelp").hide();
	$("div#opaqueBg").animate({opacity:0},500).hide()
	$("div#selectCountry").slideUp();
	$("div#selCountrySpacer").slideUp();
	$("div#header_bg").slideDown();
}

function setIfrSources()
{
	var lang = getLang()[0];
	var acr = getLang()[1];
	var langVerySign = getLang()[2];
	var page = getPage()[0];
	var pagegrp = getPage()[1];
	var category = getPage()[2];
	
	var langParam = "lang=" + lang;
	var acrParam = "acr=" + acr;
	var langVerySignParam = "lang=" + langVerySign;
	var pageParam = "page=" + page;
	var pagegrpParam = "pagegrp=" + pagegrp;
	var categoryParam = "category=" + category;
	
	var header = document.getElementById("ifrHeader");
	var mainMenu = document.getElementById("ifrMainMenu");
	var footer = document.getElementById("ifrFooter");
	var footer_privacy = document.getElementById("ifrFooterPrivacy");
	var inPreviewMode = previewMode();
	var server = "";
	
	function previewMode() {
		if (getParentParamNames()[0] == "qsPageCD") return true; else return false;
	}
	
	if (inPreviewMode) var server = "http://192.168.1.2";
	if (secure != -1) var server = "https://www2.brastel.com";
	
	if (header)
	{
		$("iframe#ifrHeader").attr({src: server + "/web/WIMS/Manager.aspx?xslFile=header.xsl&xmlPreview=languages.xml&Style=1&Service=1&" + acrParam + "&" + pageParam + "&" + categoryParam});
	}
	if (mainMenu)
	{
		$("iframe#ifrMainMenu").attr({src: server + "/" + lang + "/menu/" + category + "/?" + pageParam + "&" + pagegrpParam});
	}
	if (footer)
	{
		$("iframe#ifrFooter").attr({src: server + "/web/WIMS/Manager.aspx?xslFile=footer.xsl&xmlPreview=languages.xml&Style=1&Service=1&" + acrParam});
	}
	/*
	if (footer_privacy)
	{
		$("iframe#ifrFooterPrivacy").attr({src: server + "/web/WIMS/Manager.aspx?xslFile=privacyfooter.xsl&xmlPreview=languages.xml&Style=1&Service=1&" + acrParam + "&" + pageParam + "&" + categoryParam});
	}
	*/
}

var newwindow = "";
function popUp(url,name,specs) {
	if (!newwindow.closed && newwindow.location)
		{
			newwindow.location.href = url;
		}
	else
		{
			newwindow=window.open(url,name, specs);
			if (!newwindow.opener) { newwindow.opener = self; }
		}
	if (window.focus) 
		{
			newwindow.focus()
		}
	return true;
}

function runtest() {
	alert(getPage());
}

function alertcookie() {
	alert(readCookie("spcAddSvcMenuOpn"))
}
function alertPage() {
	alert(getPage())
}
function chatCafe(){
 var timer;
		jQuery(function($) {
        timer = setTimeout(Dialog, 100);
	});

	function Dialog() {
        $("#dialog_1").animate({marginTop: "-145px"}, 200).animate({marginTop: "-135px"}, 400, "linear", function() {
                timer = setTimeout(Dialog, 500);
        });
}


var timer;
		jQuery(function($) {
        timer = setTimeout(Dialog1, 200);
	});

	function Dialog1() {
        $("#dialog_2").animate({marginTop: "-360px"}, 200).animate({marginTop: "-350px"}, 400, "linear", function() {
                timer = setTimeout(Dialog1, 500);
        });
}

var timer;
		jQuery(function($) {
        timer = setTimeout(Dialog2, 500);
	});

	function Dialog2() {
        $("#dialog_3").animate({marginTop: "-360px"}, 200).animate({marginTop: "-350px"}, 400, "linear", function() {
                timer = setTimeout(Dialog2, 500);
        });
}
}

// HOW TO RECHARGE
function showWindows(category)
{ 
	if (category == "tab1")
	{
		getSty("tab1").display="none";		
		getSty("tab2").display ="none";
		$(document).ready(function() {
		$('#tab1').slideDown('slow');
		return false;
		});
	}
	else
	{
		getSty("tab2").display="none";
		getSty("tab1").display = "none";
		$(document).ready(function() {
		$('#tab2').slideDown('slow');
		return false;
		});
	}
}

function showDonationsLink()
{
	var _href = "/"+lang+"/allforjapan/";
	var _img = $('<img src="/GenericFiles/4.0/img/all4Japan/badge.png" alt="" />');
	$('<a class="all4JapanLink" />')
		.attr("href",_href).html(_img)
		.appendTo("div.condolences")
		.click(function(){
			openDonationPage();
			pageTracker._trackPageview('/clicks/home/top_banner/'+lang+'/earthquake_donations_badge');
			return false;
		}).hover(
			function(){$("div.condolences").addClass("underline")},
			function(){$("div.condolences").removeClass("underline")}
		);
}
function openDonationPage()
{
	var lang = getLang()[0];
	var _href = "/"+lang+"/allforjapan/";
	var w=window.open(_href,'_allforjapan','width=960, height=800, scrollbars=1');
	w.focus();
	return false;
}
function hideDeltaSlide()
{
	$("#delta_campaign").animate({bottom:-209},1000,function(){
		$("#delta_campaign .open_close .tab_arrow").css("background-position","0 0");
	});
	$.cookie("closeDeltaSlide","yes", {expires:7,path: '/'});
}
function showDeltaSlide()
{
	$("#delta_campaign").animate({bottom:0},1000,function(){
		$("#delta_campaign .open_close .tab_arrow").css("background-position","0 bottom");
	});
	$.cookie("closeDeltaSlide","no", {expires:7,path: '/'});
}
function openDeltaPage()
{
	hideDeltaSlide();
	popUp("http://www2.brastel.com/newsletters/brastel_delta_email_"+lang+"_winners.html","delta","width=750, height=900, location=0, directories=0, toolbar=0, directories=0, resizable=1, status=0, scrollbars=1")
}

