var movieName = "mPreview";

function thisMovie(movieName) {
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window.ItemList[movieName];
  } else {
    return document[movieName];
  }
}

function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    return theMovie.PercentLoaded() == 100;
  } else {
    return false;
  }
}

function playmovie() {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).Play();
  }
   return true;
}

function stopmovie() {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).StopPlay();
  }
   return true;
}

function go(theFrame) {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).GotoFrame(theFrame);
  }
   return true;
}

function goPlay(theFrame) {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).GotoFrame(theFrame);
    thisMovie(movieName).Play();
  }
   return true;
}

function golabel() {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).TGotoLabel("_level0/","redframe");
  }
   return true;
}

function setVariable() {
    theValue = prompt ("Please entr a phrase:", "Macromedia");

    if (theValue!=null) {
                thisMovie(movieName).GotoFrame(1);
        thisMovie(movieName).SetVariable('tColor.text', '0xff0000');
        thisMovie(movieName).SetVariable('tFont.text', 'Windsor');
        thisMovie(movieName).SetVariable('tSize.text', '45');
        thisMovie(movieName).SetVariable('tText.text', theValue);
                thisMovie(movieName).GotoFrame(2);
    }
   return true;
}


function preview_custom(word, font, size, color) {

    if (!word) {
      alert("Please type the word");
      return 0;
    }

    if (color) {
       color = colors[color];
    } else if (!color) {
       color = "0xff0000";
    }

    if (!font) {
       font = 'Windsor';
    }

    if (size) {
       size = sizes[size];
    } else if (!size) {
       size = '45';
    }



    if (word!=null) {
       thisMovie(movieName).GotoFrame(1);

       thisMovie(movieName).SetVariable('tColor.text', color);
       thisMovie(movieName).SetVariable('tFont.text', font);
       thisMovie(movieName).SetVariable('tSize.text', size);
       thisMovie(movieName).SetVariable('tText.text', word);

       thisMovie(movieName).GotoFrame(2);
    }
   return true;
}


function preview_sign(word, font, color_bg, color_fg) {

    if (!word) {
      alert("Please type the word");
      return 0;
    }

    if (color_bg) {
       color_bg = background_colors[color_bg];
    } else if (!color_bg) {
       color_bg = "0xff0000";
    }

    if (color_fg) {
       color_fg = foregraund_colors[color_fg];
    } else if (!color_fg) {
       color_fg = "0xff0000";
    }

    if (!font) {
       font = 'Windsor';
    }

    size = '45';


    if (word!=null) {
       thisMovie(movieName).GotoFrame(1);

       thisMovie(movieName).SetVariable('tFont.text', font);
       thisMovie(movieName).SetVariable('tSize.text', size);
       thisMovie(movieName).SetVariable('tText.text', word);
       thisMovie(movieName).SetVariable('tColor.text', color_fg);
       thisMovie(movieName).SetVariable('tBg.text', color_bg);

       thisMovie(movieName).GotoFrame(2);
    }
   return true;
}











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 popUpImg(url, pageWidth, pageHeight) {
    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>\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;\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 +30, document.images[0].height+100-i);\n");
    _w.document.write("self.focus();\n");
    _w.document.write("}\n");
    _w.document.write("//--></script></head>\n");
    _w.document.write("<body onload='resize();' bgcolor='#B99898'>\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 href='javascript:window.close()'><img src='" + url + "' alt='Click to close' border='0' /></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();
   return true;
}
                                                



var opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
var ie = (document.all && !opera)? true : false;
var dom = (document.getElementById && !ie && !opera)? true : false;

var expiration = new Date();
expiration.setTime(expiration.getTime() + 3600*3600*3600);


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');
    }
}


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)); 
} 

