if (document.images) {

	m1On = new Image
	m1Off = new Image
	m1On.src ='/vm/skin1/vm/pix/home_off.jpg'
	m1Off.src = '/vm/skin1/vm/pix/home_on.jpg'
	m2On = new Image
	m2Off = new Image
	m2On.src ='/vm/skin1/vm/pix/faq_off.jpg'
	m2Off.src = '/vm/skin1/vm/pix/faq_on.jpg'
	m3On = new Image
	m3Off = new Image
	m3On.src ='/vm/skin1/vm/pix/about_off.jpg'
	m3Off.src = '/vm/skin1/vm/pix/about_on.jpg'
	m4On = new Image
	m4Off = new Image
	m4On.src ='/vm/skin1/vm/pix/contact_off.jpg'
	m4Off.src = '/vm/skin1/vm/pix/contact_on.jpg'
	ms1On = new Image
	ms1Off = new Image
	ms1On.src ='/vm/skin1/vm/pix/ms_gen_info_off.jpg'
	ms1Off.src = '/vm/skin1/vm/pix/ms_gen_info_on.jpg'
	ms2On = new Image
	ms2Off = new Image
	ms2On.src ='/vm/skin1/vm/pix/ms_filter_off.jpg'
	ms2Off.src = '/vm/skin1/vm/pix/ms_filter_on.jpg'
	ms3On = new Image
	ms3Off = new Image
	ms3On.src ='/vm/skin1/vm/pix/ms_pref_off.jpg'
	ms3Off.src = '/vm/skin1/vm/pix/ms_pref_on.jpg'
	ms4On = new Image
	ms4Off = new Image
	ms4On.src ='/vm/skin1/vm/pix/ms_flicks_off.jpg'
	ms4Off.src = '/vm/skin1/vm/pix/ms_flicks_on.jpg'
	ms5On = new Image
	ms5Off = new Image
	ms5On.src ='/vm/skin1/vm/pix/ms_front_off.jpg'
	ms5Off.src = '/vm/skin1/vm/pix/ms_front_on.jpg'
	ms6On = new Image
	ms6Off = new Image
	ms6On.src ='/vm/skin1/vm/pix/ms_prod_off.jpg'
	ms6Off.src = '/vm/skin1/vm/pix/ms_prod_on.jpg'
	ms7On = new Image
	ms7Off = new Image
	ms7On.src ='/vm/skin1/vm/pix/ms_layout_off.jpg'
	ms7Off.src = '/vm/skin1/vm/pix/ms_layout_on.jpg'
	ms8On = new Image
	ms8Off = new Image
	ms8On.src ='/vm/skin1/vm/pix/ms_style_off.jpg'
	ms8Off.src = '/vm/skin1/vm/pix/ms_style_on.jpg'
	ms9On = new Image
	ms9Off = new Image
	ms9On.src ='/vm/skin1/vm/pix/ms_camp_off.jpg'
	ms9Off.src = '/vm/skin1/vm/pix/ms_camp_on.jpg'
	ms10On = new Image
	ms10Off = new Image
	ms10On.src ='/vm/skin1/vm/pix/ms_studio_off.jpg'
	ms10Off.src = '/vm/skin1/vm/pix/ms_studio_on.jpg'
	mr1On = new Image
	mr1Off = new Image
	mr1On.src ='/vm/skin1/vm/pix/mr_cum_off.jpg'
	mr1Off.src = '/vm/skin1/vm/pix/mr_cum_on.jpg'
	mr2On = new Image
	mr2Off = new Image
	mr2On.src ='/vm/skin1/vm/pix/mr_daily_off.jpg'
	mr2Off.src = '/vm/skin1/vm/pix/mr_daily_on.jpg'
	mr2aOn = new Image
	mr2aOff = new Image
	mr2aOn.src ='/vm/skin1/vm/pix/mr_daily2_off.jpg'
	mr2aOff.src = '/vm/skin1/vm/pix/mr_daily2_on.jpg'
	mr3On = new Image
	mr3Off = new Image
	mr3On.src ='/vm/skin1/vm/pix/mr_monthly_off.jpg'
	mr3Off.src = '/vm/skin1/vm/pix/mr_monthly_on.jpg'
	mr4On = new Image
	mr4Off = new Image
	mr4On.src ='/vm/skin1/vm/pix/mr_hist_off.jpg'
	mr4Off.src = '/vm/skin1/vm/pix/mr_hist_on.jpg'
}


