﻿var oldSrc;

//showcase hyperlinks
function swapImage(id, src, overOut)
{
    // onmouseover
    if(overOut == 'over')
    {
        // save old url
        oldSrc = document.getElementById(id).src;
        
        // set new url
        document.getElementById(id).src = src;
    }
    
    // onmouseout
    if(overOut == 'out')
    {
        // reset to default url
        document.getElementById(id).src = oldSrc;
    }
}

//pdf gen
function sayHello(pages){
    window.addEvent('domready', function(){
			var txt = $('myTextarea'), log = $('log');
			var fx = new Fx.Styles(log, {
				duration: 3000,
				wait: false,
				transition: Fx.Transitions.Expo.easeIn
			});

			$('myTextarea').addEvents({
				'burn': function(text) {
					txt.value = '';
					log.setHTML(text);
					fx.start({
						'background-color': ['#e5dfec', '#fff'],
						'opacity': [1, 0]
					})
				}
			});
			txt.fireEvent('burn', '<div id="popUp" class="sidebar"><div id="popUpText"><h3 class="pdf">PDF Basket</h3><p>'+pages+'</p></div></div>');
		}); 
      }

//topText
function willWork(i, text, inc) {
        var outputVar = "This will work!";

        var tempFunction = function() {
        //Due to closures, outputVar will be populated
        fadeText("#div", "#span", i, text, inc);
        };
        //Will call function in local scope
        setTimeout(tempFunction, 3500);
        }
function willWork1(i, text) {
        var outputVar = "This will work!";

        var tempFunction = function() {
        //Due to closures, outputVar will be populated
        fadeText1("#div", "#span", i, text);
        };
        //Will call function in local scope
        setTimeout(tempFunction, 3500);
        }

function fade(i, text, inc) {

        var tempFunction = function() {
        //Due to closures, outputVar will be populated
        fadeOutIn("#div", "#span", i, text, inc);
        };
        //Will call function in local scope
        setTimeout(tempFunction, 5000);
        }
function fade1(i, text) {

        var tempFunction = function() {
        //Due to closures, outputVar will be populated
        fadeOutIn1("#div", "#span", i, text);
        };
        //Will call function in local scope
        setTimeout(tempFunction, 5000);
        }
//homepage
function topText(i, text) 
{   
    if(i >= text.length)
    {
        var i = 0;
    }
    if(i == -1) 
    {
        var i=0;
        document.getElementById("span").innerHTML = text[i+1];
        document.getElementById("div").innerHTML = text[i];
 
        //var t = window.setTimeout(fadeText1, 2000, "#div", "#span", i, text);
        willWork1(i, text);
    } 
    else 
    { 
        var inc = 2;
        document.getElementById("span").innerHTML = text[i];
        
        if(i == text.length - 1)
        {
            i = 0;
            document.getElementById("div").innerHTML = text[0];  
            inc = 1;
        }
        else
        {
            document.getElementById("div").innerHTML = text[i+1];
            inc = 2;
        }
        //var t = window.setTimeout(fadeText, 2000, "#div", "#span", i, text);
        willWork(i, text, inc);
    }  
};
 
function fadeText(elemOut, elemIn, i, text, inc) 
{ 
    jQuery(elemIn).fadeOut(1500, function(){jQuery(elemOut).fadeIn(100);});
    //var t = window.setTimeout(fadeOutIn, 5000, elemOut, elemIn, i, text);
    fade(i, text, inc);
};

function fadeText1(elemOut, elemIn, i, text) 
{ 
    jQuery(elemOut).fadeOut(1500, function(){jQuery(elemIn).fadeIn(100);});
    //var t = window.setTimeout(fadeOutIn1, 5000, elemOut, elemIn, i, text);
    fade1(i, text);
};

function fadeOutIn(elemOut, elemIn, i, text, inc) 
{
    jQuery(elemOut).fadeOut(1500, function(){jQuery(elemIn).fadeIn(100);topText(i+inc, text);} );
}; 

function fadeOutIn1(elemOut, elemIn, i, text) 
{
    jQuery(elemIn).fadeOut(1500, function(){jQuery(elemIn).fadeIn(100);topText(i+2, text);} );
};  