﻿function SetWaterMarkForTextFields() {
    var txtBoxes = document.getElementsByTagName("input")
    for (var i = 0; i < txtBoxes.length; i++) {
        if (txtBoxes[i].WaterMarkText) {
            txtBoxes[i].style.color = '#999999';
            txtBoxes[i].value = txtBoxes[i].WaterMarkText;
            txtBoxes[i].onfocus = function() {
                if (this.value == this.WaterMarkText) {
                    this.value = '';
                    this.style.color = '#000000';
                }
            }
            txtBoxes[i].onblur = function() {
                if (this.value == '') {
                    this.value = this.WaterMarkText;
                    this.style.color = '#999999';
                }
                else {
                    this.style.color = '#000000';
                }
            }
        }
    }
}
 function trim(string)
 {
	return string.replace(/^\s*/, "").replace(/\s*$/, "");
} 
function DisableBackground(zIndex, bgColor, alpha, appendTo) {
    if (!zIndex)
        zIndex = 10;
    if (!bgColor)
        bgColor = '#000000';
    if (!alpha)
        alpha = .6;
    if (!appendTo)
        appendTo = 'body';

    html = '<iframe id="IFDISABLEBG" class="bgiframe" frameborder="0" tabindex="-1"' +
		               'style="display:none;position:absolute;z-index:' + zIndex + ';background:' + bgColor +
		               ';filter: alpha(opacity=' + (alpha * 100) + ');' +
		               'opacity:' + alpha + ';' +
		               'top:0px;left:0px;width:' + ($(window).width()) + 'px;height:' + $(document).height() + 'px;"/>';
    $(appendTo).append(html);


    $('#IFDISABLEBG').fadeIn("slow");


    window.onresize = function() {
        $('#IFDISABLEBG').width($(window).width());
    }


};
function EnableBackground() {
    $('#IFDISABLEBG').fadeOut("slow");
    window.onresize = null;
    $('#IFDISABLEBG').remove();
}
/*Playing mutually exculisive videos  */
var oldWrapper = null;
var oldCode;    

function removeOldPlayer(theOldWrapper, theOldCode) { 
      document.getElementById(theOldWrapper).innerHTML = theOldCode;
}

function createPlayer(theFile, placeholder, video, theWrapper, width, height, displayheight) {
    if (oldWrapper != null) { removeOldPlayer(oldWrapper, oldCode); }

    oldWrapper = theWrapper; 
    oldCode = document.getElementById(oldWrapper).innerHTML; 

    var s = new SWFObject("Controls/mediaplayer.swf", "thePlayerId", width, height, "7");
    s.addParam("allowfullscreen", "true");
    s.addVariable("file", theFile);
    s.addVariable("width", width);
    s.addVariable("height", height);
    s.addVariable("wmode", "opaque");
    s.addVariable("autoscroll", "true");
    s.addVariable("allowscriptaccess", "true");
    s.addVariable("wmode", "opaque");
    s.addVariable("bufferlength", "10");
    s.addVariable("displayheight", displayheight);
    s.addVariable("allowfullscreen", "true");
    s.addVariable("autostart", "true");
    s.addVariable("shuffle", "false");
    s.addVariable("image", "" + video + "");
    s.addVariable("enablejs", "true");
    s.addVariable("javascriptid", "thePlayerId");

    s.write(placeholder);
}
//$(function() { createPlayerTest('http://www.ediblearrangements.com/Res/en-us/i/p/mediaplayer.swf', 'http://www.ediblearrangements.com/Resources/en-us/v/video_cnbcbigidea_9and10.flv', 'v1', 'http://www.ediblearrangements.com/Resources/en-us/i/p/video_cnbcbigidea_9and10.jpg', 185, 157, 137); });

function createPlayerTest(mediaFile, theFile, placeholder, image, width, height, displayHeight) {
    var s = new SWFObject(mediaFile, "thePlayerId", width, height, "7");
    s.addParam("allowfullscreen", "true");
    s.addVariable("file", theFile);
    s.addVariable("width", width);
    s.addVariable("height", height);
    s.addVariable("wmode", "opaque");
    s.addVariable("autoscroll", "true");
    s.addVariable("allowscriptaccess", "true");
    s.addVariable("wmode", "opaque");
    s.addVariable("bufferlength", "10");
    s.addVariable("displayheight", displayHeight);
    s.addVariable("allowfullscreen", "true");
    s.addVariable("autostart", "false");
    s.addVariable('image', image);
    s.addVariable("shuffle", "false");
    s.addVariable("enablejs", "true");
    s.addVariable("javascriptid", "thePlayerId");
    s.write(placeholder);
}
