
function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}//end function var_dump


//																																//
function findChar(haystack, needle)	// return first character index, or false
{
	if( needle.length != 1)	
		return false;
	var i=0;
	for(i=0; i<haystack.length; i++)
	{
		if( haystack.charAt(i) == needle )
			return i;
	}
	return false;
}

//																																//
function strstr (haystack, needle, bool) {
    var pos = 0;
    haystack += '';
    pos = haystack.indexOf( needle );
	
    if (pos == -1) {
        return false;
    } else{
        if (bool){
            return haystack.substr( 0, pos );
        } else{
			amp = haystack.indexOf('&');
			if(amp>pos){
            	return haystack.slice( pos, amp );
			}else{
				return haystack.slice( pos );
			}//if(amp>1){
        }//if (bool){
    }//if (pos == -1) {
	
}//function strstr

//																																//
/* Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * written by Alen Grakalic (http://cssglobe.com)
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery	*/
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = -10;	// these 2 variable determine popup's distance from the cursor
		yOffset = -200;	// you might want to adjust to get the right result		
	/* END CONFIG */		
	$(".tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$(".tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
//																																//
function str_replace (search, replace, subject)
{
	var result = '';
	var  oldi = 0;
	for (i = subject.indexOf (search); i > -1; i = subject.indexOf (search, i))
	{
		result += subject.substring (oldi, i);
		result += replace;
		i += search.length;
		oldi = i;
	}
	return result + subject.substring (oldi, subject.length);
}
//																																//
function createCookie(name,value) {
	document.cookie = name+"="+value+"; 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 toggleDiv(divClass) {
	if(readCookie(divClass) == "false") {
		createCookie(divClass, "true");
		$("."+divClass).slideDown(1000);
	} else {
		createCookie(divClass, "false");
		$("."+divClass).slideUp(1000);
	}
}
//																																//
function removeBreaks(noBreaksText)
{
	var para = true; // csak sortorest	
	var nopara = false;	// paragrafot is	
//	var noBreaksText = document.getElementById("oldText").value;
	noBreaksText = noBreaksText.replace(/(\r\n|\n|\r)/gm,"<1br />");
	re1 = /<1br \/><1br \/>/gi;		
	re1a = /<1br \/><1br \/><1br \/>/gi;
	if(nopara == 1 || nopara ==  true){	
		noBreaksText = noBreaksText.replace(re1," "); }
	else{	
		noBreaksText = noBreaksText.replace(re1a,"<1br /><2br />");
		noBreaksText = noBreaksText.replace(re1,"<2br />");	}
	re2 = /\<1br \/>/gi;	
	noBreaksText = noBreaksText.replace(re2, " ");
	re3 = /\s+/g;			
	noBreaksText = noBreaksText.replace(re3," ");
	re4 = /<2br \/>/gi;		
	noBreaksText = noBreaksText.replace(re4,"\n\n");
	return noBreaksText;
}
//																																//
function utf8_decode ( str_data ) {
    // Converts a UTF-8 encoded string to ISO-8859-1  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/utf8_decode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Norman "zEh" Fuchs
    // +   bugfixed by: hitwork    // +   bugfixed by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0;
    
    str_data += '';
    
	var i = 0;    
    while ( i < str_data.length ) {        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if ((c1 > 191) && (c1 < 224)) {            c2 = str_data.charCodeAt(i+1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);            c3 = str_data.charCodeAt(i+2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    } 
    return tmp_arr.join('');
}
//																																//
function utf8_encode ( argString ) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/utf8_encode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
 	var string = argString; 
    var utftext = "";
    var start, end;
    var stringl = 0; 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);    }
 
    return utftext;
}
//																																//

function inarray (needle, haystack) 
{
    for(var i = 0; i < haystack.length; i++) {
		if(haystack[i] == needle) {
			return true;
		}
	}
	return false;
}
/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "preloadCssImages"
 * by Scott Jehl, scott@filamentgroup.com
 * http://www.filamentgroup.com
 * reference article: http://www.filamentgroup.com/lab/automated_image_preloading/
 * demo page: http://www.filamentgroup.com/examples/preloadImages/
 * 
 * Copyright (c) 2008 Filament Group, Inc
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 *
 * Version: 1.0, 31.05.2007
 * Changelog:
 * 	02.20.2008 initial Version 1.0
 * --------------------------------------------------------------------
 */
$.preloadCssImages = function(settings){
	//overrideable defaults
	settings = jQuery.extend({
		 imgDir: 'images'
	}, settings);

	//dump all the css rules into one string
	var sheets = document.styleSheets;
	var cssPile = '';
	for(var i = 0; i<sheets.length; i++){
		if(!$.browser.msie){
			var thisSheetRules = document.styleSheets[i].cssRules;
			for(var j = 0; j<thisSheetRules.length; j++){
				cssPile+= thisSheetRules[j].cssText;
			}
		}
		else {
			cssPile+= document.styleSheets[i].cssText;
		}
	}
	//parse string for image urls and load them into the DOM
	var allImgs = [];//new array for all the image urls  
	var imgUrls = cssPile.match(/[^\/]+\.(gif|jpg|jpeg|png)/g);//reg ex to get a string of between a "/" and a ".filename"
	if(imgUrls != null && imgUrls.length>0 && imgUrls != ''){//loop array
		var arr = jQuery.makeArray(imgUrls);//create array from regex obj	 
		$(arr).each(function(k){
			allImgs[k] = new Image(); //new img obj
			allImgs[k].src = settings.imgDir +'/'+ this;	
		});
	}
	return allImgs;
}
