var preloadFlag = false;

function preloadImages() 
{
  if (document.images) 
  {
    preloadFlag = true;
  }
}

function changeImages() 
{
  if  (document.images && (preloadFlag == true)) 
  {
    for (var i=0; i<changeImages.arguments.length; i+=2) 
    {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

function confirm_del() {
  var reply = confirm("This will permanantly delete this record! You can't restore it in future.");

  if (reply) {
     return true;
  } else {
     return false;
  }
}

function popUpImgFront(url_front, pageWidth, pageHeight, title)
{
    var args = "width=" + (pageWidth + 20) + ",height=" + (pageHeight + 10) + "";
    var date = new Date();
    var now = date.getTime();
    var name = (now).toString(10);
    _w = window.open('',name,args);
    _w.document.open();
    _w.document.write("<html>\n<head><title>" + title + "</title>\n");
    _w.document.write("<meta http-equiv='imagetoolbar' content='no'>\n");
    _w.document.write("<link href='screen.css' type='text/css' rel='stylesheet'  media='screen' />\n");
    _w.document.write("<script language='javascript'><!--\n");
    _w.document.write("var i=0 , preloadFl=false;\n");
    _w.document.write("function resize() {\n");
    _w.document.write("if (navigator.appName == 'Netscape') i=40;\n");
    _w.document.write("if (document.images[0]) window.resizeTo(document.images[0].width +80, document.images[0].height+170);\n");
    _w.document.write("self.focus();\n");
    _w.document.write("preloadFl = true;}\n");
    _w.document.write("function changeImages() \n");
    _w.document.write("{\n");
    _w.document.write("  if (document.images && (preloadFl == true))");
    _w.document.write("  {\n");
    _w.document.write("  for (var i=0; i<changeImages.arguments.length; i+=2)");
    _w.document.write("    {\n");
    _w.document.write("     document[changeImages.arguments[i]].src = changeImages.arguments[i+1];\n");
    _w.document.write("    }\n");
    _w.document.write("  }\n");
    _w.document.write("}\n");
    _w.document.write("//--></script></head>\n");
    _w.document.write("<body onload='resize();'>\n");
    _w.document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0' style='height: 100%'>\n");
    _w.document.write("<tr>\n<td align='center' valign='middle'>\n");
    _w.document.write("<a><img src='" + url_front + "' alt='Click to close' border='1' name='title_image'></a>\n");
   _w.document.write("</td></tr>\n");
    _w.document.write("<tr><td align='center'><a onclick=\"javascript:window.close();\" href='#' class='white'><img src=\"images/buttons/close.gif\" border=\"0\"></a></td></tr></table>\n");
    _w.document.write("</body>\n</html>");
    _w.document.close();
}
function popUpImg(url_front, url_back, pageWidth, pageHeight, title) {
    var args = "width=" + (pageWidth + 20) + ",height=" + (pageHeight + 10) + "";
    var date = new Date();
    var now = date.getTime();
    var name = (now).toString(10);
    _w = window.open('',name,args);
    _w.document.open();
    _w.document.write("<html>\n<head><title>" + title + "</title>\n");
    _w.document.write("<meta http-equiv='imagetoolbar' content='no'>\n");
    _w.document.write("<link href='screen.css' type='text/css' rel='stylesheet'  media='screen' />\n");
    _w.document.write("<script language='javascript'><!--\n");
    _w.document.write("var i=0 , preloadFl=false;\n");
    _w.document.write("function resize() {\n");
    _w.document.write("if (navigator.appName == 'Netscape') i=40;\n");
    _w.document.write("if (document.images[0]) window.resizeTo(document.images[0].width +80, document.images[0].height+170);\n");
    _w.document.write("self.focus();\n");
    _w.document.write("preloadFl = true;}\n");
    _w.document.write("function changeImages() \n");
    _w.document.write("{\n");
    _w.document.write("  if (document.images && (preloadFl == true))");
    _w.document.write("  {\n");
    _w.document.write("  for (var i=0; i<changeImages.arguments.length; i+=2)");
    _w.document.write("    {\n");
    _w.document.write("     document[changeImages.arguments[i]].src = changeImages.arguments[i+1];\n");
    _w.document.write("    }\n");
    _w.document.write("  }\n");
    _w.document.write("}\n");
    _w.document.write("//--></script></head>\n");
    _w.document.write("<body onload='resize();'>\n");
    _w.document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0' style='height: 100%'>\n");
    _w.document.write("<tr>\n<td align='center' valign='middle'>\n");
    _w.document.write("<a onmouseout=\"changeImages('title_image','"+url_front+"'); window.status=''; return true;\"\n");
    _w.document.write("  onmouseover=\"changeImages('title_image','"+url_back+"'); window.status='Remove Cursor from Image to View Front'; return true;\">");
    _w.document.write("<img src='" + url_front + "' alt='Click to close' border='1' name='title_image'></a>\n");
   _w.document.write("</td></tr>\n");
    _w.document.write("<tr><td align='center'><a onclick=\"javascript:window.close();\" href='#' class='white'><img src=\"images/buttons/close.gif\" border=\"0\"></a></td></tr></table>\n");
    _w.document.write("</body>\n</html>");
    _w.document.close();
}
                                                

opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
ie = (document.all && !opera)? true : false;
dom = (document.getElementById && !ie && !opera)? true : false;

var expiration = new Date();
expiration.setTime(expiration.getTime() + 3600*3600*3600);



function doPreview(param1, param2) {

  if (dom) {
    var src = document.getElementById(param1).value; 
  } else if (ie) {
    var src = document.all[param1].value; 
  }

  if (src.charAt(1)==":") src = "file:/" + src;

  if (dom) {
    document.getElementById(param2).src=src; 
  } else if (ie) {
    document.all[param2].src = src; 
  }
 
}



function showtranscript(elemId,displayValue) {
  if (dom) {

      if (displayValue) {
         document.getElementById(elemId).style.display = displayValue;
         return 0;
      }

      if (document.getElementById(elemId).style.display == "none") {
         document.getElementById(elemId).style.display = "block";
      } else if (document.getElementById(elemId).style.display == "block") {
         document.getElementById(elemId).style.display = "none";
      } 
      
  } else if (ie) {
     if (displayValue) {
        document.all[elemId].style.display =  displayValue;
        return 0;
     }

     if (document.all[elemId].style.display == "block") {
        document.all[elemId].style.display = "none";
     } else if (document.all[elemId].style.display == "none") {
       document.all[elemId].style.display = "block";
     }
  }

}

function display(cookie_name, id) {
    var template_category_cookie;

    template_category_cookie = GetCookie(cookie_name);

    if (template_category_cookie) {
       SetCookie(cookie_name, "1", expiration, "", "","") 
       showtranscript(id, 'block');
    } else {
       SetCookie(cookie_name, "", expiration, "", "","") 
       showtranscript(id, 'none');
    }

    return true;                            
}


function onCookieChange(cookie_name, id) {
 
  if (dom) {
      if (document.getElementById(id).style.display == "none") {
         SetCookie(cookie_name, "", expiration, "", "","") 
      } else if (document.getElementById(id).style.display == "block") {
         SetCookie(cookie_name, "1", expiration, "", "","") 
      } 
      
  } else if (ie) {

    if (document.all[id].style.display == "block") {
       SetCookie(cookie_name, "1", expiration, "", "","") 
    } else if (document.all[id].style.display == "none") {
       SetCookie(cookie_name, "", expiration, "", "","") 
    }

  }
}


function SetCookie(name, value, expires, path, domain, secure) { 

   var mycookie = name + "=" + escape(value);
   var myexpires = new Date();
   myexpires.setTime(myexpires.getTime() + 5000);
   mycookie = mycookie + "; myexpires=" + myexpires.toGMTString();
   document.cookie = mycookie;
}


function GetCookie(name) { 
   var arg = name + "="; 
   var alen = arg.length; 
   var clen = document.cookie.length; 
   var i = 0; 

   while (i < clen) { 
     var j = i + alen; 
     if (document.cookie.substring(i, j) == arg)  return getCookieVal (j); 
     i = document.cookie.indexOf(" ", i) + 1; 
     if (i == 0) break; 
   }
    
   return null; 
} 


function getCookieVal (offset) { 
  var endstr = document.cookie.indexOf (";", offset); 
  if (endstr == -1) endstr = document.cookie.length; 
   return unescape(document.cookie.substring(offset, endstr)); 
} 

function price(){
//alert(document.getElementById("etat_dossier").value);

var id_price = document.getElementById("etat_dossier").value;
p = document.getElementById("id_"+id_price).value;
document.getElementById("price").value=p;

}