function Browser()
{
  var agt=navigator.userAgent.toLowerCase();
  this.mjr=parseInt(navigator.appVersion);
  this.mnr=parseFloat(navigator.appVersion);
  this.nav=((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1)));
  this.nav2=(this.nav && (this.mjr==2));
  this.nav3=(this.nav && (this.mjr==3));
  this.nav4=(this.nav && (this.mjr==4));
  this.nav4up=this.nav && (this.mjr>=4);
  this.mozilla=(this.nav&&(this.mjr>=5)&&(agt.indexOf('gecko')!=-1))||((this.mjr>=5)&&(agt.indexOf('gecko')!=-1)&&(agt.indexOf('firefox')!=-1));
  this.navonly   =(this.nav && (agt.indexOf(";nav")!=-1));
  this.ie=(agt.indexOf("msie") != -1);
  this.ie3=(this.ie && (this.mjr==2));
  this.ie4=(this.ie && (this.mjr==4));
  this.ie4up=this.ie && (this.mjr>=4);
  this.opera=(agt.indexOf("opera")!=-1);
  if (this.nav2 || this.ie3) this.js=1.0; else
   if (this.nav3 || this.opera) this.js=1.1; else
    if (this.nav4 || this.ie4) this.js=1.2; else
     if ((this.nav && (this.mnr > 4.05)) || (this.ie && (this.mjr>4))) this.js=1.2; else this.js=0.0;
}
var is;
var isIE3Mac=false;

if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) &&
    (parseInt(navigator.appVersion)==3)) isIE3Mac=true; else  is=new Browser();

function isIE4up()
{
  if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.charAt(0) >= 4) return true;
  else return false;
}
//--------------------------------------
function setMode(mode)
{
    frm=document.forms.data;
    frm.mode.value=mode;
    frm.submit();
}

//------------------------------
function nextModeStep(mode,step, action)
{

    frm=document.forms.data;
	if ( mode == 'first' ) {
		//var new_action ='http://'+action;
		//frm.action = '';
		frm.action ='http://'+action;
		//alert(frm.action);
	}else{
		frm.action = action;
	}
    frm.mode.value=mode;
    frm.submode.value=step;
    frm.submit();
}

//------------------------------

function PictureMouseOver(image) { if (isIE4up) image.className="menuPictureNR"; }
function PictureMouseOut(image) { if (isIE4up) image.className="menuPictureHL"; }

//------------------------------
function openVar(id,cid)
{
    w=window.open("fillVar.php?id="+id+"&cid="+cid,"","");
}
//------------------------------
function showPopUpTip(name)
{
    //alert(name);
    window.open("./view_popupTip.php?name="+name, "DetailWindow", "toolbar=no,width=550,height=600,directories=no,status=no,scrollbars=yes, resizable=yes, menubar=no, location=no");
}
//------------------------------------


