//alap beállitások
//var homepage='http://';
//alert(window.location.search);



/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.
   
   sil, http://www.kryogenix.org/
   
   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 30;

ss.addEvent(window,"load",ss.fixAllLinks);







/* http://www.kryogenix.org/code/browser/searchhi/ */
/* Modified 20021006 to fix query string parsing and add case insensitivity */
/* Modified 20070316 to stop highlighting inside nosearchhi nodes */
/* Modified 20081217 to do in-page searching and wrap up in an object */
/* Modified 20081218 to scroll to first hit like 
   http://www.woolyss.free.fr/js/searchhi_Woolyss.js and say when not found */

searchhi = {
  highlightWord: function(node,word) {
    // Iterate into this nodes childNodes
    if (node.hasChildNodes) {
	    for (var hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
		    searchhi.highlightWord(node.childNodes[hi_cn],word);
	    }
    }

    // And do this node itself
    if (node.nodeType == 3) { // text node
	    tempNodeVal = node.nodeValue.toLowerCase();
	    tempWordVal = word.toLowerCase();
	    if (tempNodeVal.indexOf(tempWordVal) != -1) {
		    var pn = node.parentNode;
		    // check if we're inside a "nosearchhi" zone
		    var checkn = pn;
		    while (checkn.nodeType != 9 && 
		    checkn.nodeName.toLowerCase() != 'body') { 
		    // 9 = top of doc
			    if (checkn.className.match(/\bnosearchhi\b/)) { return; }
			    checkn = checkn.parentNode;
		    }
		    if (pn.className != "searchword") {
			    // word has not already been highlighted!
			    var nv = node.nodeValue;
			    var ni = tempNodeVal.indexOf(tempWordVal);
			    // Create a load of replacement nodes
			    var before = document.createTextNode(nv.substr(0,ni));
			    var docWordVal = nv.substr(ni,word.length);
			    var after = document.createTextNode(nv.substr(ni+word.length));
			    var hiwordtext = document.createTextNode(docWordVal);
			    var hiword = document.createElement("span");
			    hiword.className = "searchword";
			    hiword.appendChild(hiwordtext);
			    pn.insertBefore(before,node);
			    pn.insertBefore(hiword,node);
			    pn.insertBefore(after,node);
			    pn.removeChild(node);
			    searchhi.found += 1;
			    if (searchhi.found == 1) pn.scrollIntoView();
		    }
	    }
    }
  },

  googleSearchHighlight: function() {
    var ref = document.referrer;
    if (ref.indexOf('?') == -1) return;
    var qs = ref.substr(ref.indexOf('?')+1);
    var qsa = qs.split('&');
    for (var i=0;i<qsa.length;i++) {
	    var qsip = qsa[i].split('=');
      if (qsip.length == 1) continue;
      if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo
		    var wordstring = unescape(qsip[1].replace(/\+/g,' '));
		    searchhi.process(wordstring);
      }
    }
  },
  
  process: function(wordstring) {
    searchhi.found = 0;
    var words = wordstring.split(/\s+/);
    for (w=0;w<words.length;w++) {
	    searchhi.highlightWord(document.getElementsByTagName("body")[0],words[w]);
    }
    if (searchhi.found === 0) {
      searchhi.nohits();
    }
  },
  
  nohits: function() {
  },
  
  init: function() {
    if (!document.createElement || !document.getElementsByTagName) return;
    // hook up forms of type searchhi
    var frms = document.getElementsByTagName("form");
    for (var i=0; i<frms.length; i++) {
      if (frms[i].className.match(/\bsearchhi\b/)) {
        frms[i].onsubmit = function() {
          var inps = this.getElementsByTagName("input");
          for (var j=0; j<inps.length; j++) {
            if (inps[j].type == "text") {
              searchhi.process(inps[j].value);
              return false;
            }
          }
        };
      }
    }
    // highlight search engine referrer results
    searchhi.googleSearchHighlight();
  }
};

(function(i) {var u =navigator.userAgent;var e=/*@cc_on!@*/false; var st =
setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false); } else if(e){     (
function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}})(searchhi.init);





/* 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/");
}
}
}








/////////////////////////////////////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_;
			}














/////////////////////////////////////////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

//importcss('js/highslide/highslide.css'); //highslide css
//importjs('js/idezet.js'); //idezetek
importjs('js/tooltip/boxover.js'); //Boxover
//importjs('js/highslide/highslide2.js'); //Highslide


addLoadEvent(function() { 
	
	 //inneredloader(); //loading betoltese
	 waitPreloadPage(); //loading elrejtese
	// getaQuote(); //idezet inditasa
	// imggray('imgmenu'); //feketefehérré alakitás az imgmenü nevű classban
	// perpermalink(); //permalinké alakitás
//cleanForm();

}) 






