﻿String.prototype.trim = function () {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
reset_form_value = function(str1, str2, val) {
	if(str1 == val.value.trim())
		val.value = str2;
}

$(function() {
    $('a[href*=pdf]').click(function() {
        pageTracker._trackPageview('/pdf/' + $(this).text());
    });
    $('a[href*=mp3]').click(function() {
        pageTracker._trackPageview('/video/' + $(this).text());
    });
    $('a[href*=xls]').click(function() {
        pageTracker._trackPageview('/xls/' + $(this).text());
    });
    $('a[href*=ppt]').click(function() {
        pageTracker._trackPageview('/ppt/' + $(this).text());
    });
    $('a[href*=doc]').click(function() {
        pageTracker._trackPageview('/doc/' + $(this).text());
    });
});
function renderFlash(src, width, height, features) {
    document.writeln('<embed src="' + src + '" quality="high" width="' + width +
					 '" height="' + height + '" align="top" allowscriptaccess="sameDomain" ' +
					 'type="application/x-shockwave-flash" ' + features +
  					 'pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}

var openFLVPlayer = function(source) {
    if (source) {
        modalWindow.windowId = "flv-player";
        modalWindow.width = 800;
        modalWindow.height = 500;
        modalWindow.content = "<iframe width='800' height='800' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'></iframe>";

        modalWindow.open();
    }
};
var modalWindow = {
    parent: String = "body",
    windowId: String = null,
    content: String = null,
    width: Number,
    height: Number,
    close: function() {
        $(".modal-window").remove();
        $(".modal-overlay").remove();
    },
    open: function() {
        var modal = "";
        modal += "<div class=\"modal-overlay\"></div>";
        modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
        modal += this.content;
        modal += "</div>";

        $(this.parent).append(modal);


        $(".modal-window").append("<a class=\"close-window\"></a>");
        $(".close-window").click(function() { modalWindow.close(); });
        $(".modal-overlay").click(function() { modalWindow.close(); });
    }
};
try {
    hex_chars = Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
    hash = '';
    hash_length = 20;
    for (h = 0; h < hash_length; h++) { hash = hash + hex_chars[Math.floor(16 * Math.random())]; }
    document.getElementById('vrCaptchaHash').value = hash;
    captcha_image_url = 'https://captcha.vresp.com/produce/' + hash;
    document.getElementById('vrCaptchaImage').src = captcha_image_url;
}
catch (err) {
}
