//Templates output --------------------------------------------------------------------------------------------------------------------------

var affInterfaceOptions = '&pr_code=6RgWr7mnU0z8h83d5AcVd2Hl8G3x51&cols=3&rows=4&shop=z1-gray-green&currency=1&locale=Hu&bgcolor=ebebc8';

function IncludeAffInterface(options,file){
	if(!file) file = 'pr_interface';
	options = affInterfaceOptions + (options ? '&'+options : '');
	document.write('<SCRIPT type="text/javascript" language="JavaScript" src="http://www.mytemplatestorage.com/codes/'+file+'.php?'+options+'"><'+'/SCRIPT>');
}


function Popup(url){
	window.open(
		url,
		'window',
		'width=530, height=810, 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 init() {
    IncludeAffInterface('categories&authors&types','pr_data.js');
}

function clearIn(where) {
    var wordsClicked = false;
    if (where == 'keyword' && !wordsClicked) {
        document.forms['aff_custom_search_form'].keyword.value = "";
        wordsClicked = true;
    }
}

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 latestWebsiteTemplatesOutput() {
    IncludeAffInterface('ft=1&ftt=1&sp=0&ih=290&iw=170&noscroll=1');
    IncludeAffInterface('ft=2&ftt=1&sp=0&ih=290&iw=170&noscroll=1');
    IncludeAffInterface('ft=3&ftt=1&sp=0&ih=290&iw=170&noscroll=1');
    IncludeAffInterface('ft=4&ftt=1&sp=0&ih=290&iw=170&noscroll=1');
}

function latestFlashTemplatesOutput() {
	IncludeAffInterface('ft=1&ftt=9&sp=0&ih=290&iw=170&noscroll=1');
	IncludeAffInterface('ft=2&ftt=9&sp=0&ih=290&iw=170&noscroll=1');
	IncludeAffInterface('ft=3&ftt=9&sp=0&ih=290&iw=170&noscroll=1');
	IncludeAffInterface('ft=4&ftt=9&sp=0&ih=290&iw=170&noscroll=1');
}

function searchResultOutput() {
    affInterfaceOptions += '&cols=4&rows=3&sp=0&iw=530&ih=81&bgcolor=%23202020&noscroll=yes';
    IncludeAffInterface(window.location.search.substring(1));
}

//Code removed from HTML --------------------------------------------------------------------------------------------------------------------

//Inner formating, adjustments and corections -----------------------------------------------------------------------------------------------

      //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++) {
                          //Creating array of types
                          typesList[typeOptions[i].value]=typeOptions[i].innerHTML;
                          //Creating array of types
                          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++) {
                          //Creating array of types
                          typesList[typeOptions[i].value]=typeOptions[i].innerHTML;
                          //Creating array of types
                          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].text==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].text==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 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('types').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);
                   if (typeValue==menuType) {types[i].className='activeType';}
                }
          }

          //Set active category begin
          if (categoryValue!=0) {
               var categories = document.getElementById('categories').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 &&(highPriceValue==undefined || lowPriceValue==undefined || keywordValue==undefined)) {
              if (categoryValue!=0 && typeValue!=0) {
              }
              else {
                  if (typeValue!=0) {
                      document.getElementById('searchResultTitle').innerHTML=typesList[typeValue];
                      document.title=html_entity_decode(typesList[typeValue]);
                  }

                  else {
                      document.getElementById('searchResultTitle').innerHTML=categoriesList[categoryValue];
                      document.title=html_entity_decode(categoriesList[categoryValue]);
                  }
              }
          }
          //Set searchResult title end

      }

//Inner formating, adjustments and corections -----------------------------------------------------------------------------------------------
/* ************************************************** */

function openwindow() /*  */
{
window.open("http://www.memex.hu/SablonBolt/bankkartyas-vasarlas-video1.htm",
	"mywindow","location=1,status=1,scrollbars=1,width=850,height=580");
}


// ************* COPY TO CLIPBOARD FUNCTION **********************

			function copyToClipboard(s)
			{
				if( window.clipboardData && clipboardData.setData )
				{
					clipboardData.setData("Text", s);
				}
				else
				{
					// You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true);
					netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

					var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
				   if (!clip) return;
				   
				   // create a transferable
				   var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
				   if (!trans) return;
				   
				   // specify the data we wish to handle. Plaintext in this case.
				   trans.addDataFlavor('text/unicode');
				   
				   // To get the data from the transferable we need two new objects
				   var str = new Object();
				   var len = new Object();
				   
				   var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);
				   
				   var copytext=meintext;
				   
				   str.data=copytext;
				   
				   trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);
				   
				   var clipid=Components.interfaces.nsIClipboard;
				   
				   if (!clip) return false;
				   
				   clip.setData(trans,null,clipid.kGlobalClipboard);	   
				}
			}

