﻿

function keypress(e) {

    if ([e.keyCode || e.which] == 8) //this is to allow backspace
        return true;
    if ([e.keyCode || e.which] < 48 || [e.keyCode || e.which] > 57)
        e.preventDefault ? e.preventDefault() : e.returnValue = false;
}

function initrequestHandler() {
   
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}
function EndRequestHandler() {
  
    if (typeof tinyMCE != 'undefined')
        InitTb();
}
function InitTb() {
    var tas = document.getElementsByTagName('textarea');
    for (var i = 0; i < tas.length; i++) {
        var ta = tas[i];
        tinyMCE.execCommand('mceAddControl', true, ta.id);
    }
}

function removemce() 
{
    var tas = document.getElementsByTagName('textarea');
    for (var i = 0; i < tas.length; i++) {
        var ta = tas[i];
        tinyMCE.execCommand("mceRemoveControl", false, ta.id);
    }
}
function ShowBig(nProduct) {
    window.open("retailImage.aspx?PID=" + nProduct + "", "bigPics", "directories=no,height=600,width=600,left=20,location=no,menubar=no,toolbar=no,top=20");

}

function showme(myImg, myID) 
{
    var mainImage = document.getElementById("ctl00_ContentPlaceHolder1_FormView1_ImageButton1");
    if (null == mainImage)
        return;
    mainImage.src = String.format("GetThumbnail.ashx?Img=ProductImages/{0}&X=300&Y=300&rt=yes", myImg);
}
if (typeof tinyMCE != 'undefined') {
   
    tinyMCE.init({ mode: "textareas", theme: "simple", editor_selector: "mceSimple", width: "500" });
    tinyMCE.init({
        // General options

        forced_root_block: '',
        force_p_newlines: false,
        force_br_newlines: true,
        convert_newlines_to_brs: false,
        remove_linebreaks: false,


        mode: "textareas",
        editor_selector: "mceAdvanced",
        width: "400",
        theme: "advanced",

        plugins: "safari,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
        relative_urls: false,
        // Theme options
        theme_advanced_buttons1: "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect,emotions",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,cleanup,code,|,preview,|,forecolor,backcolor",
        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,advhr,|,ltr,rtl,|,fullscreen",
        //  theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,

        // Example content CSS (should be your site CSS)
        content_css: "StyleSheet.css",
        width: "400",
        // Drop lists for link/image/media/template dialogs
        template_external_list_url: "lists/template_list.js",
        external_link_list_url: "lists/link_list.js",
        external_image_list_url: "lists/image_list.js",
        media_external_list_url: "lists/media_list.js",

        // Replace values for the template plugin
        template_replace_values: {
            username: "Some User",
            staffid: "991234"
        }
    });
    initrequestHandler();
}
