//
//Copyright © 2007 ManipurPage.com All Rights Reserved
//

function PopMP3(theURL)
{ 
  window.open('redirectMp3.aspx?url='+ theURL, "MP3songs", "scrollbars=yes, width=429, height=820");
}

function PopTellaFrenWindow()
{
  var url;
  url = "TellaFren.aspx?link="+ URL_Encode(GetCurrentURL());
  window.open(url, "TellaFren", "scrollbars=yes,width=640,height=390");
}

function InvokePlayer(theURL)
{
  window.open(theURL,'ManipurPagePlayer', 'statusbar=yes,scrollbars=yes,width=320,height=196');
}

function PopPrinterFriendly(theURL)
{ 
  window.open(theURL, "PrinterFriendly", "toolbar=0,location=0,status=0,menubar=1,scrollbars=1,resizable=1,width=640,height=390");
}

function PopWindow(theURL,winName,features)
{ 
  window.open(theURL,winName,features);
}

function ManipurPageBookmark(title)
{
  var url;
  url = GetCurrentURL();
  if(document.all)
  window.external.AddFavorite(url,title)
}

function GetCurrentURL()
{
  return document.URL;
}

function URL_Encode(text)
{
  if(text==null)
     return "";
  if(typeof(text)!="string")
     text = text+"";
  text = text.replace(/&/g,"%26");
  return text;
}

function IsBrowser_ie()
{
	var ua = navigator.userAgent.toLowerCase(); 
	if ( ua.indexOf( "msie" ) != -1 ) 
	{
		return true;
	}
	else
	{
		return false;
	}
}

function GetURL()
{
    var str = window.location.protocol + '//' + window.location.hostname;
    return str;
}

function GetAjax()
{
	var oAjax;
	try
	{
		oAjax = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			oAjax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oe)
		{
			oAjax = null;
		}
	}
	
	if(! oAjax && typeof XMLHttpRequest != 'undefine')
	{
		oAjax = new XMLHttpRequest();
	}
	return oAjax;
}
function HideLoading(id, hide)
{
	if(hide == 'yes' || hide ==  1 )
	{
	  document.getElementById(id).style.display = "none";
	}
	else
	{
		document.getElementById(id).style.display = "block";
	}
}
function ShowLatestPost()
{
	var rdn = Math.random();
	rdn++;
	var req;
	var url = GetURL() +"/forum/LatestPost.asp?" + rdn;
	var divId = document.getElementById("LatestPost");
	req = GetAjax();
	req.onreadystatechange = function (){
		if(req.readyState == 4 || req.readyState == "complete")
		{
			if(req.status == 200)
			{
				HideLoading("LatestPostLoading", 1);
				divId.innerHTML = req.responseText;
				
			}
			else
			{
			 HideLoading("LatestPostLoading", 1);
			 divId.innerHTML = '<span class="text">Sorry, could not connect to ManipurPage Forum ...</span>';
			}
			
		}
		else
		{
			 HideLoading("LatestPostLoading", 0);
			 //divId.innerHTML = '<div style="text-align: center; padding-botom: 20px;"><img src="images/ajax-loader.gif" /><span class="text"> Loading ManipurPage Forum ...</span></div>';
		}
	}
	req.open("GET", url, true);
	req.send(null);
}