
/* Handset */
function Handset(id)
{
	this.id = id;
	this.compatibilities = new Array();
	this.isCompatible = isCompatible;
	this.a = addCompatibility;
}
	
function isCompatible(productType)
{
	for (var i=0; i <this.compatibilities.length ; i++)
	{
		if (productType == 5 || productType == 10 || productType == 13)
			return true;
		if (this.compatibilities[i] == productType)
			return true;
	}
	return false;
}

function addCompatibility(productType)
{
	this.compatibilities[this.compatibilities.length] = productType;
}
							
function getCookie(name)
{
	var s = document.cookie;
	if (s != null)
	{
		var ss = s.split(";");
		for(var i=0;i<ss.length;i++)
		{
			var sss = ss[i].split("=");
			if (sss.length > 0)
			{
				while ( sss[0].substring(0,1) == " ")
					sss[0] = sss[0].substring(1,s.length);
				if (sss[0] == name)
					return sss[1];
			}
		}
		
	}
	return null;
}

function getHandsetId()
{
	var s = getCookie("HANDSET");
	if (s != null)
	{
		var ss = s.split(",");
		return ss[0];
	}
	return 0;
}

function getHandsetBrandLabel()
{
	var s = getCookie("HANDSET");
	if (s != null)
	{
		var ss = s.split(",");
		return ss[1];
	}
	return "";
}


function getHandsetLabel()
{
	var s = getCookie("HANDSET");
	if (s != null)
	{
		var ss = s.split(",");
		return ss[2];
	}
	return "";
}

function insertCompat(handsetId,typeId,id,obj)
{
	if (h == null)
		return;
	if (h.isCompatible(typeId))
	{
		var element = document.getElementById(id);
		if (element == null)
			return;
		element.innerHTML = obj + element.innerHTML;
	}
}


function getServiceId()
{
	var s = document.location.href;
	var ss = s.split("/");
	if (ss.length > 0)
	{
		var sss = ss[ss.length - 1];
		if (sss != null && sss != "")
		{
			var ssss = sss.split("-");
			if (ssss.length > 0)
				return serviceId = parseInt(ssss[0]);
		}
	}
	return NaN;
}

function isHandsetCompatibleWithService()
{
	var serviceId = getServiceId();
	if (serviceId == NaN)
		return false;
	if (h == null)
		return false;
	if (h.isCompatible(serviceId))
		return true;
}