﻿/*
Copyright 2007 - 2012 Red Software.
All Rights Reserved.

This file and its contents may only be used to the extent, in the manner and 
for the purposes permitted by PDFescape's terms of use. Without limiting the 
foregoing, this file and its contents may NOT be copied, modified, used to 
create a derivative work of, reverse engineered, reverse assembled or 
otherwise used in attempt to discover any source code, linked to or otherwise 
used outside of PDFescape, sold, assigned, sublicensed, or distributed without 
the prior written consent of Red Software.
*/

var pDefinition;

function pDefinitionShow(e, t)
{
	var tx;
	var docWidth;
	var docHeight;
	var docScrollTop = 0;
	var docScrollLeft = 0;
	
	switch(t)
	{
		case "pub":
			tx = "<b>Publishing Credits</b> are used to upload a document to the PDFescape server. Each <b>Publishing Credit</b> allows one file to be uploaded. Once a file is uploaded, advanced permissions for the file can be setup (including the ability to make the PDF form submit responses to an email address).";
			break;

		case "unreg":
			tx = "<b>Unregistered Users</b> can use PDFescape free of charge, however they can <b>not</b> later log back into PDFescape and work with previously opened files. Files which you do not save to your local computer will be deleted from our servers. Registering is free and recommended for most users.";
			break;

		default:
		    tx = "";
	}
	
	if(tx.length > 0)
	{
	    if(window.event)
	    {
			e = window.event;
		}
		
		pDefinition = document.getElementById("pDefinition");
		
		if( window.innerWidth )
		{
			docWidth	= window.innerWidth;
			docHeight	= window.innerHeight;
		}
		else if( document.documentElement.clientWidth )
		{
			docWidth	= document.documentElement.clientWidth;
			docHeight	= document.documentElement.clientHeight;
		}
		else if( document.body.clientWidth )
		{
			docWidth	= document.body.clientWidth;
			docHeight	= document.body.clientHeight;
		}
		
		docScrollTop    = (document.documentElement.scrollTop  || document.body.scrollTop  || 0);
		docScrollLeft   = (document.documentElement.scrollLeft || document.body.scrollLeft || 0);
		
		pDefinition.innerHTML = tx;
		
		if( ((e.pageX || e.clientX || 0) + 250) > docWidth )
		{
			pDefinition.style.left = ((e.pageX || (e.clientX + docScrollLeft) || 0) - 210) + "px";
		}
		else
		{
			pDefinition.style.left = ((e.pageX || (e.clientX + docScrollLeft) || 0) + 5) + "px";
		}
		pDefinition.style.top = ((e.pageY || (e.clientY + docScrollTop) || 0) - parseInt(pDefinition.scrollHeight) - 5) + "px";
		
		pDefinition.style.visibility = "visible";
	}
}
function pDefinitionHide()
{
    if(pDefinition)
    {
	    pDefinition.style.visibility = "hidden";
	    pDefinition.innerHTML = "";
    }
}

function pCreateLink(bSetFocus)
{
	var fLink      = document.getElementById("fLink");
	var fLinkStyle = document.getElementById("fLinkStyle");
    var fSource    = document.getElementById("fSource");
	
	var u = "";
	
	var sSource = fSource.value;
	if(sSource)
	{
	    if((sSource.toLowerCase().indexOf("http://") != 0) && (sSource.toLowerCase().indexOf("https://") != 0))
	    {
	        sSource = "http://" + sSource;
	    }
	    
	    u = "http://www.pdfescape.com/url/?" + encodeURIComponent(sSource);
	}
	
	if( fLinkStyle.value == "1" )
	{
		fLink.value = "<a href=\"" + u + "\"><img alt=\"Edit This PDF Online With PDFescape\" src=\"http://www.pdfescape.com/images/pdfescape_link.gif\" border=\"0\" width=\"150\" height=\"61\" /></a>";;
	}
	else
	{
		fLink.value = u;
	}
	
	if(bSetFocus)
	{
    	fLink.focus();
    	fLink.select();
	}
}
