/*
 * Copyright 2011 1fb.net Financial Services. This document may not be reproduced, distributed or used in any manner
 * whatsoever without the expressed written permission of 1st Financial Bank USA.
 */

/**
 * @fileOverview Define Featured Video in home page.
 * 
 * @author Kevin Shen
 * @version 1.0, 2011-09-06
 * @since 7.00
 */

var collegeVideoTourPopup = null;
/*
 *  Set the flag ifPopupOpenFlag is to avoid that
 *  several YouUniversity popup windows will be opened if
 *  click it in college profile main page multiple times quickly.
 */
var ifPopupOpenFlag = false;
	
function openCollegeVideoTourPopup(schoolId) {
	var windowURL = windowMainURL + schoolId;
    if (ifPopupOpenFlag == true ){
        return;
    }
    ifPopupOpenFlag = true;
    collegeVideoTourPopup = window.open(windowURL, "CollegeVideoTourPopup", "left=109,top=267,height=560,width=680,status=yes,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
    ifPopupOpenFlag = false;
    collegeVideoTourPopup.focus();

    CookieUtil.setCookie("college_video_tour_popup_opener_url", window.location.href);
}

/**
 * Limit pre-configured page elements' text length.
 * All "span" elements with "limit" attribute set will be re-rendered by displaying the surplus characters using ellipsis (...).
 * For example, if a "span" element has a "limit" attribute set with 12 and now its text content is "1234567890123",
 * after this method is called, its display will become "123456789012...".
 */
jQuery.fn.limit = function() {
    var self = $j('span[limit]');
    self.each(function() {
        var objString = $j(this).text();
        var objLength = $j(this).text().length;
        var num = $j(this).attr('limit');
        $j(this).attr('title','View video tour of ' + objString);
        if (objLength > num) {
            objString = $j(this).text(objString.substring(0,num) + '...');
        }
    })
};

$j(document).ready(function() {
	$j(".ytv_thumb_btn").attr("style","display:block");
    // Call the method to limit all pre-configured page elements' text length.
    $j(document.body).limit();
});

