﻿// JScript File
var req1;
function callfunc(proid,varid)
{
  var url = "addtocart.aspx?ProductID="+proid+"&VariantID="+varid+"&template=empty";
  showdiv();
  show_hide_box(url, 770, 540, '1px solid','addtocart');
}

var req2;
function sendmail(parameter)
{
  var url = "EmailCourse.aspx";
    if (window.XMLHttpRequest) {
       req2 = new XMLHttpRequest();
       
   } else if (window.ActiveXObject) {
       req2 = new ActiveXObject("Microsoft.XMLHTTP");
   }
   document.body.style.cursor='wait';
   req2.open("POST", url, true);
   req2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   req2.setRequestHeader("Content-length", parameter.length);
   req2.setRequestHeader("Connection", "close");
   req2.onreadystatechange = function(){ if (req2.readyState == 4) if (req2.status == 200) { alert("Mail Sent"); document.body.style.cursor='auto';}}
   req2.send(parameter);
}

function getmail() {
var sendto=document.getElementById('SendTo');
var sendfrom=document.getElementById('SendFrom');
var txtMsg=document.getElementById('txtMsg');
if(sendto.value.length==0)
{
alert('Please enter email in To field');
sendto.focus();
return false;
}
if(!EmailCheck(sendto.value))
{
sendto.focus();
return false;
}
if(sendfrom.value.length==0)
{
alert('Please enter email in From field');
sendfrom.focus();
return false;
}
if(!EmailCheck(sendfrom.value))
{
sendfrom.focus();
return false;
}
if(txtMsg.value.length==0)
{
alert('Please enter Message');
txtMsg.focus();
return false;
}
if (txtMsg.value.length > 0 )
{
    var strMsg = txtMsg.value;
   
    if ((strMsg.indexOf("<") > 0) || (strMsg.indexOf(">") > 0))
    {
        alert("Characters < or > are not allowed in the message");
        txtMsg.focus();
        return false;
    }   
}

var subject=document.getElementById('Subject');

if (document.getElementById('filename')!=null)
{
      var poststr = "Subject=" + encodeURIComponent( document.getElementById('Subject').value ) +
                    "&SendTo=" + encodeURIComponent( sendto.value ) +
                    "&SendFrom=" + encodeURIComponent( sendfrom.value ) +
                    "&txtMsg=" + encodeURIComponent( txtMsg.value ) +
                    "&cbattach=" + document.getElementById("cbattach").checked +
                    "&filename=" + encodeURIComponent(document.getElementById('filename').value);
}
else
{
    var poststr = "Subject=" + encodeURIComponent( document.getElementById('Subject').value ) +
    "&SendTo=" + encodeURIComponent( sendto.value ) +
    "&SendFrom=" + encodeURIComponent( sendfrom.value ) +
    "&txtMsg=" + encodeURIComponent( txtMsg.value ) +
    "&cbattach=" + document.getElementById("cbattach").checked    ;
}
    //alert(poststr);
      sendmail(poststr);
   }
function getCormail() {
var sendto=document.getElementById('CorSendTo');
var sendfrom=document.getElementById('CorSendFrom');
var txtMsg=document.getElementById('CortxtMsg');
if(sendfrom.value.length==0)
{
alert('Please enter email in From field');
sendfrom.focus();
return false;
}
if(!EmailCheck(sendfrom.value))
{
sendfrom.focus();
return false;
}
if(txtMsg.value.length==0)
{
alert('Please enter Message');
txtMsg.focus();
return false;
}
 var strMsg = txtMsg.value;
   
    if ((strMsg.indexOf("<") > 0) || (strMsg.indexOf(">") > 0))
    {
        alert("Characters < or > are not allowed in the message");
        txtMsg.focus();
        return false;
    }
    
      var poststr = "Subject=" + encodeURIComponent( document.getElementById('CorSubject').value ) +
                    "&SendTo=" + encodeURIComponent( sendto.value ) +
                    "&SendFrom=" + encodeURIComponent( sendfrom.value ) +
                    "&txtMsg=" + encodeURIComponent( txtMsg.value ) +
                    "&cbattach=false";
      sendmail(poststr);
   }

