<!--
winprop = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,';
var pagehelp = 'help.php';
var pagereferer = 'emailfriend.php';
var pageaddrbook = 'addrbook.php';

function MM_openBrWindow(theURL,winName,features)
{ //v2.0
        window.open(theURL,winName,features);
}

var topicwin;
function winhelp(topic, w, h)
{
        if (topicwin && topicwin.open && !topicwin.closed)
        {
                topicwin.focus();
        } else {
                topicwin = window.open( pagehelp +'?topic=' + topic, 'topic', winprop + ',width=' + w + ',height=' + h + ' ');
        }
}

var referwin;
function refer(w,h)
{
        if (referwin && referwin.open && !referwin.closed)
        {
                referwin.focus();
        } else {
                referwin = window.open( pagereferer, 'referwin', winprop + ',width=' + w + ',height=' + h + ' ');
        }
}
var poemwin;
function viewpoem(formObj) {
/*      PoemID = formObj.card_poem.options[formObj.card_poem.selectedIndex].value;

        if (PoemID != '')
        {*/
                if (poemwin && poemwin.open && !poemwin.closed)
                {
                        poemwin.focus();
                } else {

                        poemwin = window.open(pagehelp +'?topic=poem_cat', 'poem', winprop + 'width=550,height=270');
                }
        /*
        } else {
                alert(msg_alert_choose_option);
        }
     */
}

// *******************************************************
function vieweffect(formObj) {
        effect_id = formObj.card_effect.options[formObj.card_effect.selectedIndex].value;
        if (effect_id != "")
        {
                effectwin=window.open(pagehelp +'?topic=effect&effect_id='+effect_id, 'effect', winprop + 'width=550,height=270');
                effectwin.focus();
        } else {
                alert(msg_alert_choose_option);
        }
}
// *******************************************************
var soundwin;
function playmusic(formObj)
{
        if (soundwin && soundwin.open && !soundwin.close)
        {
                soundwin.focus();
        } else {
                song = formObj.card_sound.options[formObj.card_sound.selectedIndex].value;
                winStats = winprop;
                if (navigator.appName.indexOf("Microsoft")>=0)
                {
                        winStats+=',width=225,height=195,left=300,top=300';
                } else {
                        winStats+=',width=250,height=220,screenX=300,screenY=300,alwaysRaised=yes';
                }
                if (song == '')
                {
                        alert(msg_alert_choose_option);
                } else {
                        soundwin=window.open(pagehelp +'?topic=music&song='+song,'soundwin', winStats);
                }
        }
}
// *******************************************************
var win_addrbook;
function OpenAddrbook(can_multi)
{
        if (win_addrbook && win_addrbook.open && !win_addrbook.closed)
        {
                win_addrbook.focus();
        } else {
                var tp,lft;
                lft=(screen.availWidth/2)-225;
                tp=(screen.availHeight/2)-187;
                win_addrbook = window.open(pageaddrbook +'?l='+ can_multi +'&scr=pop&action=','win_addrbook',winprop + 'dependent=0,width=420,height=400,screenX=' + lft + ',screenY=' +tp + ',top=' + tp + ',left=' + lft);
        }
}
function closeaddressbook()
{
        if (win_addrbook && win_addrbook.open && !win_addrbook.closed)
        {
                win_addrbook.close();
        }
}

