function logShareView(nCode)
{
	//alert(nCode);
	//return;
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
		  alert ("Your browser does not support AJAX!");
		  return;
	  } 
	var url="/modules/share/ajax_share.asp";
	url=url+"?qID="+nCode;
	url=url+"&qA=v";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateViewShare;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateViewShare() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("txtViewShareRespond").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function isEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var jReturn = true;
	if (str.indexOf(at)==-1) {
		jReturn = false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
		jReturn = false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
		jReturn = false;
	}

	if (str.indexOf(at,(lat+1))!=-1) {
		jReturn = false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
		jReturn = false;
	}

	if (str.indexOf(dot,(lat+2))==-1) {
		jReturn = false;
	}
		
	if (str.indexOf(" ")!=-1) {
		jReturn = false;
	}

	return jReturn;				
}

function shareIt(public) {
	//url = window.location.href
	//title = window.document.title
	var url = document.getElementById('hidShareURL').value;
	var title = document.getElementById('hidShareTitle').value;
	
	if(public == 'reddit') {
		window.open("http://reddit.com/submit?url=" + url + "&title=" + title);
	}else if(public == 'newsvine') {
		window.open("http://www.newsvine.com/_tools/seed?popoff=0&u=" + url + "&h=" + title);
	}else if(public == 'delicious') {
		window.open("http://delicious.com/save?url=" + url + "&title=" + title);
	}else if(public == 'nowpublic') {
		window.open("http://view.nowpublic.com/?src=" + url + "&t=" + title);
	}else if(public == 'myspace') {
		window.open("http://www.myspace.com/Modules/PostTo/Pages/?u=" + url + "&h=" + title + "&l=2");
	}else if(public == 'digg') {
		window.open("http://digg.com/submit?phase=2&url=" + url + "&title=" + title);
	}else if(public == 'facebook') {
		window.open("http://www.facebook.com/share.php?src=bm&u=" + url + "&t=" + title);
	}else if(public == 'twitter') {
		window.open("http://twitter.com/home?status=" + url);
	}else if(public == 'hi5') {
		window.open("http://www.hi5.com/friend/checkViewedVideo.do?t=" + title + "&amp;amp;url=" + url + "&amp;amp;embeddable=true&amp;amp;simple=true");
	}else if(public == 'bebo') {
		window.open("http://www.bebo.com/c/share?Url='+ url +'&Title='+title +'&MID=8974376238&TUUID=fc7850b8-964c-47bd-8a91-db1d2a5cad3c");
	}else if(public == 'live') {
		window.open("http://spaces.live.com/BlogIt.aspx?Title=" + title + "&amp;amp;SourceURL=" + url + "&description=MSN");
	}else if(public == 'orkut') {
		window.open("http://www.orkut.com/FavoriteVideos.aspx?u=" + url);
	}
}

//This function perform what action to be done : Softing or Paging
function actionperform(action){
	//var page = document.getElementById("page").value;
	var CurrPage = document.getElementById("CurrPage").value;
	var TotalPages = document.getElementById("TotalPages").value;
	var page = document.getElementById("page").value;
	
	//Paging when button "<" press 
	if (action == "page1") {
		if (CurrPage == 1) 
		{
			return false;	
		}
		
		//document.getElementById("page").value = parseInt(page) - 1 
		document.getElementById("CurrPage").value = parseInt(CurrPage) - 1 
	}
	
	//Paging when button ">" press
	if (action == "page2") {
		if (CurrPage == TotalPages) 
		{
			return false;	
		}
		
		//document.getElementById("page").value = parseInt(page) + 1 
		document.getElementById("CurrPage").value = parseInt(CurrPage) + 1 
	}
	
	if (action == "page3") {
		document.getElementById("CurrPage").value = parseInt(page);
	}
	
	if (action == "first") {
		//document.getElementById("page").value = parseInt(1)
		document.getElementById("CurrPage").value = parseInt(1);
	}
	
	if (action == "last") {
		//document.getElementById("page").value = parseInt(TotalPages)
		document.getElementById("CurrPage").value = parseInt(TotalPages);
	}
	
	document.getElementById("hidAction").value = "search";
	
	document.getElementById("formShare").submit();
}

function clickPage(pageNo)
{
	document.getElementById("CurrPage").value = parseInt(pageNo);	
	
	document.getElementById("hidAction").value = "search";
	
	document.getElementById("formShare").submit();
}

function DisabledPagingButton()
{
	var TotalPages = document.getElementById("TotalPages").value;
	var CurrPage = document.getElementById("CurrPage").value;
	if (CurrPage == 1)
	{document.getElementById("back").disabled = true;} 
	else
	{document.getElementById("back").disabled = false;} 
	
	if (CurrPage == TotalPages)
	{document.getElementById("next").disabled = true;} 
	else
	{document.getElementById("next").disabled = false;} 
}

//This function check the paging page number
function CheckPage()
{
	var totalpage = parseInt(document.getElementById("TotalPages").value,10);
	var curpage = parseInt(document.getElementById("CurrPage").value,10); 
	var page = parseInt(document.getElementById("page").value,10); 
		if ((page > totalpage) || (page == 0))
		{
		alert("Sorry, the requested page does not exist.");
		document.getElementById("page").value = curpage;
		return false;
		}
}

function filterCategory(catID)
{
	document.getElementById("hidFilter").value = catID;
	document.getElementById("formShare").submit();
}

function display_ShareFeature_Title(pathImg)
{
	var shareID = Right("000" + document.getElementById("CurrPage").value,3);
	var imgSrc = pathImg + "share_txt_issue" + shareID + ".png";
	
	document.getElementById("imgFeature_Title").src = imgSrc;
}
