//if (top.location != location) top.location.href = document.location.href;
//var mt__crtlang = 'en';

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function prog__rate(pid, rating)
{
	var ax = new Ajax("/dyn-prograte.php", { data: 'p='+pid+'&r='+rating, evalScripts: true, update: $("rater__fb"), method: 'post' });
	ax.request();
}

function news__rate(pid, rating)
{
	var ax = new Ajax("/dyn-newsrate.php", { data: 'n='+pid+'&r='+rating, evalScripts: true, update: $("rater__fb"), method: 'post' });
	ax.request();
}

function rss_lighten(obj){obj.src = '/base_img/rss_on.gif';}
function rss_darken(obj, icon){obj.src = '/base_img/rss_'+icon+'.gif';}

// NEWS SPOT SWITCHING
function news__spot_next(x)
{
	$("___spoth2_"+news__spot_crt).style.display = 'none';
	$("___spota_"+news__spot_crt).style.display = 'none';

	news__spot_crt++;
	if(news__spot_crt > x) news__spot_crt = 1;
	$("__spot_idx").setText(news__spot_crt);

	$("___spoth2_"+news__spot_crt).style.display = 'block';
	$("___spota_"+news__spot_crt).style.display = 'block';
}
function news__spot_prev(x)
{
	$("___spoth2_"+news__spot_crt).style.display = 'none';
	$("___spota_"+news__spot_crt).style.display = 'none';

	news__spot_crt--;
	if(news__spot_crt < 1) news__spot_crt = x;
	$("__spot_idx").setText(news__spot_crt);

	$("___spoth2_"+news__spot_crt).style.display = 'block';
	$("___spota_"+news__spot_crt).style.display = 'block';
}
function news__spot2_next(x)
{
	$("___spot2h2_"+news__spot2_crt).style.display = 'none';
	$("___spot2a_"+news__spot2_crt).style.display = 'none';

	news__spot2_crt++;
	if(news__spot2_crt > x) news__spot2_crt = 1;
	$("__spot2_idx").setText(news__spot2_crt);

	$("___spot2h2_"+news__spot2_crt).style.display = 'block';
	$("___spot2a_"+news__spot2_crt).style.display = 'block';
}
function news__spot2_prev(x)
{
	$("___spot2h2_"+news__spot2_crt).style.display = 'none';
	$("___spot2a_"+news__spot2_crt).style.display = 'none';

	news__spot2_crt--;
	if(news__spot2_crt < 1) news__spot2_crt = x;
	$("__spot2_idx").setText(news__spot2_crt);

	$("___spot2h2_"+news__spot2_crt).style.display = 'block';
	$("___spot2a_"+news__spot2_crt).style.display = 'block';
}

// BOOKMARKING 
function bookmark_msg(){
	var isie = 0;

	if(document.all) isie = 1;

	if(isie == 1)
	{
		window.external.AddFavorite(location.href, document.title); 
		return false;
	}
	else
	{
		alert("Your web-browser does not support automatic addition of favourites/bookmarks.\n\n"+
				"You will have to use a key-combination or menu option specific to your browser:\n"+
				"  - in Mozilla/Mozilla Firefox try: Ctrl-D\n"+
				"  - in Opera try Ctrl-T\n"+
				"  - for other browsers consult the program's help system/documentation\n\n\n"+
				"NOTE: The key combinations above will bookmark the page you were browsing at that moment.");

		return false;
	}
}

// QUICK SEARCH FORM VALIDATE
function qsearch_validate(src_field)
{
	if((src_field.value != undefined) && (src_field.value != "") && (src_field.value != "Keyword")) return true;
	else return false;
}

// COPY TO CLIPBOARD
function copy__clip(inElement)
{
	var flashcopier = 'flashcopier';
	if(!document.getElementById(flashcopier))
	{
		var divholder = document.createElement('div');
		divholder.id = flashcopier;
		document.body.appendChild(divholder);
	}
	
	document.getElementById(flashcopier).innerHTML = '';
	var divinfo = '<embed src="http://www.softpedia.com/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	document.getElementById(flashcopier).innerHTML = divinfo;
}

/* COOKIE WRAPPERS */
function createCookie(name,value,days)
{
        if (days)
        {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";

        document.cookie = name+"="+value+expires+"; 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 decode64(input)
{
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var output = chr1 = chr2 = chr3 = enc1 = enc2 = enc3 = enc4 = "";
	var i = 0;

	var base64test = /[^A-Za-z0-9\+\/\=]/g;
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do
	{
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));
		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;
		output = output + String.fromCharCode(chr1);
		if (enc3 != 64) output = output + String.fromCharCode(chr2);
		if (enc4 != 64) output = output + String.fromCharCode(chr3);
		chr1 = chr2 = chr3 = enc1 = enc2 = enc3 = enc4 = "";

	}
	while (i < input.length);
	return unescape(output);
}

function spi__jjmp(burl)
{
    document.location.href = decode64(burl);
}