function EmailCheck(str)
   {
    var at="@";
    var dot="."; 
    var lat=str.indexOf(at);
    var lstr=str.length;
    var ldot=str.indexOf (dot); 
    if (str.indexOf(at)==-1)
    {
        alert("Invalid E-mail ID");
        return false;
    }
    if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
        alert ("Invalid E-mail ID"); 
        return false;
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
        alert("Invalid E-mail ID"); 
        return false;
    }
    if (str.indexOf(at,(lat+1))!=-1)
    {
        alert("Invalid E-mail ID");
        return false;
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert ("Invalid E-mail ID");
      return false;
    }
    if (str.indexOf(dot,(lat+2))==-1)
    {
      alert("Invalid E-mail ID"); 
      return false;
    }
    if (str.indexOf(" ")!=-1)
    {
      alert("Invalid  E-mail ID");
      return false;
    }
    return true;
  }

function addtocart(pid)
{
var divname="regtnover"+pid;
 var rbname=eval('document.course.rb'+pid);
 var vid=getCheckedValue(rbname);
   if(vid=="")
    {
     alert("Please select any one course");
     return false;
    }
   else
    {
    var hdfield=eval('document.course.hd'+pid+''+vid);
    //alert(hdfield.value);
    if(hdfield.value==1)
     {
      alert('Sorry! You can not register for this course. This course is already started');
      return false;   
     }
     else
     {
      callfunc(pid,vid);
      MM_showHideLayers(divname,'','hide');
      return false;
     }
    }
 return false;
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) 
{
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
    else
        return "";
    for(var i = 0; i < radioLength; i++) 
    {
       if(radioObj[i].checked) 
       {
        return radioObj[i].value;
       }
    }
    return "";
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
   
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; }}
}


 function HideAllDiv()
          {
          var count=document.getElementById('divno').value;
          for(i=1;i<=count;i++)
              {
              var divname="regtnover"+i;
              var divname2="regtn"+i;
              document.getElementById(divname2).style.zIndex = 0;
              MM_showHideLayers(divname,'','hide');
              }
          return true;
          }
          
//           function setzindex()
//          {
//          var count=document.getElementById('divno').value;
//          for(i=1;i<=count;i++)
//              {
//              var divname="regtn"+i;
//               document.getElementById(divname).style.zIndex = 10000-i;
//               alert(document.getElementById(divname).style.zIndex);
//              }
//          
//          }

function changeclass(x)
{
  var i=0;
  for(i=1;i<=5;i++)
    {
    var tab=eval('document.getElementById("tab'+i+'")');
    var div=eval('document.getElementById("div'+i+'")');
     if(i==x)
     {
        tab.className='tabselect';
        div.style.display='';
     }
     else
     {
        tab.className='tabunselect';
        div.style.display='none';
     }
    }
}

function changeclassHome(x)
{
  var i=0;
  for(i=1;i<=5;i++)
    {
    var tab=eval('document.getElementById("tab'+i+'")');
    var div=eval('document.getElementById("div'+i+'")');
     if(i==1)
     {
         if(i==x)
         {
            tab.className='selfst';
            div.style.display='';
         }
         else
         {
            tab.className='selfstd';
            div.style.display='none';
         }
     }
     else
     {
         if(i==x)
         {
            tab.className='sel';
            div.style.display='';
         }
         else
         {
            tab.className='unsel';
            div.style.display='none';
         }
     }
    }
}

