﻿//Templates output --------------------------------------------------------------------------------------------------------------------------

var affInterfaceOptions = '&pr_code=709OLSX76i6bQ7YIgSzkn5qxoSs4I1&cols=3&rows=4&shop=hyper-color2';

function IncludeAffInterface(options,file){
	if(!file) file = 'pr_interface';
	options = affInterfaceOptions + (options ? '&'+options : '');
	document.write('<SCRIPT type="text/javascript" language="JavaScript" src="http://www.templatehelp.com/codes/'+file+'.php?'+options+'"><'+'/SCRIPT>');
	document.write('<script type="text/javascript">translateToCzechNames();</script>');
}

function Popup(url){
	window.open(
		url,
		'window',
		'width=600, height=600, resizable=yes, scrollbars=yes, location=no,  toolbar=no, menubar=no, status=no'
	);
}
// Hide "www.mytemplatestorage.com" from status bar
function HideStatus(){
	window.status = document.readyState!="complete" ?
		"Loading..." : window.defaultStatus;
}
document.onreadystatechange = HideStatus;

//Templates output --------------------------------------------------------------------------------------------------------------------------

//Code removed from HTML --------------------------------------------------------------------------------------------------------------------
function translateToCzechNames() {
categories = {
 '121':'Alternativní energie',
 '125':'Brewery Templates',
 '115':'Drupal Templates',
 '140':'HTML 5',
 '108':'Joomla/Mambo Templates',
 '138':'jQuery Templates',
 '117':'Magento Templates',
 '118':'Maintenance Services',
 '126':'Mobile Templates',
 '116':'Papervision 3D',
 '127':'SWiSHmax3 Templates',
 '119':'Tools & Equipment',
 '132':'VirtueMart Templates',
 '69':'3-barevné návrhy',
 '62':'3D styl',
 '26':'Architektura',
 '11':'Auta',
 '41':'Bezpečnost',
 '2':'Business',
 '91':'Casina',
 '27':'Cestování',
 '96':'Charita',
 '63':'Čistý styl',
 '95':'CRE šablony',
 '79':'CSS',
 '48':'Dárky',
 '50':'Elektronika',
 '61':'Fireworks návrhy',
 '93':'Flash 8',
 '53':'Flash animované',
 '80':'Flash CMS-lite',
 '98':'Flash Fotoalbum CMS-lite',
 '55':'Flash intro v hlavičce',
 '68':'Flash Site návrhy',
 '92':'Flexibilní',
 '64':'Fóra',
 '60':'Full site',
 '105':'Haloweenové šablony',
 '21':'Hosting',
 '74':'Hotely',
 '67':'Hry',
 '19':'Hudba',
 '87':'Ikonky',
 '24':'Interiéry &amp; Nábytek',
 '6':'Internet',
 '29':'Jídlo &amp; Pití',
 '111':'Joomla šablony',
 '76':'Kavárny a Restaurace',
 '51':'Klenoty',
 '39':'Knihy',
 '72':'Komplexní návrhy',
 '22':'Komunikace',
 '1':'Krása a wellness',
 '17':'Křesťanské a víra',
 '36':'Květiny',
 '10':'Lékařství',
 '86':'Loga',
 '112':'Mambo šablony',
 '18':'Média',
 '49':'Móda',
 '83':'Nejprodávanější',
 '107':'Nezařazené šablony',
 '77':'Noční kluby',
 '42':'Online obchody',
 '84':'osCommerce šablony',
 '66':'Osobní stránky',
 '71':'PHP-Nuke témata',
 '89':'PhpBB2',
 '106':'PhpBB3',
 '3':'Počítače',
 '65':'Politika',
 '5':'Portály',
 '57':'Poslední přidané',
 '34':'Právo',
 '16':'Průmysl',
 '4':'Realitní kanceláře',
 '7':'Rodina',
 '35':'Seznamky',
 '56':'Sleva',
 '23':'Software',
 '32':'Společnost &amp; Kultura',
 '14':'Sport',
 '75':'Svatby',
 '97':'Svatý Valentýn',
 '81':'Swish animované',
 '88':'Swish CMS-lite',
 '109':'SWISHMax2 šablony',
 '43':'Transport a doprava',
 '54':'Umělecké práce',
 '40':'Umění & Fotografie',
 '113':'Vánoční šablony',
 '45':'Věda',
 '25':'Venkovní design',
 '44':'Vojenství',
 '100':'Výběrové šablony',
 '46':'Vzdělávání',
 '102':'Web 2.0 šablony',
 '8':'Web design',
 '94':'WordPress skiny',
 '103':'XML Flash Site',
 '9':'Zábava',
 '78':'Zatím neprodané',
 '114':'Zelené šablony',
 '33':'Zemědělství',
 '101':'Zen cart šablony',
 '47':'Zvířata &amp; Chov zvířat'
};

types = {
 '48':'After Effects Intros',
 '49':'After Effects Logo Reveals',
 '7':'Corporate Identity',
 '18':'CRE Loaded Templates',
 '26':'Drupal Templates',
 '36':'Flash CMS Templates',
 '3':'Flash Intro Templates',
 '19':'Flash Photo Gallery Templates',
 '9':'Flash šablony',
 '12':'Icon Sets',
 '24':'Joomla Templates',
 '5':'Logo Templates',
 '11':'Logosets',
 '27':'Magento Themes',
 '25':'Mambo Templates',
 '42':'Mobile Templates',
 '14':'osCommerce Templates',
 '10':'PHP-Nuke Templates',
 '15':'PhpBB Templates',
 '32':'PowerPoint Templates',
 '43':'PrestaShop Themes',
 '38':'Silverlight Intro Templates',
 '33':'Silverlight Templates',
 '30':'Stock Music',
 '13':'SWiSH Templates',
 '40':'VirtueMart Templates',
 '1':'Website Templates',
 '17':'WordPress Themes',
 '16':'ZenCart Templates'
};

}

