function openRetrieve()
 {
    var popupWin = window.open("RetrievePassword.aspx", 'openRetrieve',' dependent, width=500, height=300')
 }
 
 
 function openEzineInfo(id)
 {
    var ezineId = document.getElementById(id);
 
    var popupWin = window.open("EzineInfoPopup.aspx?EzineId=" + ezineId.value, 'openEzineInfo','status, dependent, width=500, height=400');
    return false;
 }
 
 function openAdInvoiceInfo(id)
 {
    var adId = document.getElementById(id);
   
 
    var popupWin = window.open("AdInvoicePopup.aspx?AdId=" + adId.value, 'openAdInvoiceInfo','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openPendingEzineInfo(id)
 {
    var ezineId = document.getElementById(id);
 
    var popupWin = window.open("PendingEzinePopup.aspx?EzineId=" + ezineId.value, 'openEzineInfo','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openPendingPaymentInfo(id)
 {
    var paymentId = document.getElementById(id);
 
    var popupWin = window.open("PaymentInvoicePopup.aspx?PaymentId=" + paymentId.value, 'openPendPaymentInfo','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 
 function openAccountInfo(id)
 {
    var customerId = document.getElementById(id);
 
    var popupWin = window.open("AccountInfoPopup.aspx?CustomerId=" + customerId.value, 'openAccountInfo','status, dependent, width=500, height=500, resizable, scrollbars');
    return false;
 }
 
 function openPendingAds(id)
 {
    var adId = document.getElementById(id);
 
    var popupWin = window.open("PendingAdsPopup.aspx?adId=" + adId.value, 'openPendingAds','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openSubmittedAds(id)
 {
    var adId = document.getElementById(id);
 
    var popupWin = window.open("SubmittedAdsPopup.aspx?adId=" + adId.value, 'openSubmittedAds','status, dependent, width=500, height=550, resizable, scrollbars');
    return false;
 }
 
 function openAddEzine(id)
 {
     var customerId = document.getElementById(id);
 
    var popupWin = window.open("AddEzinePopup.aspx?CustomerId=" + customerId.value, 'openInsertEzine','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openEditEzine(id)
 {
     var ezineId = document.getElementById(id);
 
    var popupWin = window.open("EzineEditPopup.aspx?EzineId=" + ezineId.value, 'openEditEzine','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openSearchSales(id)
 {
     var customerId = document.getElementById(id);
 
    var popupWin = window.open("AffiliateSalesPopup.aspx?RefId=" + customerId.value, 'openSearchSales','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
  function openSearchPayment(id)
 {
     var customerId = document.getElementById(id);
 
    var popupWin = window.open("AffiliatePaymentPopup.aspx?RefId=" + customerId.value, 'openSearchPayment','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openContactPayment(id)
 {
     var customerId = document.getElementById(id);
 
    var popupWin = window.open("AffiliateContactPopup.aspx?CustomerId=" + customerId.value, 'openAffiliateContact','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openPayment(id)
 {
     var customerId = document.getElementById(id);
 
    var popupWin = window.open("RequestPaymentPopup.aspx?CustomerId=" + customerId.value, 'openPayment','status, dependent, width=500, height=750, resizable, scrollbars');
    return false;
 }
 
 function openAdvertise(id)
 {
     var customerId = document.getElementById(id);
 
    var popupWin = window.open("PromotionPopup.aspx?CustomerId=" + customerId.value, 'openPayment','status, dependent, width=620, height=750, resizable, scrollbars');
    return false;
 }
 
 function openFAQ()
 {
    var popupWin = window.open("FAQPopup.aspx", 'openFAQ','status, dependent, width=500, height=500, resizable, scrollbars');
 }
 
 
 function openRulesAd()
 {
    var popupWin = window.open("ProgramRulesPopup.aspx", 'openRulesAd','status, dependent, width=500, scrollbars, resizable');
 }
 
 function openRulesPub()
 {
    var popupWin = window.open("ProgramRulesPopup.aspx", 'openRulesPub','dependent, width=500, scrollbars, resizable');
 }
 
  function validateCheckBox(source, args)
  {
      var checkbox = document.getElementById('accept').getElementsByTagName('input');
      args.IsValid = document.getElementById(checkbox[0].id).checked;
  }
  
  function openTwitter()
 {
    
    var popupWin = window.open("http://Twitter.com/EzineAdTeam", 'openTwitter');
    
 }
 
 function disableValidator(val)
 {
    var enableRfv = document.getElementById(val);
    ValidatorEnable(enableRfv, false);
 }
 
 function ShowModal()
 {
    $find('ctl00_cphMaster_mb').show()
      //document.getElementById(modal).show();
//    $object('modal').show();
    
    //var modalPopupBehave = $find('modal');
    //$find('modalShow').show();
    //window.setTimeout("modal.show();", 1000);
 }
 
  function openAutoPanel(cbx, panel, rfv, subEmail, subSub)
 {
     var checkbox = document.getElementById(cbx);
     var showPanel = document.getElementById(panel);
     var enableRfv = document.getElementById(rfv);
     var subEmailText = document.getElementById(subEmail);
     var subSubText = document.getElementById(subSub);
     
     if(checkbox.checked)
     {
        showPanel.style.display = 'block';
        ValidatorEnable(enableRfv, true);
     }
     else
     {
        showPanel.style.display = 'none';
        ValidatorEnable(enableRfv, false);
        subEmailText.value = "";
        subSubText.value = "";
     }
 }

function validateCheckBoxList(source, args)
  {
       var checkbox = document.getElementById('accept').getElementsByTagName('input');
        args.IsValid =false;
        var total = 0;
        
        for(i=0;i<checkbox.length;i++)
        {
            var opt = checkbox[i];
            if(opt.type=="checkbox")
            {
                if(opt.checked)
                {
                    total = total + 1;
                }
            } 
        }
         if(total>0 && total<4)
            {
                args.IsValid = true;
            }    
  }
  
  function addUpgrade(silver, gold, platinum, totalLable, totalBox, totalNew)
  {
    var silverTotal = document.getElementById(silver);
    var goldTotal = document.getElementById(gold);
    var platinumTotal = document.getElementById(platinum);
    var totalOrigL = document.getElementById(totalLable);
    var totalOrigB = document.getElementById(totalBox);
    var totalNewB = document.getElementById(totalNew);
    
    if(silverTotal.checked)
    {
        var totalTrim = totalOrigB.value.toString().replace(/\$|\,/g,'');
        totalOrigL.innerHTML = "$" + (Number(4.95) + Number(totalTrim)).toFixed(2);
        totalNewB.value = "$" + (Number(4.95) + Number(totalTrim)).toFixed(2);
        //totalOrigB.value = "$" + (Number(4.95) + Number(totalTrim)).toFixed(2);
    }
    else if(goldTotal.checked)
    {
        var totalTrim = totalOrigB.value.toString().replace(/\$|\,/g,'');
        totalOrigL.innerHTML = "$" + (Number(9.95) + Number(totalTrim)).toFixed(2);
        totalNewB.value = "$" + (Number(9.95) + Number(totalTrim)).toFixed(2);
        //totalOrigB.value = "$" + (Number(9.95) + Number(totalTrim)).toFixed(2);
    }
    else if(platinumTotal.checked)
    {
        var totalTrim = totalOrigB.value.toString().replace(/\$|\,/g,'');
        totalOrigL.innerHTML = "$" + (Number(12.95) + Number(totalTrim)).toFixed(2);
        totalNewB.value = "$" + (Number(12.95) + Number(totalTrim)).toFixed(2);
        //totalOrigB.value = "$" + (Number(12.95) + Number(totalTrim)).toFixed(2);
    }
    else
    {
        //var totalTrim = totalOrigB.value.toString().replace(/\$|\,/g,'');
        totalOrigL.innerHTML = totalOrigB.value;
        totalNewB.value = totalOrigB.value;
        //totalOrigB.value = "$" + (Number(totalTrim)).toFixed(2);
    }
  }
  
//  function clipBoard(textbox)
//{
//    //event.returnValue = false;
////    var r = document.body.createTextRange();
//    var textBoxCopy = document.getElementById(textbox).innerText;
//    //r.findText(textBoxCopy);
//    var clip = window.clipboardData.setData("Text", textBoxCopy);
//    //r.select();
//}

function clipBoard(textbox)
 {
//    if (window.clipboardData) 
//    {
        var textBoxCopy = document.getElementById(textbox).select();
        //window.clipboardData.setData("Text",textBoxCopy);
        
    //} 
//  else 
//  {
//    var clipboarddiv=document.getElementById('divclipboardswf');  
//    if(clipboarddiv==null)  
//     {  
//     //alert('1');
//        clipboarddiv=document.createElement('div');  
//            clipboarddiv.setAttribute("name", "divclipboardswf");  
//        clipboarddiv.setAttribute("id", "divclipboardswf");  
//        document.body.appendChild(clipboarddiv);  
//     } 
//    //alert('2');
//         clipboarddiv.innerText='<embed src="_clipboard.swf" FlashVars="clipboard='+  
// encodeURIComponent(textBoxCopy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';  
//  }  
     //alert('The text is copied to your clipboard...');  
     return false;
}


var height = 4;
var rate = 0.3;
var interval = 20;
var timer = 0;

function toggleLoginVisibility()
{
	if(timer != 0) return;
	
	var loginForm = document.getElementById('login');
	
	if(loginForm.className == 'topFormShow')
	{
		var offH = loginForm.offsetHeight;
		loginForm.className = 'topFormHide';
		loginForm.style.height = offH+"px";
		height = 4;
	}
	else
	{
		height = loginForm.offsetHeight;
		height = 46;
		loginForm.style.height = 30+'px';
	}
	
	timer = window.setTimeout('transition()', interval);
}

function transition()
{
	var loginForm = document.getElementById('login');
	if(height < loginForm.offsetHeight)
	{
		var step = (loginForm.offsetHeight - height)*rate;
		if(step < 1) step = 1;
		loginForm.style.height = (loginForm.offsetHeight - step) + 'px';
		if(loginForm.offsetHeight < height)
			loginForm.style.height = height+'px';
			
		timer = window.setTimeout('transition()', interval);
	}
	else if(height > loginForm.offsetHeight)
	{
		var step = (height - loginForm.offsetHeight)*rate;
		if(step < 1) step = 1;
		loginForm.style.height = (loginForm.offsetHeight + step) + 'px';
		if(loginForm.offsetHeight > height)
			loginForm.style.height = height+"px";
			
		timer = window.setTimeout('transition()', interval);
	}
	else
	{
		if(loginForm.offsetHeight == 4)
			loginForm.className = 'topFormHide'
		else
		{
			loginForm.className = 'topFormShow';
			//document.getElementById('txtLoginUserName.ClientId').focus();
		}

		timer = 0;			
		loginForm.style.height="";
	}
}


function textCounter(field, countfield, maxlimit) 
{ 
    var box = document.getElementById(field); 
    var counter = document.getElementById(countfield); 
    
    if (box.value.length > maxlimit) 
    box.value = box.value.substring(0, maxlimit); 
    else 
    counter.value = maxlimit - box.value.length; 
    counter.innerHTML = counter.value; 
} 

//function calculateTotal(gridview, checkBox, numberOfSubs, sumTotal)
//{
//   var grid = document.getElementById(gridview);
//   var check = document.getElementById(checkBox);
//   var number = document.getElementById(numberOfSubs);
//   var numberVal = number.innerHTML.value;
//   var total = document.getElementById(sumTotal);
//   
//   var sum = 0;
//   
//   for(i=0; i< grid.rows.length; i++)
//   {
//        
//   }
//   if(check.checked)
//        {
//            sum = numberVal;
//        }
//   
// total.innerHTML = numberVal;
//}

//function SelectAll(id) 
//{
//    var frm = document.forms[0];

//    for (i=0;i<frm.elements.length;i++) 
//    {
//        if (frm.elements[i].type == "checkbox") 
//        {
//            frm.elements[i].checked = document.getElementById(id).checked;
//        }

//    }
// }  
 
// function calculateTotal(checkBox, costPer, sumTotal) 
//{
//    var frm = document.forms[0];
//    
//    var check = document.getElementById(checkBox);
//    var cost = document.getElementById(costPer).innerHTML.replace(/\$|\,/g,'');
//    var total = document.getElementById(sumTotal);
//    var sum = 0;
//    
//    for (i=0;i<frm.elements.length;i++) 
//    {
//        if (frm.elements[i].checked) 
//        {       
//              var newCost = frm.elements[i].;
//              sum += Number(newCost);
//        }
//    }
//    total.innerHTML = "$" + sum.toFixed(2);
// }  
 
 function calculateTotal(gridViewId, totalId, totalTopId, totalBox) 
{
    var gridView = document.getElementById(gridViewId);
    var total = document.getElementById(totalId);
    var totalTop = document.getElementById(totalTopId);
    var totalTxt = document.getElementById(totalBox);

    
    var cost;
    var sum = 0;
    
    if(gridView.rows.length > 0)
    {

        for(i=1; i<gridView.rows.length; i++)
        {
            var cell = gridView.rows[i].cells[1];
            
            for(j=0; j<cell.childNodes.length; j++)
            {
                if(cell.childNodes[j].checked)
                {
                    if(document.all)
                    {
                        var cost = gridView.rows[i].cells[4].innerText.replace(/\$|\,/g,'');
                    }
                    else
                    {
                        var cost = gridView.rows[i].cells[4].textContent.replace(/\$|\,/g,'');
                    }
                    sum += Number(cost);
                }
            }
       }
    }
          total.innerHTML = "$" + sum.toFixed(2);
          totalTop.innerHTML = "$" + sum.toFixed(2);
          totalTxt.value =  sum.toFixed(2);
          
}

 var timer=0;
 var currentSeconds=0;
 
 function countDown(timerLable, initalTime)
 {
    timer = document.getElementById(timerLable);
   
    setCounterText(initalTime);
    window.setTimeout('countDownTicker()', 1000);
 }
 
 function countDownTicker()
 {
    if(currentSeconds <= 0)
    return;
    
    setCounterText(currentSeconds - 1);
    window.setTimeout('countDownTicker()', 1000);
 }
 
 function setCounterText(seconds)
 {
    currentSeconds = seconds;
    
    var minutes = parseInt(seconds/60);
    seconds = (seconds%60);
    
    timer.innerHTML = minutes + ':' + addZero(seconds);
 }
 
 function addZero(num)
 {
    return ((num >= 0) && (num < 10)) ?'0'+ num:num +'';
 }


 function keepSessionAlive()
 {
    window.status = 'Session continued ...';
    var img = new Image(1,1);
    img.src = 'Reconnect.aspx';
 }