function canvasHeight()
    {
     var scnHei;
     if (document.body) // other Explorers
	    {
		    scnHei = document.body.scrollHeight;
	    }  
	     else if (document.documentElement && document.documentElement.clientHeight)
		    // Explorer 6 Strict Mode
	    {
		    scnHei = document.documentElement.scrollHeight;
	    }
	    else if (self.innerHeight) // all except Explorer
	    {
		    scnHei = self.scrollHeight;
	    }
	    
      return scnHei;
   }  
    
    
    function canvasHeight1()
    {
      if (window.innerHeight != null)
        return window.innerHeight;
      if (document.body.clientHeight != null)
        return document.body.clientHeight;
      return null;     
    }
    
    function canvasWidth()
    {
      if (window.innerWidth != null)
        return window.innerWidth;
      if (document.body.clientWidth != null)
        return document.body.clientWidth;
      return null;     
    }  

function showdiv()
{
document.getElementById('toptd').focus();
window.location.href="#";
//document.getElementById('Layer4').style.height='auto';
document.documentElement.style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
document.getElementById('Layer4').style.height=canvasHeight();
document.getElementById('Layer4').style.width=canvasWidth();
//document.getElementById('myimg').style.height=canvasHeight();
//document.getElementById('myimg').style.width=canvasWidth();
}

function hidediv()
{
document.getElementById('Layer4').style.height='0';
document.documentElement.style.overflow = '';
document.body.style.overflow = '';
document.getElementById('myimg').style.height='0';
document.getElementById('myimg').style.width='0';
document.getElementById('Layer4').style.height='0';
document.getElementById('Layer4').style.width='0';
}


function move_box(an, box, w, h) {

//var deadlinks=document.getElementsByTagName("a");
//		for (var i=0;i<deadlinks.length;i++)
//		{
//					
//		        	alert(deadlinks[i].text);
//		    
//	    }

  box.style.left = (canvasWidth()-w)/2;
  box.style.top = (canvasHeight1()-h)/2;
  
  
}

function closediv(an, width, height, borderStyle, dynadiv)
{
    show_hide_box(an, width, height, borderStyle ,dynadiv)
    hidediv();
}

function show_hide_box(an, width, height, borderStyle,dynadiv) {
  var href = an;
  
  var boxdiv = document.getElementById('dynadiv');
  
  if (boxdiv != null) {
      if (boxdiv.style.display=='none') {
      move_box(an, boxdiv, width, height);
        boxdiv.style.width = width + 'px';
        boxdiv.style.height = height + 'px';
      boxdiv.style.display='block';
      document.getElementById('myframe').src=href;
       document.getElementById('dynatable').style.width = width + 'px';
       document.getElementById('myframe').style.width = width + 'px';
        document.getElementById('myframe').style.height = parseInt(height)-parseInt(25) + 'px';
    } else
      boxdiv.style.display='none';
    return false;
  }

  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', 'dynadiv');
  boxdiv.style.display = 'block';
  boxdiv.style.zIndex = 10000;
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = 'firebrick 1px solid';
  boxdiv.style.backgroundColor = '#FFF';
  boxdiv.innerHTML="<table id='dynatable' width='"+width+"'><tr valign='middle'><td align='right'><a href='javascript:void(0);' class='btnpointer' style=\"color:#650101;\" onclick='closediv(\""+an+"\","+ width+","+ height+",\""+ borderStyle+"\",\""+dynadiv+"\");parent.location.reload();'>Close</a>&nbsp;<img src='skins/skin_1/images/btn-close3.gif' align='absmiddle' class='btnpointer' onclick='closediv(\""+an+"\","+ width+","+ height+",\""+ borderStyle+"\",\""+dynadiv+"\");parent.location.reload();' /></td></tr></table>";
  //var contents1  = document.createElement();
  var contents = document.createElement('iframe');
  contents.id = 'myframe';
  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = parseInt(height)-parseInt(25) + 'px';
  contents.src = href;
  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_box(an, boxdiv, width, height);

  return false;
}
var req3;
function addbyExpReg(ProgCode)
{
 var url = "ExpReg.aspx?ProgCode="+ProgCode;
 if (window.XMLHttpRequest) {
       req3 = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
       req3 = new ActiveXObject("Microsoft.XMLHTTP");
   }
   document.body.style.cursor='wait';
   req3.open("GET", url, true);
   req3.onreadystatechange = function()
   { 
    if (req3.readyState == 4) 
    if (req3.status == 200) 
    { 
        var respo=req3.getResponseHeader('result');
        if(respo.substring(0,4)=='res=')
        {
            var arr=Trim(respo.substr(4)).split(',');
            MM_showHideLayers('expregdiv','','hide');
            if(arr[2] == '')
            {
                callfunc(arr[0],arr[1]);
            }
            else
            {
                callcertfunc(arr[0],arr[1],arr[2],arr[3]);
            }   
        }
        else
        {
            alert(respo);
            document.getElementById('ProgCode').focus(); 
        }
        document.body.style.cursor='auto';
    }
    else {
            alert('There was a problem with the request. (Code: ' + req3.status + ')');
            document.body.style.cursor='auto';
            document.getElementById('ProgCode').focus();
         }
   }
   req3.send(null);
}

