var isWidgetLoad = 0, WidgetTimer;
function LoadWidget( obj, refId ){
	if ( !Custom ){		
		if ( !isWidgetLoad ){
			$('#LoadingWidget').show();
			$('.WidgetCont').hide();
			clearTimeout(WidgetTimer);
			var activeId = $('.WidCur').attr('id');
			var activeRefId = -1;
			if ( typeof activeId != 'undefined' )
				activeRefId = activeId.substr(activeId.lastIndexOf('_')+1);
			
			if ( activeRefId != refId ){
				if ( document.getElementById('DefaultWidget') ){
					document.getElementById('DefaultWidget').className = document.getElementById('DefaultWidget').className.replace(/\bon\b/,'off');
					document.getElementById('DefaultWidget').setAttribute('id','');
				}	
			
				isWidgetLoad = 1;
				obj.className = /\boff\b/.test(obj.className) ? obj.className.replace(/\boff\b/,'on') : obj.className.replace(/\bon\b/,'off');
				obj.setAttribute('id','DefaultWidget');
				WidgetTimer = setTimeout(function(){
					$('#LoadingWidget').hide();
					$('.WidgetCont').show();
					$('.WidCur').animate({'left':'464px'},'slow',function(){$(this).css('left','-464px');$(this).removeClass('WidCur');});
					$('#Widget_'+refId).addClass('WidCur');
					$('#Widget_'+refId).animate({'left':'0px'},'slow',function(){isWidgetLoad=0;});
				},1500);
			}
		}
	}
}

function AccountSwitchEfx(){
	$('#LoadingWidget').show();
	$('.WidgetCont').hide();
	$('.WidCur').css({'left':'-464px'});
	setTimeout(function(){
			$('#LoadingWidget').hide();
			$('.WidgetCont').show();
			$('.WidCur').animate({'left':'0px'},'slow');
		},1500);
}

function ToggleTab(obj, refId){
	if ( document.getElementById(refId+'_Active') ){
		$('#'+refId+'TC_'+$('#'+refId+'_Active').attr('rel')).hide();
		$('#'+refId+'_Active').removeClass('Act');		
		$('#'+refId+'_Active').attr('id','');
	}
	$('.BdrR0').removeClass('BdrR0');
	$(obj).prev().addClass('BdrR0');
	$(obj).addClass('Act')
	$(obj).attr('id',refId+'_Active');
	$('#'+refId+'TC_'+$(obj).attr('rel')).fadeIn(600);
	if(refId == 'Wireless')
	{
	
	showHideTabCont();
	}
}
function ToggleTabDD(obj, ddId){
	$('#'+ddId).css('top',$(obj).height());
	$('#'+ddId).toggle();
}
function hideTabDD(e,aDivs){
	if( !trackMouseOnDiv(e,aDivs) ){
		$('#DvrDD').hide();
	}
}

function selectValueToDD(obj){
	$('#TabDDLbl').html(obj.innerHTML+'<em></em>')
	$('#DvrDD').hide();
}
function showProgress( BarId, toPercent){	
	var t = new AnimTimer();	
	var rng = Math.round(getObject(BarId+'Cont').offsetWidth / 100);
	var i = 1;
	var intTimer = toPercent > 50 ? 70 : 45;
	if ( toPercent <= 0 ){
		document.getElementById(BarId+'Left').style.display = 'none';
		document.getElementById(BarId).className = 'TSM';
	}
	t.updateTimer(
				  	setInterval(
									function(){
												getObject(BarId).style.width = i+'%'; 
												i = i+rng;
												getObject(BarId+'_StatusTxt').innerHTML = i+'%';
												if ( i >= toPercent){
													document.getElementById(BarId+'Right').className = toPercent >= 100 ? 'TSRG' : 'TSR';
													getObject(BarId).style.width = toPercent+'%';
													getObject(BarId+'_StatusTxt').innerHTML = toPercent+'%';
													clearTimeout(t.getTimer());
												}
											  },intTimer
								)
				);
}

