﻿var intervalID = -1;
var dy = 20;
var dt = 80;

var fontSize = 1.2;
var highlighted;

function changeFontSize(size){
    document.body.style.fontSize = new String(size + 'em');
    fontSize = size;
    setCookie('pctcfontSize',size,null);
    highlightFontSizeBtn(size);
}
function loadFontSizeCookie(){
    var size = getCookie('pctcfontSize');
    if (size!=null && !isNaN(size)){
        changeFontSize(Number(size));
    } else {
        changeFontSize(1.2);
    }
}

function fontSizeMouseOver(obj){
    if (obj != highlighted) { obj.src = obj.src.replace('.jpg','_on.jpg'); }
}

function fontSizeMouseOut(obj){
    if (obj != highlighted) { obj.src = obj.src.replace('_on.jpg','.jpg'); }
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return null;
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+";path=/"+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function resizeBanner(){
    var obj = document.getElementById('banner');
    if (obj.offsetHeight == 300){
        clearInterval(intervalID);
        startExpandBanner();
        //expandBannerFull();
    } else {
        clearInterval(intervalID);
        startShrinkBanner();
    }
}
function startExpandBanner(){
    intervalID = setInterval('expandBanner()',dt);
}
function expandBanner(){
    var obj = document.getElementById('banner');
    if (obj.offsetHeight < 500){
        obj.style.height = obj.offsetHeight + dy + 'px';
    } else {
        obj.style.height = '500px';
        clearInterval(intervalID);
    }
}
function startShrinkBanner(){
    intervalID = setInterval('shrinkBanner()',dt);
}
function shrinkBanner(){
    var obj = document.getElementById('banner');
    if (obj.offsetHeight > 300){
        obj.style.height = obj.offsetHeight - dy + 'px';
    } else {
        obj.style.height = '300px';
        clearInterval(intervalID);
    }
}
function expandBannerFull(){
    var obj = document.getElementById('banner');
    if (obj.offsetHeight < 500){
        obj.style.height = '500px';
    } else {
        obj.style.height = '500px';
        clearInterval(intervalID);
    }
}

function showGlossary(id,target){ 
    var obj = document.getElementById(id); 
    var pos = $(target).position();
    var wrp = $("#content_wrapper");
    var twidth = $(target).width();
    var theight = $(target).height();
    var owidth = $(obj).width();
    var oheight = $(obj).height();
    var offset = 5;
    if (wrp == null){
        $(obj).css( { "left": (pos.left) + "px", "top":(pos.top + theight + offset) + "px" } );
    } else {
        var wrpleft = $(wrp).position().left;
        if ((wrpleft + pos.left + owidth) > (wrpleft*2 + 1000)){
            $(obj).css( { "left": (wrpleft+1000-owidth) + "px", "top":(pos.top + theight + offset) + "px" } );
        } else {
            $(obj).css( { "left": (pos.left) + "px", "top":(pos.top + theight + offset) + "px" } );
        }
    }
    $(obj).show();
}
function hideGlossary(id){ 
    var obj = document.getElementById(id); 
    $(obj).hide();  
}
    
function loadSWF(id,swf,width,height){
	swfobject.embedSWF(swf, id, width, height, "9.0.0", "swf/expressInstall.swf");
	//var so = new SWFObject(swf, id, "100%", "100%", "9", "#ffffff");
    //so.useExpressInstall('swf/expressinstall.swf');
	//so.addParam("allowScriptAccess","sameDomain");
	//so.addParam("quality","high");
	//so.addParam("wmode","transparent");
	//so.addParam("allowmenu","false");
	//so.write(id);
}    

$(document).ready(function(){
    $('div#videotestimonial1').ready(function(){
        loadSWF('videotestimonial1','../swf/videotestimonial1.swf',480,290);
    });
    $('div#videotestimonial2').ready(function(){
        loadSWF('videotestimonial2','../swf/videotestimonial2.swf',480,290);
    });
});