function put_commas(input) 
{
    var result, len;
    input += "";

    // Locate the decimal point if any.
    len = input.indexOf(".");
    if (len == -1) 
    {
        len = input.length;
        result = "";
    } 
    else 
    {
        result = input.substring(len, input.length);
    }

    // 3 characters at a time through the integer portion.
    while (len > 3) 
    {
        result = input.substring(len-3, len) + result;
        result = "," + result;
        len -= 3;
    }

    // Add any remaining characters.
    result = input.substring(0, len) + result;
    return result;
}


// Script for Certificate Added by Adnan on 03-March-2008
var chkCount = 0;
function CountCheck(ctrlChkid)
{
    var tmpCount = 0;
    for(i = 0; i < document.form1.elements.length; i++)
    {
        var elem=document.form1.elements[i];
        if(elem.type == 'checkbox' && elem.name == ctrlChkid && elem.checked)
        {
            tmpCount++;
        }
    }
    chkCount = tmpCount;
} 

function ChkReqNumber()
{
    var reqNum = parseInt(document.getElementById('ReqNum').value);
    var reqC = parseInt(document.getElementById('ReqC').value);
    var optC = parseInt(document.getElementById('OptC').value);
    var arrRPids = new Array();
    var arrOPIds = new Array();
    var trPids = document.getElementById('hrPids').value;
    var toPids = document.getElementById('hoPids').value;
    
    arrRPids = trPids.split(",");
    arrOPids = toPids.split(",");
    
    document.getElementById('hrVids').value = "";
    document.getElementById('hoVids').value = "";
    
    if(reqC != 0)
    {
        
        for(i = 0; i < arrRPids.length; i++)
        {
            var temp = addcerttocart(arrRPids[i],'required');
            if(temp == "Error")
            {
                return false;
            }
            else if(temp != "")
            {
                document.getElementById('hrVids').value += "," + temp;
            }
        }
        if(document.getElementById('hrVids').value != "")
        {
            document.getElementById('hrVids').value = document.getElementById('hrVids').value.substring(1,document.getElementById('hrVids').value.length);
        }
    }
//    if((reqC + chkCount) != reqNum)
//    {
//        alert("Please select " + (reqNum - reqC) + " Elective Courses");
//        return false;
//    }

    if(optC != 0)
    {
        for(i = 0; i < arrOPids.length; i++)
        {
            for(j = 0; j < document.form1.elements.length; j++)
            {
                var elem=document.form1.elements[j];
                if(elem.type == 'checkbox' && elem.value == arrOPids[i] && elem.checked)
                {
                    var temp = addcerttocart(arrOPids[i],'optional');
                    if(temp == "Error")
                    {
                        return false;
                    }
                    else if(temp != "")
                    {
                        document.getElementById('hoVids').value += "," + temp;
                    }
                    else
                    {
                        alert("Please select the session for selected Elective Course");
                        return false;
                    }
                }
            }
        }
        if(document.getElementById('hoVids').value != "")
        {
            document.getElementById('hoVids').value = document.getElementById('hoVids').value.substring(1,document.getElementById('hoVids').value.length);
        }
    }
    if(document.getElementById('hrVids').value == "" && document.getElementById('hoVids').value == "")
    {
        alert("Please select any one course");
        return false;
    }
    return true;
}

