

<!--

var jslock=1;
var swfMenu = 'false';
var swfQuality = 'auto';
var strFV = '';

function BuildFlash(path, w, h, bckgColor, vars, name, live)
{
    var str = '';
    if ((path != '') && (path != undefined)) {  
        var myRand = Math.random().toString().split(".");
        var divFlashName = "flash" +myRand[1];
        document.write('<div id=\"' +divFlashName+ '\"></div>');
        var so = new SWFObject(path, name, w, h, 8, bckgColor);
        so.addParam("wmode", "transparent");
        var fvValues;
        var fvArray = vars.split("&");
        for(i=0;i<fvArray.length;i++) {
            fvValues = "";
            fvValues = fvArray[i].split("=");
            if(fvValues[0] != "" && fvValues[1] != "undefined")
            {
                so.addVariable(fvValues[0],fvValues[1]);        
            }
        }
        so.write(divFlashName);
    }
}




function BuildFlash_OLD(path, w, h, bckgColor, vars, name, live)
{
var str = '';
var wmode = 'transparent';
if ((path != '') && (path != undefined)) {
str = '<object type="application/x-shockwave-flash" data="'+ path +'" width="'+ w +'" height="'+ h +'" id="'+ name +'">' +
'<param name="movie" value="'+ path +'"/>' +
'<param name="quality" value="' + swfQuality + '"/>' +
'<param name="bgcolor" value="'+ bckgColor +'"/>' +
'<param name="wmode" value="'+ wmode +'"/>' +
'<param name="menu" value="' + swfMenu + '"/>' +
'<param name="flashvars" value="' + vars + '"/>' +
'<param name="allowScriptAccess" value="sameDomain" />' +
'</object>';
}
document.write(str);
}

