m="m1";
c="m1";

var wappushbtn="";
function wappush()
{
	var phone =$("#phone").val();
	phone = $("#country_code").html() + phone;
	if (phone.length < 10)
	{
		alert("Please input your mobile phone number correctly");
	}
	else
	{
		wappushbtn =$("#SendWapPush").html();
		$("#SendWapPush").html("Seding Wap Push...");
		$.post('rpc/wappush.ashx',{
			phone: phone,					
			l : "1"
		  },function(xml){
				if(xml=="0")
				{
					$("#SendWapPush").html("Morange has pushed wap download link to your mobile, the message should arrive in a minute.");
				}
				else if(xml=="1")
				{
					$("#SendWapPush").html("Wappush message sending fail, please <a href='#' onclick='$(\"#SendWapPush\").html(wappushbtn)'>try again</a> later or install Morange by other options.");
				}
				else
				{
					$("#SendWapPush").html("Each User is only allowed to send out 3 Wap Push everyday. Please try again on another day.");
				}
		});
	}
	return false;
}

function showContent(id)
{
	if (c!=id)
	{
		$("#c" + c).fadeOut("fast", function(){
			$("#c" + id).fadeIn("fast");
			if($("#cr" + id))showRec("cr" + id);
		 });
	}
	c=id;
}
function timestamp()
{
	var now = new Date();			
	return now.getTime();
}

function showRec(id)
{
	$.get("rec.aspx",{
	t:timestamp()
	  },function(xml){
			$("#" + id).html(xml);
			$("#" + id).fadeIn("slow");
	});
}

function swapmenu(it, item)
{
	$("#m" + m).slideUp("slow");
	$("#m" + m).parent().removeClass("active");
	$("#m" + it).slideDown("slow");
	showContent(it);
	$(item.parentNode).addClass("active");

	m=it;
}

window.onload = function() 
{
	url = document.location.href;
	if(url.indexOf("#")>0)
	{
		var start = url.indexOf("#")+1;
		part = url.substring(start);
		if(part)
		{
			if(part.indexOf(".")>0)
				ajaxContent(part);
			else
				showContent(part);				
		}					
	}			
}
function sms_swap(id)
{
	 $("#sms_swap_pic").attr("src","images/download/tap" +  id + ".gif");
	 $("table.sms_swap").hide("fast", function(){$("#sms_swap" + id).fadeIn();});		 
}

function sms_change_country(c)
{
	$("#country_code").html(c.value);
}