var pageName;

function init(page) {
    IncludeAffInterface('categories&authors&types','pr_data.js');
    pageName = page;
}

function typeOutput() {
    for(type_id in types)
    document.write('<li><a target="_self" href="search.html?type='+type_id+'">'+types[type_id]+'</a></li>')
}

var currCatId = -1;

function DrawCategoryItem(catId,catName) {
  if (currCatId != catId){
    document.write(bullet + '<a href="' + url + '?category=' + catId + '" ' + lnkParams + ' target="' + target + '">' + catName + '</a><br />');
  } else {
    document.write(bullet +'<b>' + catName +'</b><br />');
  }
}

function categoryOutput() {
	for(category_id in categories)
		DrawCategoryItem(category_id, categories[category_id]); 
}

function productOptionOutput() {
    for(type_id in types)
    document.write('<option value="'+type_id+'">'+types[type_id]+'</option>')
}

function categoryOptionOutput() {
    for(category_id in categories)
    document.write('<option value="'+category_id+'">'+categories[category_id]+'</option>');
}

function authorOptionOutput() {
    for(author_id in authors)
    document.write('<option value="'+author_id+'">'+authors[author_id]+'</option>');
}

function clearIn(where) {
    var wordsClicked = false;
    if (where == 'keyword' && !wordsClicked) {
        document.forms['search'].keyword.value = "";
        wordsClicked = true;
    }
}

function latestWebsiteTemplatesOutput() {
    IncludeAffInterface('ft=1&ftt=1&sp=0&noscroll=yes&iw=173&ih=297&bgcolor=ffffff');
    IncludeAffInterface('ft=2&ftt=1&sp=0&noscroll=yes&iw=173&ih=297&bgcolor=ffffff');
    IncludeAffInterface('ft=3&ftt=1&sp=0&noscroll=yes&iw=173&ih=297&bgcolor=ffffff');
}

function latestFlashTemplatesOutput() {
    IncludeAffInterface('ft=1&ftt=9&sp=0&noscroll=yes&iw=173&ih=297&bgcolor=ffffff');
    IncludeAffInterface('ft=2&ftt=9&sp=0&noscroll=yes&iw=173&ih=297&bgcolor=ffffff');
    IncludeAffInterface('ft=3&ftt=9&sp=0&noscroll=yes&iw=173&ih=297&bgcolor=ffffff');
}

function footerTypesOutput() {
    for(type_id in types) {
        var tempType=types[type_id];
        while (tempType.indexOf(" ")>=0) {tempType=tempType.replace(" ","&nbsp;");}
        while (tempType.indexOf("-")>=0) {tempType=tempType.replace("-","&macr;");}
        document.write('<li><a target="_self" href="search.html?type='+type_id+'">'+tempType+'</a></li>');
        document.write('<li><span>|</span></li>');
    }
}

function searchResultOutput() {
    affInterfaceOptions += '&cols=3&rows=4&sp=0&iw=520&ih=1280&bgcolor=%23ffffff&noscroll=yes';
}


//Code removed from HTML --------------------------------------------------------------------------------------------------------------------