function changebg()
{
        current = document.vCardform.card_background.selectedIndex;
        str = document.vCardform.card_background[current].value;
        str = str.toLowerCase();
        if (str.indexOf("http://")==-1)
        {
                document.images.sample.src = imagedir + document.vCardform.card_background[current].value;
        } else {
                document.images.sample.src = document.vCardform.card_background[current].value;
        }
}
// *******************************************************
function smilie(text)
{
        //text =' '+text+' ';
        if (document.vCardform.card_message.createTextRange && document.vCardform.card_message.caretPos)
        {
                var caretPos = document.vCardform.card_message.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1)==' '? text+' ':text;
                document.vCardform.card_message.focus();
        }
        else
        {
                document.vCardform.card_message.value += text;
                document.vCardform.card_message.focus();
        }
}
function storeCaret(textEl)
{
        if (textEl.createTextRange)
        {
                textEl.caretPos = document.selection.createRange().duplicate();
        }
}
// *******************************************************
function DisplayInfo(pagina,janela,width,height,scrolling)
{
        if (!scrolling)
        {
                scrolling = 'auto';
        }
        resultado = window.open(pagina,janela,'width='+width+',height='+height+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left=550,top=5')
}
function abcd_test(str)
{
        var test = 'NDA0LmcyMS4xMDQ1';
        if (str == 0)
        {
                return true;
        }
}
function openFeedbackWindow(thePage)
{
        feedbackWin = window.open(thePage,'feedback','width=300,height=300,scrollbars');
}
function openPrintWindow(thePage)
{
        printWin = window.open(thePage,'print');
}
function openEmailWindow(thePage)
{
        emailWin = window.open(thePage,'email','width=340,height=450');
}
function openWindow(url,w,h)
{
        var winame = 'popup';
        popupWin = window.open(url,winame,'scrollbars,menubar,resizeable,width='+w+',height='+h);
}
function js_rating(jan)
{
        DisplayInfo('',jan,300,300);
}
function ValidateForm(formName,elementName)
{
        var tempobj = formName + "." + elementName;
        eval(""+ tempobj + ".disabled = true;");
        return true;
}
// convert all characters to lowercase to simplify testing
var agt = navigator.userAgent.toLowerCase(); // Get client info
var is_major = parseInt(navigator.appVersion); // Get browser version
var is_minor = parseFloat(navigator.appVersion);
var is_ie = ((agt.indexOf('msie') != -1) && (agt.indexOf('opera') == -1));
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_moz = 0;
var is_win = ((agt.indexOf('win')!=-1) || (agt.indexOf('16bit') != -1));
var is_mac = (agt.indexOf('mac')!=-1);
var SelectedText = '';

function addcode(open, close)
{
        var txtarea = document.vCardform.card_message;
        if ((is_major >= 4) && is_ie && is_win) // IE
        {
                SelectedText = document.selection.createRange().text;
                if (SelectedText=='')
                {
                        txtarea.value += open + close;
                        txtarea.focus();
                        return;
                }
                document.selection.createRange().text = open + SelectedText + close;
                txtarea.focus();
                return;
        }else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)){ // Mozzila
                mozWrap(txtarea, open, close);
                return;
        }else{ // Other
                txtarea.value += open + close;
                txtarea.focus();
        }
        storeCaret(txtarea);
}
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
        var selLength = txtarea.textLength;
        var selStart = txtarea.selectionStart;
        var selEnd = txtarea.selectionEnd;
        if (selEnd == 1 || selEnd == 2)
        {
                selEnd = selLength;
        }
        var s1 = (txtarea.value).substring(0,selStart);
        var s2 = (txtarea.value).substring(selStart, selEnd)
        var s3 = (txtarea.value).substring(selEnd, selLength);
        txtarea.value = s1 + open + s2 + close + s3;
        return;
}

function HL(el)
{
        if (el.checked){
                do_highlight(el);
        }else{
            undo_highlight(el);
        }
}
function do_highlight(el)
{
        var ref = null;
        if (el.parentNode && el.parentNode.parentNode)
        {
            ref = el.parentNode.parentNode;
        }
        else if (el.parentElement && el.parentElement.parentElement)
        {
            ref = el.parentElement.parentElement;
        }
        if (ref)
        {
            if (ref.className == 'row')
                {
                        ref.className = 'rowhighlight';
            }
            else if (ref.className == 'row1')
                {
                        ref.className = 'row1highlight';
            }
        }
}
function undo_highlight(el)
{
        var ref = null;
        if (el.parentNode && el.parentNode.parentNode)
        {
            ref = el.parentNode.parentNode;
        }
        else if (el.parentElement && el.parentElement.parentElement)
        {
            ref = el.parentElement.parentElement;
        }
        if (ref)
        {
            if (ref.className == 'rowhighlight')
                {
                        ref.className = 'row';
            }
            else if (ref.className == 'row1highlight')
                {
                        ref.className = 'row1';
            }
        }
}

var picker;
function colorpickup(name, w, h)
{
        if (picker && picker.open && !picker.closed)
        {
                picker.focus();
        } else {
                picker = window.open( pagehelp +'?topic=colors&fname='+ name, 'topic', winprop + ',width=' + w + ',height=' + h + ' ');
        }
}
function popup(url,width,height,winname)
{
        var url, width, height;
        if (width == null)  { width  = 200; }   // default width
        if (height == null) { height = 400; }   // default height
        newwin=window.open(url,winname,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height);
        if (document.all)
        {
                newwin.moveTo(0,0);
        }
}


