
/*****************************************************************************************************
Created By: Ferdous Md. Jannatul, Sr. Software Engineer
Created On: 10 December 2005
Last Modified: 13 April 2006
******************************************************************************************************/
//Generating Pop-up Print Preview page
function getPrint(print_area, sub_print_area)
{
    var pp = window.open();
    pp.document.writeln('<HTML><HEAD><title> </title>');
    pp.document.writeln('<LINK href=CSS/PrintScreenStyle.css type="text/css" rel="stylesheet" />');
    pp.document.writeln('<LINK href="CSS/PrintStyle.css"  type="text/css" rel="stylesheet" media="Print" /></HEAD>');
    pp.document.writeln('<BODY onload="window.print();window.close();" MS_POSITIONING="GridLayout" bottomMargin="10px" leftMargin="10px" topMargin="10px" rightMargin="10px">');
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    if (sub_print_area != null) {
        pp.document.writeln(document.getElementById(sub_print_area).innerHTML);
    }
    //pp.document.window.print();
    //location.reload(true);
    pp.document.writeln('</BODY></HTML>');
    pp.document.close();
    /*
	//Creating new page
	//var pp = window.print();
	var pp = window.open();
	//Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><title>Faktura</title><LINK href=CSS/Stylesheet.css  type="text/css" rel="stylesheet" />')
    pp.document.writeln('<LINK href=CSS/PrintStyle.css  type="text/css" rel="stylesheet" media="Print" /><base target="_self"></HEAD>')
	//Adding Body Tag
  pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="10px" leftMargin="10px" topMargin="10px" rightMargin="10px">');
    pp.document.writeln('<body>');
	//Adding form Tag
    pp.document.writeln('<form  method="post">');
	//pp.document.writeln('<DIV align="center">')
	//pp.document.writeln('<CENTER>')
	//Creating two buttons Print and Close within a table
  pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=left><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
	//Writing print area of the calling page
	//pp.document.writeln(location.reload(true));
	//pp.document.writeln(javascript:location.reload(true);window.print(););
	pp.document.writeln(document.getElementById(print_area).innerHTML);
	//Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</FORM></BODY></HTML>');
    */
}

function CopyToClipIE(divCopy){
    var div = document.getElementById(divCopy);
    //div.contentEditable = 'true';
    var controlRange;
    if (document.body.createControlRange) {
        controlRange = document.body.createControlRange();
        controlRange.addElement(div);
        controlRange.execCommand('Copy');
    }
    //div.contentEditable = 'true';
}

//Dynamically load JavaScript files or CSS files. Can be used in the following two ways:
//<a href="righttemp.htm" class="tablinks" rel="tabsect"><span onClick="javascript:loadjscssfile('content.css','css')">Promotions</span></a>
//When the Ajax page is fetched, the browser will know to style it using what's defined in content.css, as that was added to the page from the get go:
//<link rel="stylesheet" type="text/css" href="content.css" />
function loadjscssfile(filename, filetype) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref)
}

//loadjscssfile("myscript.js", "js") //dynamically load and add this .js file
//loadjscssfile("javascript.php", "js") //dynamically load "javascript.php" as a JavaScript file
//loadjscssfile("mystyle.css", "css") ////dynamically load and add this .css file

var flashcopier;
var flashlocation = 'clipboard.swf';

// setup flashcopier  
if (!window.clipboardData) {
    document.write("<div id=\"flashcopier\"></div>");
}

function copyToClipboard(text) {
    //var selectedHtml = (document.selection.createRange()).htmlText;
    // Set the clipboard with selected HTML, if there is any
    //if (selectedHtml != "")

    if (window.clipboardData) {
        window.clipboardData.setData('text', text);
    }
    else {
        if (flashcopier == null) {
            flashcopier = document.getElementById("flashcopier");
        }
        flashcopier.innerHTML = '<embed src="' + flashlocation + '" FlashVars="clipboard=' + encodeURIComponent(text) + '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    }
}  



// Copyright (C) krikkit - krikkit@gmx.net
// --> http://www.krikkit.net/
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
function copy_clip(meintext){
 if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // dit is belangrijk maar staat nergens duidelijk vermeld:
   // you have to sign the code to enable this, or see notes below 
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
   // maak een interface naar het clipboard
   var clip = Components.classes['@mozilla.org/widget/clipboard;1']
                 .createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   
   // maak een transferable
   var trans = Components.classes['@mozilla.org/widget/transferable;1']
                  .createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   
   // specificeer wat voor soort data we op willen halen; text in dit geval
   trans.addDataFlavor('text/unicode');
   
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten 
   // nodig om het in op te slaan
   var str = new Object();
   var len = new Object();
   
   str = Components.classes["@mozilla.org/supports-string;1"]
                .createInstance(Components.interfaces.nsISupportsString);
   
   var copytext=meintext;
   
   str.data=copytext;
   
   trans.setTransferData("text/unicode",str,copytext.length*2);
   
   var clipid=Components.interfaces.nsIClipboard;
   
   if (!clip) return false;
   
   clip.setData(trans,null,clipid.kGlobalClipboard);
   
   }
   alert("Following info was copied to your clipboard:\n\n" + meintext);
   return false;
}