//------------------------------------
/* popups agreement window  */
function goOpenAgr(name)
{
    if (typeof(name)=="undefined")
        name="";
    if (document.forms.data.action == 'index.php')
	    wnd = window.open("./source/view_popup.inc.php?language="+document.forms.data.cid.value+"&varname="+name, "Agreement", "toolbar=no,width=560,height=500,directories=no,status=no,scrollbars=yes,resizable=no,menubar=yes, location=yes");
	else
	   wnd = window.open("./linkreg/source/view_popup.inc.php?language="+document.forms.data.cid.value+"&varname="+name, "Agreement", "toolbar=no,width=560,height=500,directories=no,status=no,scrollbars=yes,resizable=no,menubar=yes, location=yes");
}
//------------------------------------
function popupPMI(mode)
{
    wnd = window.open("../include/top_popup.inc.php?language="+document.forms.data.cid.value+"&mode="+mode, "PopUp", "toolbar=no,width=560,height=420,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
}
//------------------------------------
function GoPopupVariable(name){
    wnd = window.open("../include/view_popup_add.inc.php?language="+document.forms.data.cid.value+"&varname="+name, "vitamin_table", "toolbar=no,width=320,height=400,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
  }
//------------------------------------
function setActivePayType(type)
{
    switch (type)
    {
        case 0:
        case 1:
        case 5:
        case 6:
        //credit card
            if (document.getElementById("route_no")) document.getElementById("route_no").value='';
            if (document.getElementById("account_no")) document.getElementById("account_no").value='';
            if (document.getElementById("bank_name")) document.getElementById("bank_name").value='';
            if (document.getElementById("check_no")) document.getElementById("check_no").value='';
            if (document.getElementById("card_no")) document.getElementById("card_no").focus();
        break;
        //----------
        case 3:
           if (document.getElementById("card_no")) document.getElementById("card_no").value='';
           if (document.getElementById("card_pin")) document.getElementById("card_pin").value='';
           if (document.getElementById("card_exp_date")) document.getElementById("card_exp_date").value='';
           if (document.getElementById("card_name")) document.getElementById("card_name").value='';
           if (document.getElementById("route_no")) document.getElementById("route_no").focus();
        //bank
        break
        //------------
        case 4:
        //cash
        //------------
        case -1:
        case 7:
           if (document.getElementById("route_no")) document.getElementById("route_no").value='';
           if (document.getElementById("account_no")) document.getElementById("account_no").value='';
           if (document.getElementById("bank_name")) document.getElementById("bank_name").value='';
           if (document.getElementById("check_no")) document.getElementById("check_no").value='';
           if (document.getElementById("card_no")) document.getElementById("card_no").value='';
           if (document.getElementById("card_pin")) document.getElementById("card_pin").value='';
           if (document.getElementById("card_exp_date")) document.getElementById("card_exp_date").value='';
           if (document.getElementById("card_name")) document.getElementById("card_name").value='';


        break;
        //------------
        default:
    }
    return 1;
}

//-use in second step of linkreg registration   ------------------------------------
function setActivePayType2(type)
{
    switch (type)
    {
        case 0:
        case 1:
        case 5:
        case 6:
        //credit card
            if (document.getElementById("route_no")) document.getElementById("route_no").value='';
            if (document.getElementById("account_no")) document.getElementById("account_no").value='';
            if (document.getElementById("bank_name")) document.getElementById("bank_name").value='';
            if (document.getElementById("check_no")) document.getElementById("check_no").value='';
            if (document.getElementById("card_no")) document.getElementById("card_no").focus();
        break;
        //----------
        case 3:
           if (document.getElementById("card_no")) document.getElementById("card_no").value='';
           if (document.getElementById("card_pin")) document.getElementById("card_pin").value='';
           if (document.getElementById("card_exp_date")) document.getElementById("card_exp_date").value='';
           if (document.getElementById("card_name")) document.getElementById("card_name").value='';
           if (document.getElementById("route_no")) document.getElementById("route_no").focus();
        //bank
        break
        //------------
        case 4:
        //cash
        //------------
        case -1:
        case 7:
           if (document.getElementById("route_no")) document.getElementById("route_no").value='';
           if (document.getElementById("account_no")) document.getElementById("account_no").value='';
           if (document.getElementById("bank_name")) document.getElementById("bank_name").value='';
           if (document.getElementById("check_no")) document.getElementById("check_no").value='';
           if (document.getElementById("card_no")) document.getElementById("card_no").value='';
           if (document.getElementById("card_pin")) document.getElementById("card_pin").value='';
           if (document.getElementById("card_exp_date")) document.getElementById("card_exp_date").value='';
           if (document.getElementById("card_name")) document.getElementById("card_name").value='';

        break;
        //------------
        default:
    }
    frm=document.forms.data;
    frm.updateData.value=1;
    nextModeStep('main','getInfo2');

    return 1;
}
//---------------------------------------------------------------------------------

//------------------------------------
function openAdd()
{
    wnd = window.open("index.php?PHPSESSID="+document.forms.data.PHPSESSID.value+"&mode=addAddr", "addAddr", "toolbar=no,width=420,height=300,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
}

/* popups warning window  */
function goOpenWarn(name)
{
    if (typeof(name)=="undefined")
        name="";
	    wnd = window.open("./source/view_warn.inc.php?language="+document.forms.data.cid.value+"&varname="+name, "Agreement", "toolbar=no,width=560,height=500,directories=no,status=no,scrollbars=yes,resizable=no,menubar=yes, location=yes");

}
//------------------------------------

function setCouponCountry(code) {
	document.getElementById('coupon_country').value=code;
}
//

function goText(name) {
	  frm = document.forms.show_text;
	  frm.textname.value=name;
	  frm.submit();
  }
  
function goFooterLink(id) {
	  frm = document.forms.show_text;
	  frm.footer_link_id.value=id;
	  frm.submit();
}  
