//alap beállitások
//var homepage='http://';
//alert(window.location.search);




/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Paul Tuckey | http://tuckey.org/
Modified by: EZboy yuriy.demchenko at gmail.com */

function countLines(strtocount, cols) {
  var hard_lines = 1;
  var last = 0;
  while ( true ) {
    last = strtocount.indexOf("\n", last+1);
    hard_lines ++;
    if ( last == -1 ) break;
  }
  var soft_lines = Math.round(strtocount.length / (cols-1));
  var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
  if ( hard ) soft_lines = hard_lines;
  return soft_lines;
}

function cleanForm() {
  for(var no=0;no<document.forms.length;no++){
    var the_form = document.forms[no];
    for( var x in the_form ) {
      if ( ! the_form[x] ) continue;
      if( typeof the_form[x].rows != "number" ) continue;

      if(!the_form[x].onkeyup) {the_form[x].onkeyup=function()
      {this.rows = countLines(this.value,this.cols)+1;};the_form[x].rows =
      countLines(the_form[x].value,the_form[x].cols) +1;}
    }
  }
}







/*
*Megosztás más oldalakon
*a saját oldalamat -fejlesztés alatt by abel
*/
function myShareinit(s){
	if(s=='on'){
	document.getElementById('shares').style.display = ""; 
	//document.getElementById('shareleft').style.display = ""; 
   }
if(s=='off'){
		document.getElementById('shares').style.display = "none"; 
	//document.getElementById('shareleft').style.display = "none";
	}
}

function myShare(){
var myURL = window.location.protocol + "//" + window.location.host + "" + window.location.pathname;
var myTITLE =document.title;
//alert(myURL+myTITLE);

  document.write('<div id="ko-share" >');
  document.write('<img src="http://www.eladotelkek.hu/images/plus.png" align=left  onmouseover="myShareinit(\'on\')" onmouseout="myShareinit(\'off\')"><span  onmouseover="myShareinit(\'on\')" onmouseout="myShareinit(\'off\')">MEGOSZTÁS</span>');
    //document.write('<img src="http://www.eladotelkek.hu/images/plus.png" align=left><span>NYOMTATÁS</span>');
    //document.write('<img src="http://www.eladotelkek.hu/images/plus.png" align=left><span>KÜLDÉS</span>');
  document.write('<br><div id="shares"  onmouseover="myShareinit(\'on\')" onmouseout="myShareinit(\'off\')"><div class="left" id="shareleft">');
	document.write('<a class="iwiw-share" target="_blank" title="iWiW" href="http://iwiw.hu/pages/share/share.jsp?u='+myURL+'" onclick="return iwiwshare_click()">Iwiw</a>');
	document.write('<a class="facebook-share" target="_blank" title="Facebook" href="http://www.facebook.com/share.php?u='+myURL+'">Facebook</a>');
	document.write('<a class="startlap-share" target="_blank" title="Startlap" href="http://www.startlap.hu/" onclick="window.open(\'http://www.startlap.hu/sajat_linkek/addlink.php?url=\'+encodeURIComponent(location.href)+\'&amp;title=\'+encodeURIComponent(document.title));return false;">Startlap</a>');
	document.write('<a class="tumblr-share" target="_blank" title="Tumblr" href="http://www.tumblr.com/share?v=3&amp;u='+myURL+'&amp;t='+myTITLE+'">Tumblr</a>');
	document.write('<a class="twitter-share" target="_blank" title="Twitter" href="http://twitter.com/home?status='+myURL+'">Twitter</a>');
	document.write('<a class="google-share" title="Google Reader" href="javascript:var%20b=document.body;var%20GR________bookmarklet_domain=\'http://www.google.com\';if(b&amp;&amp;!document.xmlVersion){void(z=document.createElement(\'script\'));void(z.src=\'http://www.google.com/reader/ui/link-bookmarklet.js\');void(b.appendChild(z));}else{}">Google</a>');
	document.write('<a class="myspace-share" target="_blank" title="Myspace" href="http://www.myspace.com/Modules/PostTo/Pages/?l=3&amp;u='+myURL+'">Myspace</a>');
  
  document.write(' </div><div class="right" id="shareright">');
 //document.write(' <div class="addthis_toolbox addthis_default_style">');


//document.write('<a class="addthis_button_email"></a>');
//document.write('<a class="addthis_button_print"></a>');
//document.write('<a class="addthis_button_facebook"></a>');
//document.write('<a class="addthis_button_myspace"></a>');
//document.write('<a class="addthis_button_google"></a>');
document.write('<a class="addthis_button_blogger">Blogger</a>');
//document.write('<a class="addthis_button_hotmail"></a>');
document.write('<a class="addthis_button_live">Windows live</a>');
document.write('<a class="addthis_button_wordpress">Wordpress</a>');
document.write('<a class="addthis_button_googlereader">Google reader</a>');
document.write('<a class="addthis_button_multiply">Multiply</a>');
document.write('<a class="addthis_button_gmail">Gmail</a>');
document.write('<a class="addthis_button_pdfonline">Pdfonline</a>');
//document.write('<a class="addthis_button_translate"></a>');
//document.write('<span class="addthis_separator">|</span>');
//document.write('<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4b5c625316cc69bc" class="addthis_button_expanded">More</a>');
//document.write('</div>');
document.write('<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b5c625316cc69bc"></script>');

document.write('</div></div></div>');

document.getElementById('shares').style.display = "none"; 
//document.getElementById('shareleft').style.display = "none"; 

}