function escapeURI(str) {
  str = str.replace(/=/g, '%3D'); 
  str = str.replace(/&/g, '%26');
  str = str.replace(/"/g, '%22');
  return str;
}
function test() {
  alert('test');
}
function getQuerryStringByName(name){
  url = new String(window.location);
  var xx=String(document.location.search);
  str_tmp = url.split("?");
  
  if( str_tmp.length < 2 ) return "";
  querry = str_tmp[1];
  
  if (xx.match(/%20\w+=/)) // haszcz
  { 
    element = querry.split(escape("&"));
  }
  else // bez haszcza
  {
    element = querry.split("&");
  }  
  i=0;
  while(i<element.length){
      e = element[i];
      _item =  e.split("=");
      if(_item[0] == name){
        return _item[1];
      }
      i++;
  }
  return "";
}

function okno(nazwa,szer,wys)
 {
 window.open(nazwa,'','toolbar=no,scrollbars=yes,resizable=no,status=no,location=no,directories=no,width='+eval(szer)+',height='+eval(wys)+',menubar=no')
 }

function my_window_open(url,wname,params) {
        if (typeof(Error)!='undefined') {
                eval("try { _xx_wo=window.open(url,wname,params); } catch(_xx_ev) {}");
        } else {
                _xx_wo=window.open(url,wname,params);
        }
        if(!_xx_wo) {
                _xx_url = url;
                _xx_wname = wname;
                _xx_params = params;
                if (document.attachEvent) document.attachEvent("onclick", xx_wopen);
                else if(document.addEventListener) document.addEventListener("click", xx_wopen, false);
        }
}

function OpenWindow(url, title, w, h) {
 if(window.screen) {
  aw = screen.availwidth;
  ah = screen.availheight;
 } else {
  aw = 640;
  ah = 450;
 }
 settings =
        "left="+(aw-w)/2+","
        +"top="+(ah-h)/2+","
        +"screenX="+(aw-w)/2+","
        +"screenY="+(ah-h)/2+","
        +"width="+w+","
        +"height="+h+","
        +"toolbar=no,"
        +"location=no,"
        +"directories=no,"
        +"status=no,"
        +"menubar=no,"
        +"scrollbars=no,"
        +"resizable=no" 
 my_window_open(url, title, settings);
 //newWindow = window.open(url, title, settings);
 //newWindow.focus();
}

function OpenWindowScroll(url, title, w, h) {
 if(window.screen) {
  aw = screen.availwidth;
  ah = screen.availheight;
 } else {
  aw = 640;
  ah = 450;
 }
 settings =
        "left="+(aw-w)/2+","
        +"top="+(ah-h)/2+","
        +"screenX="+(aw-w)/2+","
        +"screenY="+(ah-h)/2+","
        +"width="+w+","
        +"height="+h+","
        +"toolbar=no,"
        +"location=no,"
        +"directories=no,"
        +"status=no,"
        +"menubar=no,"
        +"scrollbars=yes,"
        +"resizable=no" 
 my_window_open(url, title, settings);
 //newWindow = window.open(url, title, settings);
 //newWindow.focus();
}


/* FAQ */
    function expandFAQ() {
        for (i=0;i<faqArr.length;i++) {
            var obj = document.getElementById(faqArr[i]);
            if (obj.tagName == 'DIV') {
                obj.style.display = (document.all) ? 'block' : 'table-row';
            }
            if (obj.tagName == 'DIV') {
                obj.style.display = 'block';
            }
        }
    }
    function collapseFAQ() {
        for (i=0;i<faqArr.length;i++) {
            var obj = document.getElementById(faqArr[i]);
            if (obj.tagName == 'DIV') {
                obj.style.display = 'none';
            }
            if (obj.tagName == 'DIV') {
                obj.style.display = 'none';
            }
        }        
    }
function swapFAQ(faqID) {
    var obj = document.getElementById(faqID);
    var s = obj.style;
    if (document.all) {
        if (s.display == 'none') {
            s.display = 'block';
        } else if (s.display == 'block') {
            s.display = 'none';
        }
    } else {
        if (s.display == 'none') {
            s.display = 'table-row';
        } else if (s.display == 'table-row') {
            s.display = 'none';
        }
    }
}
/* /FAQ */

function resizeFlash(val) {
 clearTimeout(t);
 val = Math.round(val);
 if (jslock == 0){
  document.getElementById('flash').style.height = val+'px';
 } else {
  t = setTimeout("resizeFlash("+val+")", 500);
 }
}

function URLEncode(plaintext) {
 // The Javascript escape and unescape functions do not correspond
 // with what browsers actually do...
 var SAFECHARS = "0123456789" +     // Numeric
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
     "abcdefghijklmnopqrstuvwxyz" +
     "-_.!~*'()";     // RFC2396 Mark characters
 var HEX = "0123456789ABCDEF";
 var encoded = "";
 for (var i = 0; i < plaintext.length; i++ ) {
  var ch = plaintext.charAt(i);
     if (ch == " ") {
      encoded += "+";    // x-www-urlencoded, rather than %20
  } else if (SAFECHARS.indexOf(ch) != -1) {
      encoded += ch;
  } else {
      var charCode = ch.charCodeAt(0);
   if (charCode > 255) {
       alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
              "(URL encoding only supports 8-bit characters.)\n" +
        "A space (+) will be substituted." );
    encoded += "+";
   } else {
    encoded += "%";
    encoded += HEX.charAt((charCode >> 4) & 0xF);
    encoded += HEX.charAt(charCode & 0xF);
   }
  }
 } // for
 return encoded;
}

function add2Favourite() {
var title = 'Odkryj dania Tex-Mex z Delectą!'
var url = 'http://www.odkryjmeksyk.pl/';

 if (window.sidebar) { // FF
  window.sidebar.addPanel(title, url,"");
 } else if( window.external ) { // IE 
  window.external.AddFavorite(url, title);
 }
 else { // ALL
  alert('Funkcja jest nieaktywna w Twojej przeglądarce');
}
}


function s2f() {
 var formUrl = '/send2friend.htm';
 OpenWindow(formUrl, 'S2F', 405, 375);}


