﻿function ChangeCursorStyleWait(obj)
{  
  if(obj)
  {
    // if enable control
    if(!obj.disabled && obj.style.display!='none')
    {
      ResetCursorStyle(false);
      setTimeout('ResetCursorStyle(true)',2000);
    }
  }    
}

function ResetCursorStyle(valBool)
{  
  if (valBool)
  {
    window.document.body.style.cursor='default';    
  }
  else
  {
    window.document.body.style.cursor='wait';    
  }
}

function hidediv(id) {
	if (document.getElementById) 
	{
	  var elm = document.getElementById(id);
	  if (elm)
	  {
		  elm.style.display = 'none';
		}
	}
	else
	{
		if (document.layers) 
		{
		  if (document.id)
		  {
			  document.id.display = 'none';
			}
		}
		else 
		{
		  if (document.all.id)
		  {
			  document.all.id.style.display = 'none';
			}
		}
	}
}

function showdiv(id) {
	if (document.getElementById) 
	{
	  var elm = document.getElementById(id);
	  if(elm)
	  {
		  elm.style.display = 'block';
	  }
	}
	else
	{
		if (document.layers) 
		{
		  if (document.id)
		  {
			  document.id.display = 'block';
			}
		}
		else 
		{
		  if (document.all.id)
		  {
			  document.all.id.style.display = 'block';
			}
		}
	}
}

function showvalidator(show)
{    
  if(show)
  {    
    showdiv("space");
    showdiv("LabelSelProd");
  }
  else
  {
    hidediv("space");
    hidediv("LabelSelProd");
  }
}

function IfSelectedProduct()
{
    var listProducts = document.getElementById("DropDownListProducts")
    if(listProducts)
    {
        if(listProducts.options.length > 1)
        {
            if( listProducts.options[0].selected )
            {
                showvalidator(true);
                return false;
            }
        }
    }
    
    return true;
}

function ForgotPasswordCall()
{
  if (!IfSelectedProduct())
  {
    return false;
  }
  
  var listProducts = document.getElementById("DropDownListProducts");
  if(listProducts && listProducts.options.length == 1)
  {
    window.open('http://www.upbill.com/','_blank');
    return false;
  }
  
  return true;
}

function DownloadLinkCall()
{
  if (!IfSelectedProduct())
  {
    return;
  }

  var listProducts = document.getElementById("DropDownListProducts");
  if(listProducts)
  {
    var downloadLinkGuid = listProducts.options[listProducts.selectedIndex].getAttribute('downloadLinkGuid');
    if(downloadLinkGuid && downloadLinkGuid != '')
    {
      var url = 'http://download.upclick.com/download.aspx?id=' + downloadLinkGuid;
      window.open(url, '_blank');
    }        
  }
  
  return;
}