/* On Demand Tab Toggle in home page */
function ToggleHLRc( obj, type ){
	if ( document.getElementById(type+'_Active') ){
		$('#'+type+'_Active').removeClass('Act');
		$('#'+type+'_Active').next().removeClass('NBdr');
		document.getElementById(type+'_Active').setAttribute('id','');			
	}
	$(obj).parent().attr('id',type+'_Active');
	$(obj).parent().addClass('Act');
	$(obj).parent().next().addClass('NBdr');		
	
	if ( $(obj).parent().is(':last-child') ) 
		$('#'+type+'RC').addClass('RCOn')
	else
		$('#'+type+'RC').removeClass('RCOn')
		
	if ( $(obj).parent().is(':first-child') )
		$('#'+type+'LC').addClass('LCOn')
	else
		$('#'+type+'LC').removeClass('LCOn')
}
/* On Demand Tab Toggle in home page */



/* popup code */
var popInnerCont,popContentId, aSelect;
function hideSelectBox(){
	var ob = document.getElementsByTagName('select');
	aSelect = [];
	for ( var t=0; t<ob.length; t++ ){
		aSelect.push( ob[t] );
		ob[t].style.visibility = 'hidden';
	}
}
function revealSelectBox(){
	for ( var t=0; t<aSelect.length; t++ ){
		aSelect[t].style.visibility = 'visible';
	}
	aSelect = null;
}
function openPopup(T,W,poptype, e)
{
	if(arguments.length==0)
	{
		alert('Invalid arguments. onclick="openPopup(Title, Width, Popup Type)"');
		return;
	}
	hideSelectBox();
	popContentId = poptype;
	popContent = '&nbsp;';
	popContent = popInnerCont = document.getElementById(poptype).innerHTML;
	document.getElementById(poptype).innerHTML = '';	
	
	var poptitle=T;
	var popwidth=W;
	var obj=document.createElement('div');
	obj.id='popouter_drag';
	if(document.all)
	{obj.style.width=document.body.clientWidth+'px';
	obj.style.height=document.body.scrollHeight+30+'px';}
	else
	{obj.style.width=document.body.clientWidth+'px';
	obj.style.height=document.body.scrollHeight+'px';}
	document.body.appendChild(obj);
	
	obj=document.createElement('div');
	obj.id='popupbox_drag';
	obj.style.width=popwidth+'px';
	obj.style.left=(document.body.clientWidth-popwidth)/2+'px';
	document.body.appendChild(obj);
	var popcnt='<table width="100%" cellpadding="0" cellspacing="0" border="0">'+
			   '<tr>'+
			  '<td class="popup_top_lcurve" width="5" nowrap></td>'+
			   '<td class="popup_top_bg" width="100%">'+
			  '<div class="Fl popup_title" title="Customize your Tabs">'+poptitle+'</div>'+
			 ' <div class="Fr PadT4">'+
			  '<a  class="Fl" href="javascript:closePopup();" title="Close"><u>Close</u></a>'+
			  ' <a href="javascript:closePopup();" class="popup_ico_close MarR5 MarL4" title="Close"></a>'+
			  '</div>'+  
			  '</td>'+
			  '<td id="popup_top_rcurve" class="popup_top_rcurve" width="5" nowrap></td>'+
				'</tr>'+
				'<tr>'+
				'<td colspan="4" class="popup_cont_bg" valign="top" id="PopContBg">'+popContent+'</td>'+
				'</tr>'+
				'<tr>'+
				'<td colspan="4">'+
				'<b class="VZ_PopupCnr1"><b class="VZ_PopupCnr1B4"></b>'+
				'<b class="VZ_PopupCnr1B3"></b><b class="VZ_PopupCnr1B2"></b><b class="VZ_PopupCnr1B1"></b></b>'+
			   '</td>'+
			  '</tr>'+
			'</table>';
  if(poptype!='VZWelcome' && poptype!='VZWelcome2')
    document.getElementById('popupbox_drag').innerHTML=popcnt;
  else
    document.getElementById('popupbox_drag').innerHTML = popContent;
  var offHeight = document.getElementById('popupbox_drag').offsetHeight;
	var scrTop    = (document.documentElement && document.documentElement.scrollTop)||(document.body && document.body.scrollTop)||0;
	document.getElementById('popupbox_drag').style.top= scrTop+100+'px';



}