/*
*grayscale azaz feketefehér képek ...
* saját oldalam -fejlesztés alatt by abel
*/
 /* <img id="myImage" src="images/volcano.jpg"   onload="javascript:prepareMouseOverImage(this, 'images/volcano.jpg');"></img> */
  
function prepareMouseOverImage(image, originalURL)
{
	image.mouseOverImage=originalURL;
	image.onload=function(){return true;};
	image.normalImage=grayscale(image, false);
	
	image.onmouseover=function()
	{
	//alert("a");
		this.src=this.mouseOverImage;
	}
	
	image.onmouseout=function()
	{
//	alert(this.normalImage.src);
		this.src=this.normalImage;
	}
	image.src=image.normalImage;	
}


function grayscale(image, bPlaceImage)
{
  var myCanvas=document.createElement("canvas");
  var myCanvasContext=myCanvas.getContext("2d");

  var imgWidth=image.width;
  var imgHeight=image.height;

  myCanvas.width= imgWidth;
  myCanvas.height=imgHeight;
//  alert(imgWidth);
  myCanvasContext.drawImage(image,0,0);
  // this function cannot be called if the image is not rom the same domain.  You'll get security error
  var imageData=myCanvasContext.getImageData(0,0, imgWidth, imgHeight);
 
  for (i=0; i<imageData.height; i++)
  {
    for (j=0; j<imageData.width; j++)
    {
	  var index=(i*4)*imageData.width+(j*4);
	  var red=imageData.data[index];	  
	  var green=imageData.data[index+1];
	  var blue=imageData.data[index+2];	  
	  var alpha=imageData.data[index+3];	 
	  var average=(red+green+blue)/3; 	  
   	  imageData.data[index]=average;	  
   	  imageData.data[index+1]=average;
   	  imageData.data[index+2]=average;
   	  imageData.data[index+3]=alpha;	  	  
	}
  }
  myCanvasContext.putImageData(imageData,0,0,0,0, imageData.width, imageData.height);
  //myCanvasContext.drawIMage(imageData,0,0);//,0,0, imageData.width, imageData.height);  
  
  if (bPlaceImage)
  {  
	  var myDiv=document.createElement("div");  
	  myDiv.appendChild(myCanvas);
	  image.parentNode.appendChild(myCanvas);//, image);
  }
  return myCanvas.toDataURL();
}

function imggray(s){
var alinks = document.getElementsByClassName(s);
for (var i=0; i<alinks.length; i++) {
prepareMouseOverImage(alinks[i], alinks[i].src);
}
}


////////////////////////////////////////////////////////permalinkekké alakitás a hrefeket
function perpermalink(){
var alinks = document.getElementsByTagName("a");
for (var i=0; i<alinks.length; i++) {
	if(alinks[i].href.match(/.*index\.php.*/gi)){
alinks[i].href  = alinks[i].href.replace("index.php", "");
		  //if(alinks[i].href.match(/.*page\=\.*/gi)){
		 // alinks[i].href  = alinks[i].href.replace("?page="+gi, "")+'.html';
		 //  alinks[i].href  = alinks[i].href.replace("?page="+gi, "")+'.html';
		  // &&  alinks[i].href.split("&").length > 0
		   if(alinks[i].href.match(/.*page\=\.*/gi) &&  alinks[i].href.split("&").length > 1){
		   	alinks[i].href  = alinks[i].href.replace("?", "");
		 // alinks[i].href  = alinks[i].href.replace(/\?\page=(\w+)&(\w+)/, "$1/$2"); //+'&i='+alinks[i].href.split("&").length
      }else{
				      	if(alinks[i].href=="index.php"){
				      		}else{
				      	alinks[i].href  = alinks[i].href.replace("?page=", "");
				           }
				      
      }
     alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/$6/$8/$10/$12"); 
     alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/$6/$8/$10"); 
     alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/$6/$8"); 
     alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/$6"); //+'&i='+alinks[i].href.split("&").length
     alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/");
}
}
}