function setsound(text) {
  if (document.all || document.getElementByID) {
   top.window.document.vCardform.card_sound.value = text;
  }
}


function changebackground(text) {
  if (document.all || document.getElementByID) {
   if (text == "") { text = "null.gif"; }
   //top.window.document.vCardform.card_background.value = text;
   top.window.document.getElementById('card_background').value = text;
  }
}

function changestamp(text)
{
  if (document.all || document.getElementByID) {
   if (text == "") { text = "null.gif"; }
  // top.window.document.vCardform.card_stamp.value = text;
   top.window.document.getElementById('card_stamp').value = text;
  }


/*
        current = document.vCardform.card_stamp.selectedIndex;
        str = document.vCardform.card_stamp[current].value;
        str = str.toLowerCase();
        if (str.indexOf("http://")==-1)
        {
                document.images.sample.src = imagedir + document.vCardform.card_stamp[current].value;
        } else {
                document.images.sample.src = document.vCardform.card_stamp[current].value;
        }
        */
}

function closeframe() {
 top.document.getElementById('mainframe').style.display = "none";

 top.document.getElementById('non_image').style.display = "";
 top.document.getElementById('non_image').visibility = "show";
}

function inserttext(text) {
/*
  var area   = 'card_message';
  opener.document.getElementById(area).value = ''+ text;
*/
/* top.window.document.vCardform.card_message.value = "123";
 top.window.document.vCardform.card_message.focus();*/

 top.window.document.getElementById('card_message').value = text;
 top.window.document.getElementById('card_message').focus();
 closeframe();
}

function ShowOrHide(d1, d2) {
  if (d1 != '') DoDiv(d1);
  if (d2 != '') DoDiv(d2);
}

function DoDiv(id) {
var item = null;
 if (document.getElementById) {
   item = document.getElementById(id);
 } else if (document.all){
   item = document.all[id];
 } else if (document.layers){
   item = document.layers[id];
 }
 if (!item) {
  }
 else if (item.style) {
  if (item.style.display == "none"){ item.style.display = ""; }
    else {item.style.display = "none"; }
  }else{ item.visibility = "show"; }
}

function ChangeOption(selectedOption) {
  document.getElementById('non_image').style.display = "none";
  document.getElementById('font_box').style.display = "none";

  document.getElementById('mainframe').style.display = "";
  document.getElementById('mainframe').visibility = "show";



 // Закрываем все закладки
/* if (selectedOption != 'poem') {
    ShowOrHide('mainframe');
 }

 if (selectedOption != 'card_color_box') {
    ShowOrHide('mainframe');
 }

 if (selectedOption != 'font_box') {
    ShowOrHide('mainframe');
    document.getElementById('font_box').style.display = "none";
 }

 if (selectedOption != 'mark') {
    ShowOrHide('mainframe');
 }

 if (selectedOption != 'background') {
    ShowOrHide('mainframe');
 }


 if (selectedOption != 'sound') {
    ShowOrHide('mainframe');
 }  */


 /*if (selectedOption != 'sound') {
    document.getElementById('non_image').style.display = "none";
    document.getElementById('mainframe').style.display = "none";
 }  */

 // Открываем Страницы фрейма
 if (selectedOption == 'poem') {
   window.open('poem_ex.php?action=poem_cat', 'uniframe', config='');
  // ShowOrHide('mainframe');
 }

 if (selectedOption == 'card_color_box') {
   window.open('select_color.php?action=card_color', 'uniframe', config='');
  // ShowOrHide('mainframe');
 }

 if (selectedOption == 'font_box') {
   window.open('select_color.php?action=card_fontcolor', 'uniframe', config='');

   ShowOrHide('font_box');
 //  ShowOrHide('mainframe');
 }

 if (selectedOption == 'mark') {
   window.open('mark_ex.php', 'uniframe', config='');
  // ShowOrHide('mainframe');
 }

 if (selectedOption == 'background') {
   window.open('mark_ex.php?action=back', 'uniframe', config='');
  // ShowOrHide('mainframe');
 }

 if (selectedOption == 'sound') {
   window.open('music_ex.php?action=list', 'uniframe', config='');
   //ShowOrHide('mainframe');
 }
}


function playsound(filename) {
 document.all.sound.src = "./music/" + filename;
}


//-->