var x=0;
var y=0;
var shown =0;
var isWap = 0;

//The big mouse over function
function ShowProfilePic(url,userid)
{
	var myDiv = document.getElementById('divPic');
	myDiv.style.visibility = 'visible';		
		
	myDiv.innerHTML = userid+'<BR><img src = "'+url+'" >';
	shown=1;
	
}
//The big mouse over function
function ShowWapPic(url,userid)
{
	var myDiv = document.getElementById('divPic');
	myDiv.style.visibility = 'visible';		
	isWap=1;
	MoveProfilePic();
	myDiv.innerHTML = userid+'<BR><img src = "'+url+'" >';
	shown=1;
	
}

//Big mouseover support function
function MoveProfilePic()
{
	if(isWap==0)
	{
		x = window.event.clientX + document.body.scrollLeft+20;
		y = window.event.clientY + document.body.scrollTop-100;
	}
	else
	{
		x = window.event.clientX + document.body.scrollLeft+20;
		y = window.event.clientY + document.body.scrollTop-250;
	}
	var myDiv = document.getElementById('divPic');
	if (myDiv) //&& (shown==1))
	{
		if (y<0)
		{
			y=0;
		}	
		if (y>document.body.scrollHeight-myDiv.offsetHeight)
		{
			y=document.body.scrollHeight-myDiv.offsetHeight;
		}
		if (x>document.body.scrollWidth-myDiv.offsetWidth)
		{
			x=x-myDiv.offsetWidth-40;
		}		
	
		myDiv.style.top = y + 'px';
		myDiv.style.left = x+'px';
	}
}

//Big mouseover support 
function HideProfilePic()
{				
	var myDiv = document.getElementById('divPic');
	myDiv.style.visibility = 'hidden';				
	myDiv.innerHTML = '';
	shown=0;
}
//Big mouseover support 
function HideWapPic()
{				
	var myDiv = document.getElementById('divPic');
	myDiv.style.visibility = 'hidden';				
	myDiv.innerHTML = '';
	shown=0;
	isWap=0;
}

function resizePic(x)
{
	//alert('hi');
	if(x.width > x.height)
	{ 
		var temph =Math.round(((76)/x.width) * x.height); 
		if(temph>5)
		{
			x.height = temph; 
		}
		else
		{				
			setTimeout("resizePic(x,0)",10);
		}
		x.width = (76);		
	}
	else
	{
		var tempw =Math.round(((76)/x.height) * x.width); 
		if(tempw>5)
		{
			x.width = tempw;
		}
		else
		{
			setTimeout("resizePic(x,0)",10);
		}
		
		x.height = (76); 
	} 
}
function resizeMainPic(x,depth)
{	
	if(x)
	{
		if(x.width)
		{	
			if(x.width > x.height)
			{ 
				var temph =Math.round(((127)/x.width) * x.height); 
				if(temph>2)
				{
					x.height = temph; 
					x.width = (127); 
				}
				else
				{				
					setTimeout("resizeMainPic(x,0)",10);
				}
				
			}
			else
			{
				var tempw =Math.round(((127)/x.height) * x.width); 
				if(tempw>2)
				{
					x.width = tempw;
					x.height = (127); 
				}
				else
				{
					setTimeout("resizeMainPic(x,0)",10);
				}			
			}
		}
		else
		{
			//alert('wurp ' + x)
			x.width=120;
			//x.height=Math.round(((127)/x.width) * x.height);
			//x.src = x.src;
			
		}
	}
}

function ShowSendSmsBox()
{
	var myDiv = document.getElementById('SendSmsBox');
	myDiv.className = "visText";
	isSendSmsBoxOn=1;
}

function HideSendSmsBox()
{
	var myDiv = document.getElementById('SendSmsBox');
	myDiv.className = "hiddenText";
	isSendSmsBoxOn=0;
}

function SetBmf(innerText)
{
	var myDiv = document.getElementById('BMF');
	myDiv.innerHTML = innerText;
}

function SetPhone(innerText)
{
	var myDiv = document.getElementById('SendSmsBox');
	myDiv.innerHTML = innerText;
}

			
// Align Tab: LEFT, CENTER, RIGHT
var tabAlign = "LEFT";
var Tabindex ;

/*
imageFR = new Image();
imageFR.src = "./_images/tab_off_right.gif";

imageNR = new Image();
imageNR.src = "./_images/tab_on_right.gif";

imageFL = new Image();
imageFL.src = "./_images/tab_off_left.gif";

imageNL = new Image();
imageNL.src = "./_images/tab_on_left.gif";

imageRt = new Image();
imageRt.src = "./_images/arrow_rt.gif";

imageDn = new Image();
imageDn.src = "./_images/arrow_dn.gif";
*/

/*********************************************/

function tabOnClick(ID)
{
	Tabindex = ID;	
	tabLoad(ID);		
					
	var tab = tabs[ID].split("|");
	var TabFramer = document.getElementById("TabFrame");
	TabFramer.src = "pleasewait.aspx?gt="+tab[1];
	TabFramer.style.height = tab[2];		

	document.body.focus;
}

function iframeLoad()
{
	var TabFramer = document.getElementById("TabFrame");

	//find the height of the internal page
	var the_height= TabFramer.contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	TabFramer.style.height=	the_height;	
}

function iframeIBLoad()
{
	var TabFramer = document.getElementById("frmIB");

	//find the height of the internal page
	var the_height= TabFramer.contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	TabFramer.style.height=	the_height;	
}