function closePopup() {
    if (document.getElementById('popupbox_drag') != null) {
        var obj = document.getElementById('popupbox_drag');
        document.body.removeChild(obj);
    }
    if (document.getElementById('popouter_drag') != null) {
        var obj = document.getElementById('popouter_drag');
        document.body.removeChild(obj);
    }    
    if (document.getElementById('popupbox') != null) {
        var obj = document.getElementById('popupbox');
        document.body.removeChild(obj);
    }
    if (document.getElementById('popouter') != null) {
        var obj = document.getElementById('popouter');
        document.body.removeChild(obj);
    }
	if (document.getElementById(popContentId))
	document.getElementById(popContentId).innerHTML = popInnerCont;
	revealSelectBox();
}

function openWelcomeBasketPopup(T, W, poptype, e) {
    if (arguments.length == 0) {
        alert('Invalid arguments. onclick="openPopup(Title, Width, Popup Type)"');
        return;
    }
    hideSelectBox();
    popContentId = poptype;
    popContent = '&nbsp;';
    popContent = popInnerCont = document.getElementById(poptype).innerHTML;
    document.getElementById(poptype).innerHTML = '';

    var poptitle = T;
    var popwidth = W;
    var obj = document.createElement('div');
    obj.id = 'popouter';
    obj.style.width = document.body.clientWidth + 'px';
    obj.style.height = document.body.scrollHeight + 'px';
    document.body.appendChild(obj);

    obj = document.createElement('div');
    obj.id = 'popupbox';
    obj.style.width = popwidth + 'px';
    obj.style.left = (document.body.clientWidth - popwidth) / 2 + 'px';
    document.body.appendChild(obj);
    var popcnt = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'
			   + '<tr>'
				+ '	<td colspan="4" class="PopCBg" valign="top">' + popContent
				+ '    </td>'
				+ '</tr>'
			+ '</table>';

    if (poptype != 'AtchViewer') {
        document.getElementById('popupbox').innerHTML = popcnt;
    }
    else {

        document.getElementById('popupbox').innerHTML = popContent;
    }
    var offHeight = document.getElementById('popupbox').offsetHeight;
    var scrTop = (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop) || 0;
    document.getElementById('popupbox').style.top = scrTop + 100 + 'px';
}

function openWelcomePopup(T, W, poptype, e) {
    if (arguments.length == 0) {
        alert('Invalid arguments. onclick="openPopup(Title, Width, Popup Type)"');
        return;
    }
    hideSelectBox();
    popContentId = poptype;
    popContent = '&nbsp;';
    popContent = popInnerCont = document.getElementById(poptype).innerHTML;
    document.getElementById(poptype).innerHTML = '';

    var poptitle = T;
    var popwidth = W;
    var obj = document.createElement('div');
    obj.id = 'popouter';
    obj.style.width = document.body.clientWidth + 'px';
    obj.style.height = document.body.scrollHeight + 'px';
    document.body.appendChild(obj);

    obj = document.createElement('div');
    obj.id = 'popupbox';
    obj.style.width = popwidth + 'px';
    obj.style.left = (document.body.clientWidth - popwidth) / 2 + 'px';
    document.body.appendChild(obj);
    var popcnt = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'
			   + '<tr>'
				+ '	<td colspan="4" class="popup_cont_bg" valign="top" id="PopContBg">' + popContent
				+ '    </td>'
				+ '</tr>'
			+ '</table>';

    if (poptype != 'AtchViewer') {
        document.getElementById('popupbox').innerHTML = popcnt;
    }
    else {

        document.getElementById('popupbox').innerHTML = popContent;
    }
    if (poptype == 'KeepmeSignedIn') {
        document.getElementById('popup_top_rcurve').style.width = 7;
    }

    var offHeight = document.getElementById('popupbox').offsetHeight;
    var scrTop = (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop) || 0;
    document.getElementById('popupbox').style.top = scrTop + 100 + 'px';
}
function closeWelcomePopup() {
    var obj = document.getElementById('popupbox');
    document.body.removeChild(obj);
    var obj = document.getElementById('popouter');
    document.body.removeChild(obj);
    if (document.getElementById(popContentId))
        document.getElementById(popContentId).innerHTML = popInnerCont;
    revealSelectBox();
}
/* popup code */
