
//*****************************************************************************************
//* SetScrollerPosition y GetScrollerPosition funciones para mantener entre Postbacks la posicion
//* del scroll.
//* Para que funcione en la pagina que se necesite mantener el scroll, hacer lo siguiente.
//* 1- Agregar esta linea: <script type=text/javascript src=../../Resources/clientUtils.js></script>
//* 2- Cambiar la definicion <body> por esta <body onload="SetScrollerPosition()" onbeforeunload="GetScrollerPosition()">
//* ESO ES TODO!

function SetScrollerPosition()
{ 
	if (document.getElementById("YPos").value != "")
	{
		var y = document.getElementById("YPos").value;
		window.scrollTo(0, y);
		document.getElementById("YPos").value = "";
	}
	
}



function WinPopUp(URLsrc)
{
		//var ventana = window.open(destino, "_blank", ", left=0,top=0,width=830,height=600,toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes");
		var_height = (screen.height * 0.7);
        if(URLsrc.indexOf('?') > 0)
        {
            tb_show(null,URLsrc +"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height="+var_height+"&width=700&modal=true",false);
        }
        else
        {
            tb_show(null,URLsrc +"?placeValuesBeforeTB_=savedValues&TB_iframe=true&height="+var_height+"&width=700&modal=true",false);
        }
}

function getQueryVariable(variable) {
				var query = window.location.search.substring(1);
				var vars = query.split("&");
				for (var i=0;i<vars.length;i++) {
					var pair = vars[i].split("=");
					if (pair[0] == variable) {
					return pair[1];
					}
				} 
				return "";
			}


var timerID = 0;
var tStart  = null;

function UpdateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();

   tDate.setTime(tDiff);

   //Changed by Diego on 18/03/2009
   //document.getElementById('messageSent').innerHTML = 'Sending Test...';    
   document.getElementById('messageSent').innerHTML = $("#"+runEnvironment+"lblSendingTest").text();
   
   if (tDate.getSeconds() == 3) 
       //Changed by Diego on 18/03/2009
       //document.getElementById('messageSent').innerHTML = 'Done!';
       document.getElementById('messageSent').innerHTML = $("#"+runEnvironment+"lblDone").text();
   
   if (tDate.getSeconds() == 4)
   {
		document.getElementById(runEnvironment+'TestOk').style.display = 'none';
		
		document.getElementById(runEnvironment+'TestField').style.display = 'block';
		StopTimer();
   }
   
   
   timerID = setTimeout("UpdateTimer()", 1000);
}

function StartTimer() {
   tStart   = new Date();

   timerID  = setTimeout("UpdateTimer()", 1000);
}

function StopTimer() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function ResetTimer() {
   tStart = null;

   return "00:00";
}


function GetScrollerPosition()
{
	var scrollY;
	
	/*if (document.all)
	{
		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop;
	}   
	else
	{
		scrollY = window.pageYOffset;
	}*/

	if (self.pageYOffset) {
		scrollY = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		scrollY = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		scrollY = document.body.scrollTop;
	}
	
	document.getElementById("YPos").value = scrollY;
}

function SetOverMenuItem(obj)
{
	obj.className = 'selected pointer';
}

function SetOutMenuItem(obj)
{
	obj.className = 'default';
}

function setValue(source,dest,img)
	{		    
		var s = source.value;
		var l = s.lastIndexOf('\\');
		if (l == -1)
			l = s.lastIndexOf('/');
		if (img !=null)	document.getElementById(runEnvironment + img).src = $('#' + runEnvironment + 'lblUploadOn').text(); //'../../images/btnupload_on.png'; 
		var file = s.substr(l+1);
		if (file.length > 26)
			document.getElementById(dest).innerHTML = file.substr(0,22) + " ...";
		else
			document.getElementById(dest).innerHTML = file;
		
	}

fe= true;
u=document;

function show(id,valuetxt)
{
    u.getElementById(id).value = valuetxt;
    setPlan(id);
}

function setPlan(id)
{
    u.getElementById(runEnvironment + "txtClientTypePlanID").value = id;
}

function setPlanSelected()
{
    var radios=u.getElementsByName('rdPlan');
    
    if(radios!=null)
    {
        u.getElementById(radios[0].id).checked=fe;
        document.getElementById(runEnvironment + "txtClientTypePlanID").value =radios[0].id ;
    }
}

function cleanSkypePlugin()
{
    window.setTimeout(function() {
			$('.skype_pnh_container').html('');
			$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
		}, 800);
}
