﻿// JScript File

function PrintEventInfo(divID)
{
    //alert('hi');
    var gAutoPrint = true;

    if (document.getElementById != null)
    {
        var html = '<HTML>\n<HEAD>\n';

        //html += '<link href="../css/Admin.css" type="text/css" rel="stylesheet">';
        //html += '<link href="../css/AdminRegistration.css" type="text/css" rel="stylesheet">'
    
        if (document.getElementsByTagName != null)
        {
            var headTags = document.getElementsByTagName("head");
            if (headTags.length > 0)
                html += headTags[0].innerHTML;
        }

        html += '\n</HEAD>\n<BODY>\n';

        //var printReadyElem = document.getElementById("PrintEvent");
        var printReadyElem = document.getElementById(divID);


        if (printReadyElem != null)
        {
            html += printReadyElem.innerHTML;            
        }
        else
        {
            alert("Could not find the printReady function");
            return false;
        }

        html += '\n</BODY>\n</HTML>';

        var printWin = window.open("#","printSpecial",'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=300,top=150,left=300');
        printWin.document.open();
        printWin.document.write(html);
        printWin.document.close();
        if (gAutoPrint)
        {
            printWin.print();
        }           
        
    }
    else
    {
        alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
        return false;
    }
}

function getPrint(divID)
{	
    window.open('RMC/Admin/PrintWindow.aspx?divID='+divID,'Print','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=300,top=150,left=300'); 
}	

function DisableEnableLinks(xHow){
  objLinks = document.getElementById("print_content1").getElementsByTagName(A); 
  for(i=0;i<objLinks.length;i++){
    objLinks[i].disabled = xHow;
    //link with onclick
    if(objLinks[i].onclick && xHow){  
        objLinks[i].onclick = new Function("return false;" + objLinks[i].onclick.toString().getFuncBody());
    }
    //link without onclick
    else if(xHow){  
      objLinks[i].onclick = function(){return false;}
    }
    //remove return false with link without onclick
    else if(!xHow && objLinks[i].onclick.toString().indexOf("function(){return false;}") != -1){            
      objLinks[i].onclick = null;
    }
    //remove return false link with onclick
    else if(!xHow && objLinks[i].onclick.toString().indexOf("return false;") != -1){  
      strClick = objLinks[i].onclick.toString().getFuncBody().replace("return false;","")
      objLinks[i].onclick = new Function(strClick);
    }
  }
}

String.prototype.getFuncBody = function(){ 
  var str=this.toString(); 
  str=str.replace(/[^{]+{/,"");
  str=str.substring(0,str.length-1);   
  str = str.replace(/\n/gi,"");
  if(!str.match(/\(.*\)/gi))str += ")";
  return str; 
}

