/**** pegassist supporting script ****/

/* set font size from either click or cookie, then set new cookie */
function changeFontPegassist(e, obj) {
    if(YAHOO.lang.isUndefined(obj.size) || obj.size == null)
        return;
    var b = document.getElementsByTagName("body")[0];
    YAHOO.util.Dom.setStyle(b, "font-size", obj.size + "%");
    YAHOO.util.Cookie.set("pinFontPegassist", obj.size, { 
        expires: new Date("January 1, 2012"),
        path: "/"
       // domain: "foo.com"   /* if you want to set the domain explicitly... 
    }
	);
} 

function initTabViewControl() {
    var tabView = new YAHOO.widget.TabView('tab-control-subnav');
	var tabView = new YAHOO.widget.TabView('sub-tab-control-subnav');
	var tabView = new YAHOO.widget.TabView('sub-tab-control-subnav2');
}
var SendMail = {
	send: function(){
		YAHOO.util.Dom.setStyle('friend-content', 'display', 'none'); 
		YAHOO.util.Dom.setStyle('sented-content', 'display', 'block'); 
	},
	confirmMail: function(){
		YAHOO.util.Dom.setStyle('sented-content', 'display', 'none'); 
		YAHOO.util.Dom.setStyle('friend-content', 'display', 'block'); 
	}
}
var ModalDialogControl = {
    modalDialog: null,
    
    init: function() {
        this.modalDialog = new YAHOO.widget.Panel("modal-dialog", { 
                width: "532px",
                height: "532px",
                underlay: "none", 
                fixedcenter: true,
                visible:false,  
                draggable:false,
                modal:true,
                close: false
            });
        this.modalDialog.render();
    },
    
    showModal: function(e){
        // for accessibility, the link should have an actual url assigned
        // this will prevent it from from going anywhere for clients that
        // support the scripted action.

        //get the target:
    	var elTarget = YAHOO.util.Event.getTarget(e);
    	if(elTarget.className.toLowerCase() === "modal-trigger") {
    		this.modalDialog.show();
    		YAHOO.util.Event.preventDefault(e);
    	} 
    },
    
    hideModal: function(e){
        this.modalDialog.hide();
    }
}
var ModalDialogControl1 = {
    modalDialog: null,
    
    init: function() {
        this.modalDialog = new YAHOO.widget.Panel("modal-dialog1", { 
                width: "435px",
                height: "317px",
                underlay: "none", 
                fixedcenter: true,
                visible:false,  
                draggable:false,
                modal:true,
                close: false
            });
        this.modalDialog.render();
    },
    
    showModal: function(e){
        // for accessibility, the link should have an actual url assigned
        // this will prevent it from from going anywhere for clients that
        // support the scripted action.

        //get the target:
    	var elTarget = YAHOO.util.Event.getTarget(e);
    	if(elTarget.className.toLowerCase() === "modal-trigger1") {
    		this.modalDialog.show();
    		YAHOO.util.Event.preventDefault(e);
    	} 
    },
    
    hideModal: function(e){
        this.modalDialog.hide();
    }
}

/* intialize settings and handlers when DOM is constructed */
function initPegassistSite() {
    // IE browser can't handle passing this as an argument directly. read in here...
    var tmpForIE = YAHOO.util.Cookie.get("pinFontPegassist");
    // do font size if cookie exists
    changeFontPegassist(null, {size: tmpForIE });
    // render tab control
    initTabViewControl();
    // attach listeners for text sizing
    YAHOO.util.Event.addListener("f-larger", "click", changeFontPegassist, {size:"100"});
	YAHOO.util.Event.addListener("search-txt", "focus", SearchTxt, {name:"search-txt"});
	YAHOO.util.Event.addListener("search-btn", "click", SearchTxt, {name:"search-txt"});
    YAHOO.util.Event.addListener("f-largest", "click", changeFontPegassist, {size:"120"});
    // init modal dialog
    ModalDialogControl.init();
	ModalDialogControl1.init();
    // attach listener to delegate for modal popup
    var b = document.getElementsByTagName("body")[0];
    YAHOO.util.Event.addListener(b, "click", ModalDialogControl.showModal, ModalDialogControl, true);
	YAHOO.util.Event.addListener(b, "click", ModalDialogControl1.showModal, ModalDialogControl1, true);
    // attach listener to close modal popup
    var closeDialog = YAHOO.util.Selector.query('img#close-img', 'modal-dialog', true);
    YAHOO.util.Event.addListener(closeDialog, "click", ModalDialogControl.hideModal, ModalDialogControl, true);
	var closeDialog1 = YAHOO.util.Selector.query('img#close-img1', 'modal-dialog1', true);
    YAHOO.util.Event.addListener(closeDialog1, "click", ModalDialogControl1.hideModal, ModalDialogControl1, true);
	var closeDialog2 = YAHOO.util.Selector.query('#returnsite', 'modal-dialog1', true);
	YAHOO.util.Event.addListener(closeDialog2, "click", ModalDialogControl1.hideModal, ModalDialogControl1, true);
	
	// attach listener to send for send button
	var send = YAHOO.util.Selector.query('img#send', 'modal-dialog', true);
	YAHOO.util.Event.addListener(send,"click",SendMail.send, SendMail, true);
	
	// attach listener to send for send another button
	var another = YAHOO.util.Selector.query('img#another', 'modal-dialog', true);
	YAHOO.util.Event.addListener(another,"click",SendMail.confirmMail, SendMail, true);
	document.getElementById("close-img").style.display = "block";
	document.getElementById("close-img1").style.display = "block";
	getFocus();
}
function getFocus(){
		//document.getElementById("email").focus();	
		var s = document.getElementById("content-center").getElementsByTagName("INPUT");
		if(s){
			s[0].focus();	
		}
	}

function SearchTxt(e, obj){
	obj = document.getElementById(obj.name);
	if(obj.value == "Enter Search Term"){
		obj.value = "";
	}
	if(obj.value.length<=0){
		return false;	
	}
}
	
YAHOO.util.Event.onDOMReady(initPegassistSite);


// Provide an Exit Page Popup 050709
function ExternalLink(source_url, dest_url)
{
	var ExitPage_url = "/popup/exit.aspx?source_url=" + source_url + "&dest_url=" + dest_url;
	window.open(ExitPage_url,"ExitPage","width=538,height=550,menubar=no,resizeable=no,status=no,toolbar=no,scrollbar=no");
	
	return false;
}

// Asign the Continue Button the Proper Link & Close this window
function AssignExternalLink()
{
	var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    
	if( vars != null & vars.length > 0 )
	{
		window.opener.location = vars["dest_url"];		
		window.close();
	}
}