/* schowek */
function createCookie(name,value,days)
{
 if (days)
 {
  var date = new Date();
  date.setTime(date.getTime()+(days*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
 }
 else var expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++)
 {
  var c = ca[i];
  while (c.charAt(0)==' ') c = c.substring(1,c.length);
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return null;
}
function eraseCookie(name)
{
 createCookie(name,"",-1);
}
function isValExist(value, search){
 if(value.indexOf(search) > -1) {
  return true;
 }
 else return false;
}
function saveNewPrzepis(id){
 var cookieName = 'przepisySaved';
 id = parseInt(id);
 if(!id) return false;
 
 val = readCookie(cookieName);
 
 if(val) {
  if(isValExist(val, id)) { // sprawdz czy jest juz taka value
   //alert("Wartosc" + val + " juz jest");
   return true;
  }
 }
 else {
  val = '';
  //alert ("Brak cookiesa");
 }
 val = val + id + '%7C';  
 createCookie(cookieName,val,365);// dodaj nowa wartosc
 //alert(val);
 return true;
}
function addPrzepis(id){
 r = saveNewPrzepis(id);
 if (r)
 {
    writeCookBookRecipesCount();
  alert("Przepis został dodany do Książki Kucharskiej.");
 }
}


function  getCookBookRecipesCount() {
 var cookieVal = readCookie('przepisySaved');
 if (cookieVal != null || typeof counter != 'undefined') {
  cookieVal = unescape(cookieVal);
  var recipes = cookieVal.split('|');
  var recipesCount = recipes.length-1;
  if (recipesCount == 1) return recipesCount + ' przepis.';
  if (recipesCount == 2 || recipesCount == 3 || recipesCount == 4) return recipesCount + ' przepisy.';
  if (recipesCount >= 5) return recipesCount + ' przepisów.';
 } else {
  return '0 przepisów.';
 }
}
function writeCookBookRecipesCount() {
 var counter = document.getElementById('count');
 if (counter != null) counter.innerHTML = getCookBookRecipesCount();
}


/* /schowek */




function newsletter_n(field,state) {
field.value = ((state == 0) && (field.value=="Twój e-mail")) ? "" : field.value;
field.value = ((state == 1) && (field.value=="")) ? "Twój e-mail" : field.value;
}

function validateEmail(form) {
var f= form.elements['for_email'];
if (f.value.length != 0) {
    var tmp = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i;
    if (!tmp.test(f.value)) {
        alert("Wprowadź poprawny adres e-mail."); 
        f.focus();
        return false;
    }
    return true;
}
return false;
}

function validate_userRecipe(){
 var f= document.sendPrzepis.nazwa;
  if (f.value==''){
  alert("Podaj nazwę przepisu.");
  f.focus();
  return false;
 }
 var f= document.sendPrzepis.skladniki;
 if (f.value==''){
  alert("Podaj składniki przepisu.");
  f.focus(); 
  return false;
 }

if (document.sendPrzepis.tresc.value=='' && document.sendPrzepis.zdjecie.value==''){
alert("Wypelnij treść przepisu lub dodaj zdjęcie.");
return false;
} 

 var f= document.sendPrzepis.nick;
 if (f.value==''){
  alert("Podaj imię/nazwisko/nick.");
  f.focus(); 
  return false;
 }

var f= document.sendPrzepis.email;
 
 if (f.value=='' ){
  alert('Brak adresu e-mail');
       f.focus();
  return false;
   }

var f= document.sendPrzepis.email;
 if (f.value.length != 0) {
  var tmp = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i;
  if (!tmp.test(f.value)) {
    alert("Wprowadź poprawny adres e-mail."); 
       f.focus();
    return false;
    }
 }

var m1 = -1;
for (i=document.sendPrzepis.danie.length-1; i > -1; i--) {
    if (document.sendPrzepis.danie[i].checked) {
        m1 = i; i = -1;
    }
}
var m2 = -1;
for (i=document.sendPrzepis.czas.length-1; i > -1; i--) {
    if (document.sendPrzepis.czas[i].checked) {
        m2 = i; i = -1;
    }
}

if (m1 == -1 && m2 == -1) {
  alert("Wybierz pikantność dania i czas przygotowania.");
  document.sendPrzepis.danie.item(0).focus();
  return false;
} else if (m1 == -1) {
  alert("Wybierz pikantność dania.");
  document.sendPrzepis.danie.item(0).focus();
  return false;
} else if (m2 == -1) {
  alert("Wybierz czas przygotowania.");
  document.sendPrzepis.czas.item(0).focus();
  return false;
}

 return true;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function reg(url)
{
document.forms['photo_add'].elements['regulamin'].value = 'tak';
document.forms['photo_add'].elements['oswiadczenie'].checked = true;
var regwin = OpenWindowScroll(url,'Regulamin',980,600);
}
function validateKonkurs(form) {
var f = form.elements['sender_name'];
if (f.value < 1) {
 alert('Wpisz swoje imię, nazwisko bądź nick.');
 f.focus();
 return false;
}
var f = form.elements['photo_title'];
if (f.value < 1) {
 alert('Wpisz tytuł zdjęcia.');
 f.focus();
 return false;
}
var f = form.elements['photo_desc'];
if (f.value < 1) {
 alert('Opisz zdjęcie.');
 f.focus();
 return false;
}
var f = form.elements['sender_mail'];
if (f.value < 1) {
 alert('Podaj adres e-mail.');
 f.focus();
 return false;
}
var tmp = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i;
var f = form.elements['sender_mail'];
if (!tmp.test(f.value)) {
 alert('Podaj prawidłowy adres e-mail.');
 f.focus();
 return false;
}
var f = form.elements['photo_file'];
if (f.value < 1) {
 alert('Załącz zdjęcie.');
 f.focus();
 return false;
}
var f = form.elements['zgoda'];
if (f.checked != true) {
 alert('Musisz wyrazić zgodę na umieszczenie swoich danych w bazie.');
 f.focus();
 return false;
}
var f = form.elements['regulamin'];
if (f.value != 'tak') {
 alert('Musisz zapoznać się z regulaminem, kliknij w link regulaminu.');
 form['oswiadczenie'].focus();
 return false;
}
var f = form.elements['oswiadczenie'];
if (f.checked != true) {
 alert('Musisz zaakceptować regulamin.');
 f.focus();
 return false;
}
return true;
}


function zoomImage (s) {
   var x=0; 
   var y=0; 
   var pWin=0;
   if (s == '') return;
   var str = '<ht' + 'ml><he' + 'ad><ti' + 'tle>OdkryjMeksyk.pl</ti' + 'tle><style type="text/css">body {margin: 0; padding: 0; background: #fff; }</style></he'+'ad><bo'+'dy ><a href="javascript:self.close()"><img id="image" src='+s+' border="0" onload="var widthImage = document.getElementById(\'image\').width;var heightImage = document.getElementById(\'image\').height ;window.resizeTo(widthImage,heightImage);"></a></bo' + 'dy></ht' + 'ml>';
   if (!pWin || pWin.closed) {
   pWin = window.open('about:blank','pWin','dependent=yes,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,left=10,top=10')
}
pWin.document.open();
pWin.document.write(str);
pWin.document.close();
pWin.focus();
}



function validateRecipeSearchForm() {
    var f1 = document.forms['recipe_search'];
    var fl1 = document.forms['recipe_search'].elements['skladnik'];
    var fl2 = document.forms['recipe_search'].elements['skladnik1'];
    if (fl1.value.length == 0 && fl2.value.length == 0)
    {
        alert('Proszę podać minimum jeden składnik.');
        fl1.focus();
        return false;
    }
    return true;
}

function playMP3(filePath) {
 var f=document.getElementById('mp3Player');
 f.SetVariable('mp3File', filePath);
 return false;
}


$(document).ready(function () {
    if ($("#mainMenu").length > 0) {
        var selectedItem = $("#mainMenu").attr("class");
        selectedItem = parseInt(selectedItem.replace(/active/,'')) - 1;
        $("#mainMenu li:eq("+selectedItem+") a").addClass("active");
    }
    if ( $("#subSectionNaviC ul").length > 0 ) {
        var selectedItem = $("#subSectionNaviC ul").attr("class");
        selectedItem = parseInt(selectedItem.replace(/active/,'')) - 1;
        $("#subSectionNaviC ul li:eq("+selectedItem+")").addClass("active");
    }    

})
//-->