function setCaretToEnd (el) {
  if (el.createTextRange) {
    var v = el.value;
    var r = el.createTextRange();
    r.moveStart('character', v.length);
    r.select();
  }
}


/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function popConsoleCode(console_type, vs_console_link_type, color, categoryid, vs_site_id, campaign_id, new_campaign_ind, wl_user_id, console_title) 
{

//alert (campaign_id);

	var color_var;
	var vs_console_link_type_var;
	var new_campaign_ind_var;

	if (new_campaign_ind.checked)  
	{
		new_campaign_ind_var = new_campaign_ind.value;
	}
	else
	{
		new_campaign_ind_var = "";
	}

	for (var i=0; i<color.length; i++)  
	{ 
		if (color[i].checked)  
		{
			color_var = color[i].value;
		}
	} 
	for (var i=0; i<vs_console_link_type.length; i++)  
	{ 
		if (vs_console_link_type[i].checked)  
		{
			vs_console_link_type_var = vs_console_link_type[i].value;
		}
	} 
	
	//********Validate Input
	if (!color_var)
	{
		alert ("Console Color is Not Selected!")
		return;
	}

	//********Validate Input
	if (!categoryid)
	{
		alert ("Category is Not Selected!")
		return;
	}

	if (!vs_console_link_type_var)
	{
		alert ("You Must Select a Site to Link This Console To!")
		return;
	}
	else
	{	
		if (vs_console_link_type_var == "TK" && !vs_site_id)
		{
			alert ("You Must Select Your Turn Key Site!")
			return;
		}
		if (vs_console_link_type_var == "LNK" && !wl_user_id)
		{
			alert ("You Must Select VODMoney Site!")
			return;
		}
	}

      	var uri = "main.emgp?action=vs_generate_console&console_type=" + console_type +
					"&vs_console_link_type=" + vs_console_link_type_var +
					"&color=" + color_var +
					"&categoryid=" + categoryid +
					"&vs_site_id=" + vs_site_id +
					"&campaign_id=" + campaign_id +
					"&new_campaign_ind=" + new_campaign_ind_var +
					"&wl_user_id=" + wl_user_id +
					"&console_title=" + console_title;

	window.open(uri, "ConsoleCodeWindow", "width=600, height=400");
}

function popProductDetail(productid) 
{
      	var uri = "main.emgp?action=pop_product_detail&productid=" + productid;

	window.open(uri, "ProductDetailWindow", "width=520, height=700,scrollbars=1");

}


function doCalWindow(site,date,original_action,update_action, flick_option,form_name) 
{
      	var uri = "main.emgp?action=vs_product_search&date_value=" + date + "&site_id=" + site + "&original_action=" + original_action + "&update_action=" + update_action;

        if (flick_option == 'custom')
        {  	
	
	window.open(uri, "calWin", "width=400, height=600");
        }

}

function doFPWindow(site,original_action,update_action,form_name) 
{
      	var uri = "main.emgp?action=vs_product_search&site_id=" + site + "&original_action=" + original_action + "&update_action=" + update_action + "&form_name=" + form_name + "&multiple=yes";

	
	window.open(uri, "calWin", "width=400, height=600");

}

function doCssToolWindow(site_id) 
{
      	var uri = "main.emgp?action=vs_edit_style&site_id=" + site_id + "&mode=edit_style_load";
	window.open(uri, "ccsWin", "width=1280, height=760, left=0, top=0");

}




 // This array is used to remember mark status of rows in browse mode

var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function popWindow(URL, x, y)   {
        newWindow = window.open(URL,"large","width="+x+",height="+y+"");
        }
function popWindow2(URL, x, y)  {
        newWindow = window.open(URL,"large","width="+x+",height="+y+",scrollbars=yes,resizable=yes");
        }

function Form1_Validator(theForm)
{
	if (Form1.site_name.value == "")
        {
          alert("Please enter your Store Name");
          Form1.site_name.focus();
          return (false);
        }
        
  	if (Form1.page_title.value == "")
        {
          alert("Please enter your Page Title.");
          Form1.page_title.focus();
          return (false);
        }
        

        return (true);
}


function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