function perpermalink2(){
	
var myURL = document.location.href;
var myTITLE =document.title;
var murl=location.href.substring(0,location.href.lastIndexOf("/"));
var myURL2 = location.href.match(/^.*\//);
var mydomain=window.location.hostname;
var mydomain1=window.location.href.match(/:\/\/(.[^/]+)/)[1];
var mydomain2=window.location.href.match(/:\/\/(.[^/]+)/)[1];
//location.hash = "#value";

var alinks = document.getElementsByTagName("a");






var anchors = document.getElementsByTagName("a");
var basehref = document.getElementsByTagName("base")[0].href;
var url = window.location.href;
//alert(basehref);
if(url.indexOf("#") > 0) url = url.substr(0, url.indexOf("#")); //strip hash
if(basehref) {
 for(var i = 0; i < anchors.length; i++) {
  var anchor = anchors[i];
  poundPos = anchor.href.indexOf("/#");
  if (poundPos > 0) {
   anchor.href = url + anchor.href.substr(poundPos + 1);
  }
 }
}



for (var i=0; i<alinks.length; i++) {
	if(alinks[i].href.match(/.*index\.php.*/gi) && alinks[i].href.match(mydomain1)){ //if(alinks[i].href.match(/.*index\.php.*/gi)){
alinks[i].href  = alinks[i].href.replace("index.php", "");
		  //if(alinks[i].href.match(/.*page\=\.*/gi)){
		 // alinks[i].href  = alinks[i].href.replace("?page="+gi, "")+'.html';
		 //  alinks[i].href  = alinks[i].href.replace("?page="+gi, "")+'.html';
		  // &&  alinks[i].href.split("&").length > 0
		 if(alinks[i].href.match(/.*page\=\.*/gi) &&  alinks[i].href.split("&").length > 1){
		   	alinks[i].href  = alinks[i].href.replace("?", "");
		 // alinks[i].href  = alinks[i].href.replace(/\?\page=(\w+)&(\w+)/, "$1/$2"); //+'&i='+alinks[i].href.split("&").length
      }else{
				      	if(alinks[i].href=="index.php"){
				      		}else{
				      	alinks[i].href  = alinks[i].href.replace("?page=", "");
				           }
				      
      }
     // alinks[i].href  = alinks[i].href.replace("&", "/");
       alinks[i].href  = alinks[i].href.replace("page=", "");
      // alinks[i].href  = alinks[i].href.replace("&", "/");
       //alinks[i].href  = alinks[i].href.replace("=", "/");
       
        alinks[i].href  = alinks[i].href.replace("&", "/"); 
       alinks[i].href  = alinks[i].href.replace("&", "/");
       alinks[i].href  = alinks[i].href.replace("&", "/"); 
       
       
       //alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+[-A-Z0-9])/, "$1/$2/");
   
       //alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)/, "$1/$2/");
      // alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)/, "$1/$2/");
       //alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)/, "$1/$2/");
       alinks[i].href  = alinks[i].href.replace("=", "/");
       alinks[i].href  = alinks[i].href.replace("=", "/");
      // alinks[i].href  = alinks[i].href.replace("/-", "-");
     
           
      // alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)/, "$1/$2/");
       // alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)/, "$1/$2/$3/$4");
        //  alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$1/$2/$3/$4/$5/$6"); //+'&i='+alinks[i].href.split("&").length
     //alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/$6/$8/$10/$12"); 
    // alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$2/$4/$6/$8/$10"); 
     //alinks[i].href  = alinks[i].href.replace(/(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)&(\w+)=(\w+)/, "$1/$2/$3/$4/$5/$6/$7/$8"); 
   
  
    
}
}











}



















/////////////////////////////////////loader kiirása
function inneredloader() {
var vmii='<DIV id="prepage" style="z-index:1001;position:absolute; font-family:arial; font-size:13; left:48%; top:0px; background-color:white; height:25px; width:100px;padding:6px 3px 2px 3px;text-align:center"><table align=center><tr><td><img src="js/preloader.gif" valign="absmiddle"> </td><td> <B>Betöltés...</B></td></tr></table></DIV>';
document.body.innerHTML = document.body.innerHTML + vmii;
}







//////////////////////////////////loading megjelenitése
function preloader() {
document.getElementById('prepage').style.visibility='block';
}

/////////////////////////////////////////////////oldalbetöltés utáni eltöntetés
function waitPreloadPage() { //DOM

if (document.getElementById){
document.getElementById('prepage').style.visibility='hidden';
}else{
if (document.layers){ //NS4
document.prepage.visibility = 'hidden';
}
else { //IE4
document.all.prepage.style.visibility = 'hidden';
}
}
}


////////////////////////////////////////////////////import js
function importjs(urlsc){
	
  document.write('<script type="text/javascript" src="'+urlsc+'"></script>');

}

//////////////////////////////////////////////////////import css
function importcss(urlsc){
if(document.createStyleSheet) {
  document.createStyleSheet(urlsc);
}
else {
  var styles = "@import url('"+urlsc+"');";
  var newSS=document.createElement('link');
  newSS.rel='stylesheet';
  newSS.href='data:text/css,'+escape(styles);
  document.getElementsByTagName("head")[0].appendChild(newSS);
}
//if (!document.getElementById) document.write("<link rel='stylesheet' type='text/css' href='"+urlsc+"'>");

}


////////////////////////////////////////////////////////////window onloads
function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func; 
	  } else { 
	    window.onload = function() { 
	      if (oldonload) { 
	        oldonload(); 
	      } 
	      func(); 
	    } 
	  } 
	} 
	