function addcerttocart(pid,ctype)
{
    var rbname=eval('document.form1.rb'+pid);
    var vid=getCheckedValue(rbname);
//    if(vid=="")
//    {
//        if(ctype == "required")
//        {
//            alert("Please select dates for all the Required courses");
//        }
//        else
//        {
//            alert("Please select dates for selected Elective courses");
//        }
//        return "Error";
//    }
    if(vid!="")
    {
        var hdfield=eval('document.form1.hd'+pid+''+vid);
        if(hdfield.value==1)
        {
            alert('Sorry! You can not register for this course. This course is already started');
            return "Error";   
        }
    }
    return vid;

}

function callcertCheck()
{
    if(ChkReqNumber())
    {
        callcertfunc(document.getElementById('hPid').value,document.getElementById('hVid').value,"Certificate","0");
    }
    return false;
}

function callcertfunc(proid,varid,typ,cid)
{
    var url = "addtocart.aspx?ProductID=" + proid + "&VariantID=" + varid + "&template=empty&entityType=" + typ;
    if(typ=="Certificate")
    {
        url += "&reqVids=" + document.getElementById('hrVids').value + "&optVids=" + document.getElementById('hoVids').value;
        showdivCert();
        show_hide_boxCertificate(url, 770, 660, '1px solid','addtocart', typ);
    }
    else
    {
        url += "&certID=" + cid;
        showdivCert();
        show_hide_boxCertificate(url, 770, 540, '1px solid','addtocart', typ);
    }
    
}

//function added for ShowCertificate page by adnan 
function changeclass(x,y)
{
  var i=0;
  for(i=1;i<=y;i++)
    {
    var tab=eval('document.getElementById("tab'+i+'")');
    var div=eval('document.getElementById("div'+i+'")');
     if(i==x)
     {
        tab.className='tabselect';
        div.style.display='';
     }
     else
     {
        tab.className='tabunselect';
        div.style.display='none';
     }
    }
}

//code to hide or display course menu "Bug 1"
var secs
var timerID = null
var timerRunning = false
var delay = 500
var mouseover = false