function iframePHLoad()
{
	var TabFramer = document.getElementById("frmPH");

	//find the height of the internal page
	var the_height= TabFramer.contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	TabFramer.style.height=	the_height;	
}

function GoToPage(pagestr,id)
{
	var ocElement = null;
	ocElement = document.getElementById('secondary'+Tabindex);
	//ocElement.innerHTML=subtabs[Tabindex];
	
	
	//var sbElement = document.getElementById(id);
	//sbElement.className = "tabOn";
	
	var TabFramer = document.getElementById("TabFrame");
	TabFramer.src = "pleasewait.aspx?gt="+pagestr;
	TabFramer.style.height = "600px";
} 

function tabLoad(selected)
{

	if(selected==null)
	{
		for (var i = 0; i < tabs.length; i++)
		{
			var tab = tabs[i].split("|");

			if (tab[3] == "*")
			{
				selected=i;

				break;
			}
		}	
	}
	
	var HTML = "";
	var divTabButtons = document.getElementById("divTabButtons");

	HTML += "<div id='TabHeader'><ul id='primary'>";
	for (var i = 0; i < tabs.length; i++)
	{
		var tab = tabs[i].split("|");
		if(i!=selected)
		{		
			//HTML += "<li ID='C"+i+"'><a href = 'javascript:;' onclick='tabOnClick("+i+");' >"+tab[0]+"</a></li>";				
			HTML += "<li><a href='javascript:;' onclick='tabOnClick("+i+");' >"+tab[0]+"</a></li>";				
		}
		else
		{
			//HTML += "<li ID='C"+i+"'><span><a href = 'javascript:;' onclick='tabOnClick("+i+");' >"+tab[0]+"</a></span></li>";				
			HTML += "<li style='cursor:default'><span>"+tab[0]+"</span>"+subtabs[Tabindex]+"</li>";
		}
	}
	HTML += "</ul></div><div id='subnav'></div>"

	divTabButtons.innerHTML = HTML;
	
}

function break_out_of_frame() 
{ 
	if (top.location != location) { 
		top.location.href = document.location.href ;
	}
}

function sitemaplinker()
{
	var URL = document.frmsmsProfile.SMSacHeader_new1_sitemap.options
	[document.frmsmsProfile.SMSacHeader_new1_sitemap.selectedIndex].value;
	window.location.href = URL;
}


function ResizeRingTones()
{
	var ifRingtoner = document.getElementById("ifRingtones");

	//find the height of the internal page
	var the_height= ifRingtoner.contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	ifRingtoner.style.height= the_height;			
	
	divRingtones.style.height= the_height;
}
//-->

// BSE - to move scroller		
function scrollToCoordinates(x, y)
{ 		
	window.scrollTo(x, y);
} 
function parentReload()
{		
	location.reload();	
}
function windowReload()
{
	window.open(''+parent.location,'','','true');			
}
		
function ShowBranch(branch, imgbtn) 
{ 
	var objBranch = document.getElementById(branch).style; 
	var objBtn = document.getElementById(imgbtn); 

	if(objBranch.display=="block") 
	{
		objBranch.display="none"; 
		if (document.images)
		{
			objBtn.innerHTML="<img Width='15px' src='_images/arrow_rt.gif' Height='20px' border='0'>";
		}
	}
	else 
	{
		objBranch.display="block";
		if (document.images)
		{
			objBtn.innerHTML="<img Width='15px' src='_images/arrow_dn.gif' Height='20px' border='0'>";
		}
	}

}

function jsOpenhWnd(u){p="height=660,width=380,toolbar=no,directories=no,status=no,scrollbars=auto,resizable=no,menubar=no";hWnd=window.open(u,"Hwnd",p);hWnd.focus();}

function fnTimedShow()
{
	window.setTimeout("show('phone_top')", 600);
}

function toggle2(id) 
{
	if (document.getElementById(id).style.visibility = "hidden") {
		document.getElementById(id).style.visibility = "visible";
	}
	else {
		document.getElementById(id).style.visibility = "hidden";							
	}	
}

function ChangeIncomingReqs(num)
{
	
	
	if (num > 0)
	{
		var divInc = document.getElementById("ProfileBox1_lblRequestCount");
		if(divInc)
		{
			divInc.innerHTML = "("+ num +")";
		}
		var imail = document.getElementById("ProfileBox1_imgMail");
		if(imail)
		{
			imail.src="/smsProfile/_images/template/incoming_alert.gif";
		}
		
		
		var link = document.getElementById("ProfileBox1_lnkIncomingRequest");
		link.className = "controlpanelalert";	
		
		var link2 = document.getElementById("ProfileBox1_lblRequestCount");
		link2.className = "controlpanelalert";	
	}
	else
	{
		var divInc = document.getElementById("ProfileBox1_lblRequestCount");
		if(divInc)
		{
			divInc.innerHTML = "";
		}
		var imail = document.getElementById("ProfileBox1_imgMail");
		if (imail)
		{
			imail.src="/smsProfile/_images/template/incoming.gif";
		}
		
		var link = document.getElementById("ProfileBox1_lnkIncomingRequest");
		if(link)
		{
			link.className = "controlpanel";
		}

		var link2 = document.getElementById("ProfileBox1_lblRequestCount");
		if(link2)
		{
			link2.className = "controlpanel";
		}
	}
}

document.onmousemove=MoveProfilePic


function SendtoPhone(url)
{
	frames["frmPH"].AcceptProfileURL(url);
}
	
	
function ChangeToBox(userid)
{
	frames["frmPH"].AcceptUserid(userid);
	scrollToCoordinates(0,0);
}

var isSendSmsBoxOn=0;

					