//Inner formating, adjustments and corections -----------------------------------------------------------------------------------------------


    //Footer type links begin
     function correctFooter() {
     	 if (pageName == "search")
     	 	setActiveMenusForm();
     
         var footerList=document.getElementById('footerMenu').getElementsByTagName('a');
         var lineWidth=0;
         var correctedMenu="";
         for (i=0;i<footerList.length;i++) {
             lineWidth = lineWidth + footerList[i].offsetWidth + 25;
             //alert(footerList[i].parentNode.innerHTML+ " - " + footerList[i].offsetWidth);
             if (lineWidth>955) {
                 correctedMenu=correctedMenu+'<br />';
                 correctedMenu=correctedMenu+'<li>'+footerList[i].parentNode.innerHTML+'</li>';
                 lineWidth=footerList[i].offsetWidth;
             }
             else if (correctedMenu=="") {
                 correctedMenu=correctedMenu+'<li>'+footerList[i].parentNode.innerHTML+'</li>';
                 
             }
             else {
                 correctedMenu=correctedMenu+'<li><span>|</span></li>';
                 correctedMenu=correctedMenu+'<li>'+document.getElementById('footerMenu').getElementsByTagName('a')[i].parentNode.innerHTML+'</li>';
             }
         }
         while (correctedMenu.indexOf("Â¯")>=0) {correctedMenu=correctedMenu.replace("Â¯","-");} //Replacing dash back for correct width calculating of "a" tag element
         document.getElementById('footerMenu').innerHTML=correctedMenu;
         document.getElementById('footerMenu').style.visibility='visible';
     }
      //Footer type links end

      //Html entity decode function
      function html_entity_decode(str) {
          var ta=document.createElement("textarea");
          ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
          return ta.value;
      }
      //Html entity decode function

      function setActiveMenusForm() {
          var URL=window.location.href;
          var typeValue=0;
          var categoryValue=0;
          var categoriesList=new Array();
          var typesList=new Array();
          URL=URL.substring(URL.indexOf("?")+1);
          URL=decodeURI(URL);

          //Replacing "+" symbols with space
          while (URL.indexOf("+")>=0) {URL=URL.replace("+"," ");}

          //Detect type value begin
          if (URL.match("type=")!=null) {
              var type=URL.substring(URL.indexOf("type="));
              var typeOptions;
              if (type.length>5 & type.match("&")!=null) {
                  type=type.substring(0,type.indexOf("&"));
                  if (type.length>5) {
                      typeValue=type.substring(5);
                      typeOptions=document.getElementById('productSelect').options;
                      for(i=0;i<typeOptions.length;i++) {
                          if (typeOptions[i].value==typeValue) {typeOptions[i].selected=true;
                          }
                      }
                  }
              }
              else {
                  if (type.length>5) {
                      typeValue=type.substring(5);
                      typeOptions=document.getElementById('productSelect').options;
                      for(i=0;i<typeOptions.length;i++) {
                          if (typeOptions[i].value==typeValue) {typeOptions[i].selected=true;}
                      }
                  }
              }
          }
          //Detect type value end

          //Detect category value begin
          if (URL.match("category=")!=null) {
              var category=URL.substring(URL.indexOf("category="));
              var categoryOptions;
              if (category.length>9 & category.match("&")!=null) {
                  category=category.substring(0,category.indexOf("&"));
                  if (category.length>9) {
                      categoryValue=category.substring(9);
                      categoryOptions=document.getElementById('categorySelect').options;
                      for(i=0;i<categoryOptions.length;i++) {
                          if (categoryOptions[i].value==categoryValue) {categoryOptions[i].selected=true;}
                      }
                  }
              }
              else {
                  if (category.length>9) {
                      categoryValue=category.substring(9);
                      categoryOptions=document.getElementById('categorySelect').options;
                      for(i=0;i<categoryOptions.length;i++) {
                          if (categoryOptions[i].value==categoryValue) {categoryOptions[i].selected=true;}
                      }
                  }
              }
          }
          //Detect category value end

          //Detect author value begin
          if (URL.match("author=")!=null) {
              var author=URL.substring(URL.indexOf("author="));
              var authorValue;
              var authorOptions
              if (author.length>7 & author.match("&")!=null) {
                  author=author.substring(0,author.indexOf("&"));
                  if (author.length>7) {
                      authorValue=author.substring(7);
                      authorOptions=document.getElementById('authorSelect').options;
                      for(i=0;i<authorOptions.length;i++) {
                          if (authorOptions[i].value==authorValue) {authorOptions[i].selected=true;}
                      }
                  }
              }
              else {
                  if (author.length>7) {
                      authorValue=author.substring(7);
                      authorOptions=document.getElementById('authorSelect').options;
                      for(i=0;i<authorOptions.length;i++) {
                          if (authorOptions[i].value==authorValue) {authorOptions[i].selected=true;}
                      }
                  }
              }
          }
          //Detect author value end

          //Detect keyword value begin
          if (URL.match("keyword=")!=null) {
              var keyword=URL.substring(URL.indexOf("keyword="));
              var keywordValue;
              if (keyword.length>8 & keyword.match("&")!=null) {
                  keyword=keyword.substring(0,keyword.indexOf("&"));
                  if (keyword.length>8) {
                      keywordValue=keyword.substring(8);
                      document.getElementById('keywordInput').value=keywordValue;
                  }
              }
              else {
                  if (keyword.length>8) {
                      keywordValue=keyword.substring(8);
                      document.getElementById('keywordInput').value=keywordValue;
                  }
              }
          }
          //Detect keyword value end

          //Detect number value begin
          if (URL.match("number=")!=null) {
              var number=URL.substring(URL.indexOf("number="));
              var numberValue;
              if (number.length>7 & number.match("&")!=null) {
                  number=number.substring(0,number.indexOf("&"));
                  if (number.length>7) {
                      numberValue=number.substring(7);
                      document.getElementById('numberInput').value=numberValue;
                  }
              }
              else {
                  if (number.length>7) {
                      numberValue=number.substring(7);
                      document.getElementById('numberInput').value=numberValue;
                  }
              }
          }
          //Detect number value end

          //Detect price1 value begin
          if (URL.match("price1=")!=null) {
              var lowPrice=URL.substring(URL.indexOf("price1="));
              var lowPriceValue;
              if (lowPrice.length>7 & lowPrice.match("&")!=null) {
                  lowPrice=lowPrice.substring(0,lowPrice.indexOf("&"));
                  if (lowPrice.length>7) {
                      lowPriceValue=lowPrice.substring(7);
                      document.getElementById('lowPriceInput').value=lowPriceValue;
                  }
              }
              else {
                  if (lowPrice.length>7) {
                      lowPriceValue=lowPrice.substring(7);
                      document.getElementById('lowPriceInput').value=lowPriceValue;
                  }
              }
          }
          //Detect price1 value end

          //Detect price2 value begin
          if (URL.match("price2=")!=null) {
              var highPrice=URL.substring(URL.indexOf("price2="));
              var highPriceValue;
              if (highPrice.length>7 & highPrice.match("&")!=null) {
                  highPrice=highPrice.substring(0,highPrice.indexOf("&"));
                  if (highPrice.length>7) {
                      highPriceValue=highPrice.substring(7);
                      document.getElementById('highPriceInput').value=highPriceValue;
                  }
              }
              else {
                  if (highPrice.length>7) {
                      highPriceValue=highPrice.substring(7);
                      document.getElementById('highPriceInput').value=highPriceValue;
                  }
              }
          }
          //Detect price2 value end

          //Set active type
          if (typeValue!=0) {
              var types = document.getElementById('templateTypeMenu').getElementsByTagName('a');
                for(i=0;i<types.length;i++) {
                   var typeUrl = types[i].href;
                   var ti=typeUrl.indexOf("type=");
                   var menuType = typeUrl.substr(ti+5);
                   //Creating array of types
                   typesList[menuType]=types[i].innerHTML;
                   if (typeValue==menuType) {types[i].className='activeType';}
                }
          }

          //Set active category begin
          if (categoryValue!=0) {
               var categories = document.getElementById('templateCategoryMenu').getElementsByTagName('a');
                for(i=0;i<categories.length;i++) {
                   var categoryUrl = categories[i].href;
                   var ci=categoryUrl.indexOf("category=");
                   var menuCategory = categoryUrl.substr(ci+9);
                   //Creating array of categories
                   categoriesList[menuCategory]=categories[i].innerHTML;
                   if (categoryValue==menuCategory) {categories[i].className='activeCategory';}
                }
          }
          //Set active category end

          //Set searchResult title begin
          if (categoryValue!=0 || typeValue!=0) {
              if (categoryValue!=0 && typeValue!=0) {
              }
              else {
                  if (categoryValue!=0) {
                      document.getElementById('searchResultTitle').innerHTML=categoriesList[categoryValue];
                      document.title=html_entity_decode(categoriesList[categoryValue]);
                  }
                  else if (typeValue!=0) {
                      document.getElementById('searchResultTitle').innerHTML=typesList[typeValue];
                      document.title=html_entity_decode(typesList[typeValue]);
                  }
              }
          }
          //Set searchResult title end
    }
     
    /*function setSearchPage() {
        setActiveMenusForm();
        correctFooter();
    }*/

//Inner formating, adjustments and corections -----------------------------------------------------------------------------------------------