function LnkMouseOver()
{
    mouseover = true
    MM_showHideLayers('Layer3','','show')
}
function InitializeTimer()
{
    // Set the length of the timer, in seconds
    mouseover = false
    secs = 1
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        if(!mouseover)
            MM_showHideLayers('Layer3','','hide');
        //alert("You have just wasted 3 seconds of your life.")
    }
    else
    {
        //self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

//added by adnan for 10dayCertificates
function add10DCerttocart(pid,cid)
{
    var divname="regtnover"+pid;
    var rbname=eval('document.course.rb'+pid);
    var vid=getCheckedValue(rbname);
    if(vid=="")
    {
        alert("Please select any one course");
        return false;
    }
    else
    {
        var hdfield=eval('document.course.hd'+pid+''+vid);
        //alert(hdfield.value);
        if(hdfield.value==1)
        {
            alert('Sorry! You can not register for this course. This course is already started');
            return false;   
        }
        else
        {
            callcertfunc(pid,vid,"10DayCert",cid);
            MM_showHideLayers(divname,'','hide');
            return false;
        }
    }
    return false;
}

//added by taher for radio check
function selectdeselect(ctrlChkid)
{
    var rbname = 'rb' + ctrlChkid.value;
    
    if(ctrlChkid.checked)
    {  
        for(j = 0; j < document.form1.elements.length; j++)
        {
             var rad=document.form1.elements[j];
             if(rad.type == 'radio' && rad.name == rbname)
             {
                 rad.checked=true;
                 break;
             }
    
        }
    }
    else
    {
        for(j = 0; j < document.form1.elements.length; j++)
        {
             var rad=document.form1.elements[j];
             if(rad.type == 'radio' && rad.name == rbname)
             {
                 rad.checked=false;
             }
    
        }
    }
    
    return false;
}

function RadioChk(ctrlChkid)
{
    var cname =ctrlChkid.name.substring(2,ctrlChkid.name.length);
    for(j = 0; j < document.form1.elements.length; j++)
    {
         var chkbox=document.form1.elements[j];
         if(chkbox.type == 'checkbox' && chkbox.name == 'chk' && chkbox.value == cname)
         {
            chkbox.checked = true;
         }
    }
    return false; 
}

//added by adnan for opening popup window
var win= null;
function NewWindow(mypage,myname,w,h,scroll)
{
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    var settings ='height='+h+',';
    settings +='width='+w+',';
    settings +='top='+wint+',';
    settings +='left='+winl+',';
    settings +='scrollbars='+scroll+',';
    settings +='resizable=no';
    win=window.open(mypage,myname,settings);
    if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
} 

//functions added by murtaza for AddtoCart Certificate Popup
function showdivCert(typ)
{
document.getElementById('toptd').focus();
window.location.href="#";
//document.getElementById('Layer4').style.height='auto';
if(typ == "10DayCert")
{
    document.documentElement.style.overflow = 'hidden';
    document.body.style.overflow = 'hidden';
}
document.getElementById('Layer4').style.height=canvasHeight();
document.getElementById('Layer4').style.width=canvasWidth();
//document.getElementById('myimg').style.height=canvasHeight();
//document.getElementById('myimg').style.width=canvasWidth();
}

function move_boxCert(an, box, w, h, ty) {

//var deadlinks=document.getElementsByTagName("a");
//		for (var i=0;i<deadlinks.length;i++)
//		{
//					
//		        	alert(deadlinks[i].text);
//		    
//	    }

  box.style.left = (canvasWidth()-w)/2;
  if(ty == "Certificate")
  {
    box.style.top = parseInt((canvasHeight1()-h)/2) + 50;
  }
  else
  {
    box.style.top = parseInt((canvasHeight1()-h)/2);
  }
  
  
}



function show_hide_boxCertificate(an, width, height, borderStyle, dynadiv, typ) {
  var href = an;
  
  var boxdiv = document.getElementById('dynadiv');
  
  if (boxdiv != null) {
      if (boxdiv.style.display=='none') {
      move_boxCert(an, boxdiv, width, height, typ);
        boxdiv.style.width = width + 'px';
        boxdiv.style.height = height + 'px';
      boxdiv.style.display='block';
      document.getElementById('myframe').src=href;
       document.getElementById('dynatable').style.width = width + 'px';
       document.getElementById('myframe').style.width = width + 'px';
        document.getElementById('myframe').style.height = parseInt(height)-parseInt(25) + 'px';
    } else
      boxdiv.style.display='none';
    return false;
  }

  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', 'dynadiv');
  boxdiv.style.display = 'block';
  boxdiv.style.zIndex = 10000;
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = 'firebrick 1px solid';
  boxdiv.style.backgroundColor = '#FFF';
  boxdiv.innerHTML="<table id='dynatable' width='"+width+"'><tr valign='middle'><td align='right'><a href='javascript:void(0);' class='btnpointer' style=\"color:#650101;\" onclick='closediv(\""+an+"\","+ width+","+ height+",\""+ borderStyle+"\",\""+dynadiv+"\");parent.location.reload();'>Close</a>&nbsp;<img src='skins/skin_1/images/btn-close3.gif' align='absmiddle' class='btnpointer' onclick='closediv(\""+an+"\","+ width+","+ height+",\""+ borderStyle+"\",\""+dynadiv+"\");parent.location.reload();' /></td></tr></table>";
  //var contents1  = document.createElement();
  var contents = document.createElement('iframe');
  contents.id = 'myframe';
  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = parseInt(height)-parseInt(25) + 'px';
  contents.src = href;
  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_boxCert(an, boxdiv, width, height, typ);

  return false;
}