////////////////////////////////////////////////ajax
function createRequestObject(){
			var request_;
			var browser = navigator.appName;
			if(browser == "Microsoft Internet Explorer"){
			 request_ = new ActiveXObject("Microsoft.XMLHTTP");
			}else{
			 request_ = new XMLHttpRequest();
			}
			return request_;
			}









/////////////////////////////////////////////////max karakterlimit
function textCounter(field, countfield, maxlimit) {
	maxsz=100 / maxlimit;
	maxl=maxsz * field.value.length;
if (field.value.length > maxlimit){ // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
document.getElementById('tlimit').style.width='100%';
document.getElementById('tlimit').style.backgroundColor='#FF0404';
}else{ 
document.getElementById(countfield).innerHTML= maxlimit - field.value.length;
//countfield.value = maxlimit - field.value.length;
document.getElementById('tlimit').style.width=maxl+'%';

				if(maxl==100){
					document.getElementById('tlimit').style.backgroundColor='#FF0404';
				}else if(maxl >= 75 && maxl < 80){
					document.getElementById('tlimit').style.backgroundColor='#F8B121';	
				}else if(maxl >= 80 && maxl < 85){
					document.getElementById('tlimit').style.backgroundColor='#F97C20';	
				}else if(maxl >= 85 && maxl < 90){
					document.getElementById('tlimit').style.backgroundColor='#F96120';		
				}else if(maxl >= 90 && maxl < 95){
					document.getElementById('tlimit').style.backgroundColor='#FA561F';
				}else if(maxl >= 95 && maxl < 100){
					document.getElementById('tlimit').style.backgroundColor='#FD481C';
				}else{
					document.getElementById('tlimit').style.backgroundColor='#F7F122';
				}

}
}
//<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
//<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>












/////////////////////////////////////////auto start




//importjs('js/ajax_webpage/com.bydust.array.js'); //ajax beépülő
//importjs('js/ajax_webpage/com.bydust.ajax.js');//ajax beépülő
//importjs('js/ajax_webpage/main.js');//ajax beépülő
//importcss('js/ajax_webpage/default.css');//ajax beépülő css


//importjs('js/idezet.js'); //idezetek
//importjs('js/tooltip/boxover.js'); //Boxover


addLoadEvent(function() { 
	
	 //inneredloader(); //loading betoltese
	// waitPreloadPage(); //loading elrejtese
	// getaQuote(); //idezet inditasa
 //imggray('imgmenu'); //feketefehérré alakitás az imgmenü nevű classban
 //imggray('imgmenuo'); //feketefehérré alakitás az imgmenü nevű classban
 //perpermalink2(); //permalinké alakitás
//cleanForm();

}) 







