// JavaScript Document
//Main Function

window.onerror=function ()
{
	//return true;
}


function mybmk(para)
{
	loadrajax("../bmk/mybookmark.php","POST",para,"res");
}
function favorite_list()
{
	loadrajax("../bmk/myfavoritelist.php","POST","","res");
}
function change_favorder(orderpos,favid)
{
	var para="";
	para="orderpos="+orderpos+"&favid="+favid;
	//alert(para);
	loadrajax("../bmk/myfavoritelist.php","POST",para,"res");
}

function frndnetwork(id)
{
	//alert("frend network");
	var para="userid="+id;
	if(id!="")
	{
	  loadfajax("../home/friend_network.php","post",para,handle_frndnt,'');
	}
}
function handle_frndnt(res)
{
	//alert("handler");
	arr=res.split("<||>");
	document.getElementById("fof").innerHTML=arr[0];
	document.getElementById("mainsec").innerHTML=arr[1];
	
}
function frndofrnd(id)
{
	var para="userid="+id;
	//alert("frond of friend");
	if(id!="")
	{
	  loadrajax("../home/friend_friend.php","POST",para,"fof");
	  //loadrajax("../home/lib.ps_rightlogin.php","POST",para,"fof");
	}
}

function friendbmk(para)
{
	//alert(para);
	loadrajax("../bmk/friendbookmark.php","POST",para,"res");
}

function friend_listpage(id)
{
	var para,pg,list,bmtype,userid;
	userid=id;
	pg=1;
	list=document.mybmk_frm.list_page.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype+"&userid="+userid;
	friendbmk(para);
}


function mybmk_gotopage(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.mybmk_frm.pg.value;
	
	list=document.mybmk_frm.list_page.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	mybmk(para);
}
function mybmk_listpagebm()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.mybmk_frm.list_pagebm.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	mybmk(para);
}

function mybmk_gotopagebm(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.mybmk_frm.pgbm.value;
	
	list=document.mybmk_frm.list_pagebm.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	mybmk(para);
}

function mybmk_gotopagebot(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.mybmk_frm.pgbot.value;
	
	list=document.mybmk_frm.list_page.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	mybmk(para);
}
function mybmk_listpage()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.mybmk_frm.list_page.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	mybmk(para);
}
function mybmk_listpagebot()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.mybmk_frm.list_pagebot.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	mybmk(para);
}


function mybmk_type(type)
{
	var para,pg,list,bmtype;
	
	document.mybmk_frm.bmtype.value=type;
	pg=1;
	list=document.mybmk_frm.list_page.value;
	bmtype=document.mybmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	mybmk(para);
}
function allbmk(para)
{
	loadrajax("../bmk/allbookmark.php","POST",para,"res");
}
function allbmk_gotopage(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.allbmk_frm.pg.value;
	list=document.allbmk_frm.list_page.value;
	bmtype=document.allbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	allbmk(para);
}
function allbmk_gotopagebot(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.allbmk_frm.pgbot.value;
	list=document.allbmk_frm.list_page.value;
	bmtype=document.allbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	allbmk(para);
}

function allbmk_listpage()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.allbmk_frm.list_page.value;
	bmtype=document.allbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	allbmk(para);
}

function allbmk_listpagebot()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.allbmk_frm.list_pagebot.value;
	bmtype=document.allbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	allbmk(para);
}

// for recentreview

function recentreview(para)
{
	loadrajax("../bmk/recent_review.php","POST",para,"res");
}
function recentreview_gotopage(page)
{
	var para,pg,list,bmtype;
	
	
	if(page)
		pg=page;
	else
		pg=document.recentreview_frm.pg.value;
		list=document.recentreview_frm.list_page.value;
	
	
	para="pg="+pg+"&list_page="+list;
	
	//alert(para);
	
	recentreview(para);
}
function recentreview_listpage()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.recentreview_frm.list_page.value;
	para="pg="+pg+"&list_page="+list;
	recentreview(para);
}
function recentreview_gotopagebm(page)
{
	var para,pg,list,bmtype;
	
	
	if(page)
		pg=page;
	else
		pg=document.recentreview_frm.pgbm.value;
		list=document.recentreview_frm.list_pagebm.value;
	
	
	para="pg="+pg+"&list_page="+list;
	
	//alert(para);
	
	recentreview(para);
}
function recentreview_listpagebm()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.recentreview_frm.list_pagebm.value;
	para="pg="+pg+"&list_page="+list;
	recentreview(para);
}


//End for recentreview
function allbmk_type(type)
{
	var para,pg,list,bmtype;
	
	document.allbmk_frm.bmtype.value=type;
	pg=1;
	list=document.allbmk_frm.list_page.value;
	bmtype=document.allbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	allbmk(para);
}

function newbmk()
{
	loadrajax("../bmk/addbmk.php","POST","","res");
}

function savebookmark(bmkcnt)
{
	var key="";
	var bmarkname=document.getElementById("bkname").value;
	var url=document.getElementById("bkurl").value;
	var tag=document.getElementById("bktagname").value;
	var bktype;
	var RE;
	var favorite;
	favorite="N";
	bktype="";
	var err="";
	
	var bmkid="new";
	
	if(!validateNotEmpty(bmarkname))
	{
		key+="Title\n";
	}
	
	if(!validateNotEmpty(url))
	{
		key+="Website Link\n";
	}
	
	if(!validateNotEmpty(tag))
	{
		key+="Tags\n";
	}
	
	if(key)
	{
		alert("Please fill the required details\n\n"+key);
	}
	else
	{
		if(document.getElementById("bmtype_s").checked==true)
		{
			var newgrpname;
		
			newgrpname=document.getElementById("new_groupname_"+bmkid).value;
			if(bmkcnt==0 && newgrpname=="New Group")
			{
				err="Please enter the group name";
			}
			else if(bmkcnt>0 && newgrpname=="New Group")
			{
				var flag=false;
				for(i=0;i<bmkcnt;i++)
				{
					if(document.getElementById("group_"+bmkid+"_"+i).checked==true)
					{
						flag=true;
						break;
					}
				}
				if(flag==false)
					err="Please select the group name";
			}
			
			if(newgrpname!="New Group")
			{
				if(!validate_data(newgrpname,"Username"))
					err="Oops! Invalid group name. Special characters and spaces are not allowed.\n Only 5 to 30 characters are allowed";
			}
		}
		if(err)
		{
			alert(err);
		}
		else
		{
			var str=tag;
			if(str.indexOf("'")!=-1)
				alert("Oops! Invalid Tag name. Single Quotes are not allowed");
			else if(str.indexOf("/")!=-1)
				alert("Oops! Invalid Tag name. Forward Slash are not allowed");
			else
			{
				var para="";
				if(document.getElementById("bmtype_p").checked==true)
					bktype="P";
				else if(document.getElementById("bmtype_u").checked==true)
					bktype="U";
				else if(document.getElementById("bmtype_s").checked==true)
					bktype="S";
					
				if(document.getElementById("favorite_Y").checked==true)
					favorite="Y";
				
					
				url=escape(url);
				para="bkname="+bmarkname+"&bkurl="+url+"&bktagname="+tag+"&bktype="+bktype+"&favorite="+favorite;
				
				if(bktype=="S")
				{
					para+="&bmkid=new";
				
					if(newgrpname!="New Group")
						para+="&newgrpname="+newgrpname;
				
					for(i=0;i<bmkcnt;i++)
					{
						para+="&grpid[]="+document.getElementById("group_"+bmkid+"_"+i).value;
						para+="&grpstat[]="+document.getElementById("groupstat_"+bmkid+"_"+i).value;
					}
				}
				
				document.getElementById('savebutton').disabled=true;
				document.getElementById('savebutton').value='Processing...';
				loadfajax("ajx_addbmk.php","post",para,handle_saveresult,'');
			}
		}//if(err) close...
	}
}

function handle_saveresult(res)
{
	//alert(res);
	//document.getElementById('tst1').value=res;
	if(res==1)
	{
		alert("Bookmark Created Successfully");
		mybmk();
	}
	else if(res==2)
	{
		alert("Bookmark already added. Kindly Check!");
		newbmk();
	}
	else
	{	
		alert("Error: Kindly Check");
	}
}

/* ------Div bookmark search options------- */
function settab(id)
{
	//alert("tab check");
	document.getElementById(id).focus();
	return true;
}

function bmkser(para)
{
	loadrajax("../bmk/bmksearch.php","POST",para,"res");
}
function close_serch(id)
{
	document.getElementById(id).style.display="none";
}
function dispbmksearchbox(e, obj, offx, offy)
{
	//bmk search boxes
 	document.getElementById("mybmkscarch").style.display='none';
	document.getElementById("divbmktagsearch").style.display='none';
	document.getElementById("divbmksall").style.display='none';
    positionFor(e, obj, offx, offy);
}

function disptagsearchbox(e, obj, offx, offy)
{
	//tag search boxes
	document.getElementById("divtagserchall").style.display='none';
	document.getElementById("mytagscarch").style.display='none';
    positionFor(e, obj, offx, offy);
}
function dispsocietysearchbox(e, obj, offx, offy)
{
	//society search boxes
	document.getElementById("myfriendscarch").style.display='none';
	document.getElementById("allfriendscarch").style.display='none';
    positionFor(e, obj, offx, offy);
}

function bmksearchall(id)
{
	
	if(document.getElementById(id).value)
	{
		var para,searchbmkname,location;
	
		searchbmkname=document.getElementById(id).value;
		para="&searchbmkname="+searchbmkname;
		document.getElementById(id).value="";
		bmkser(para);
	 }
	 else
	 alert("Please enter a Bookmark name");
}
function chkbmkallenter(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		bmksearchall('bmksertxtall');
		
		document.getElementById('divbmksall').style.display="none";
		return false;
	}
	return true;
}
function mybmkser(para)
{
	loadrajax("../bmk/mybmksearch.php","POST",para,"res");
}

function checkEnterBmkMySer(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		mybmkser_text();
		return false;
	}
	return true;
}


function mybmkser_text()
{
	if(document.getElementById("bmkname").value)
	{
		var para,searchbmkname,pg,list,bmtype,location;
	
		searchbmkname=document.bmksearch.searchbmkname.value;
		pg=1;
		list=document.bmksearch.list_page.value;
		bmtype=document.bmksearch.bmtype.value;
		location=document.bmksearch.location.value;
	
		para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
		mybmkser(para);
	 }
	 else
	 alert("Please enter a Bookmark name");
}

function bmkmysearch(id)
{
	
	if(document.getElementById(id).value)
	{
		var para,searchbmkname,location;
	
		searchbmkname=document.getElementById(id).value;
		para="&searchbmkname="+searchbmkname;
		document.getElementById(id).value="";
		mybmkser(para);
	 }
	 else
	 alert("Please enter a Bookmark name");
}
function chkmybmkenter(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		bmkmysearch('mybmksertx');
		document.getElementById('mybmkscarch').style.display="none";
		return false;
	}
	return true;
}

function bmktagser(para)
{
	loadrajax("../bmk/mybmktagsearch.php","POST",para,"res");
	
}
function bmkmytagser(para)
{
	loadrajax("../bmk/mybmktagsearch.php","POST",para,"res");
	
}

function bmktagser_text()
{
	if(document.getElementById("bmkname").value)
	{
		var para,searchtagname,pg,list,bmtype;
		searchtagname=document.bmktagsearch.searchtagname.value;
		pg=1;
		list=document.bmktagsearch.list_page.value;
		bmtype=document.bmktagsearch.bmtype.value;
		
		para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
		bmktagser(para);
	}
	 else
	 alert("Please enter a Tag name");
}

function hmbmktagser(para)
{
	loadrajax("../bmk/bmktagsearch.php","POST",para,"res");
}
function hmbmktagser_text()
{
	if(document.getElementById("bmkname").value)
	{
		var para,searchtagname,pg,list,bmtype;
		searchtagname=document.bmktagsearch.searchtagname.value;
		pg=1;
		list=document.bmktagsearch.list_page.value;
		bmtype=document.bmktagsearch.bmtype.value;
		
		para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
		hmbmktagser(para);
	}
	 else
	 alert("Please enter a Tag name");
}
function checkEnterhmBmkTagSer(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		hmbmktagser_text();
		return false;
	}
	return true;
}
function hmbmktagser_listpage()
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	pg=1;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	hmbmktagser(para);
}
function hmbmktagser_listpagebot()
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	pg=1;
	list=document.bmktagsearch.list_pagebot.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	hmbmktagser(para);
}
function hmbmktagser_gotopage(page)
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	if(page)
		pg=page;
	else
		pg=document.bmktagsearch.pg.value;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	hmbmktagser(para);
}
function hmbmktagser_gotopagebot(page)
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	if(page)
		pg=page;
	else
		pg=document.bmktagsearch.pgbot.value;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	hmbmktagser(para);
}


function bmktagsearchall(id)
{
	
	if(document.getElementById(id).value)
	{
		var para,searchtagname,location;
	
		searchtagname=document.getElementById(id).value;
		para="&searchtagname="+searchtagname;
		document.getElementById(id).value="";
		bmkmytagser(para);
	 }
	 else
	 alert("Please enter a Bookmark name");
}
function chkbmktagenter(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		bmktagsearchall('bmktagsertxt');
		document.getElementById('divbmktagsearch').style.display="none";
		return false;
	}
	return true;
}






function bmk_morelinks(para,pg)
{
	var pdata="";
	
	if(document.bmk)
		pdata=get_page_data(pg);
	
	if(pdata)
	{
		pdata+="&"+para;
	}
	else
	{
		pdata=para;
	}
	
	loadrajax("../bmk/bmkmorelinks.php","POST",pdata,"res");
}
function get_page_data(page)
{
	var para,pg,list;
	
	if(page)
		pg=page;
	else
		pg=document.bmk.pg.value;
		
	list=document.bmk.list_page.value;
	
	para="pg="+pg+"&list_page="+list;
	return para;
	
}


function bmkser_text()
{
	if(document.getElementById("bmkname").value)
	{
		var para,searchbmkname,pg,list,bmtype,location;
	
		searchbmkname=document.bmksearch.searchbmkname.value;
		pg=1;
		list=document.bmksearch.list_page.value;
		bmtype=document.bmksearch.bmtype.value;
		location=document.bmksearch.location.value;
	
		para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
		bmkser(para);
	 }
	 else
	 alert("Please enter a Bookmark name");
}



function bmkser_gotopage(page)
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	if(page)
		pg=page;
	else
		pg=document.bmksearch.pg.value;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmkser(para);
}
function bmkser_gotopagebot(page)
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	if(page)
		pg=page;
	else
		pg=document.bmksearch.pgbot.value;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmkser(para);
}

function mybmkser_gotopage(page)
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	if(page)
		pg=page;
	else
		pg=document.bmksearch.pg.value;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	mybmkser(para);
}
function mybmkser_gotopagebot(page)
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	if(page)
		pg=page;
	else
		pg=document.bmksearch.pgbot.value;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	mybmkser(para);
}

function bmkser_listpage()
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	pg=1;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmkser(para);
}
function bmkser_listpagebot()
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	pg=1;
	list=document.bmksearch.list_pagebot.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmkser(para);
}

function mybmkser_listpage()
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	pg=1;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	mybmkser(para);
}
function mybmkser_listpagebot()
{
	var para,searchbmkname,pg,list,bmtype,location;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	pg=1;
	list=document.bmksearch.list_pagebot.value;
	bmtype=document.bmksearch.bmtype.value;
	location=document.bmksearch.location.value;
	
	para="location="+location+"&searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	mybmkser(para);
}


function bmkser_typesearch(type)
{
	var para,searchbmkname,pg,list,bmtype;
	
	document.bmksearch.bmtype.value=type;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	pg=document.bmksearch.pg.value;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	
	para="searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	//alert(para);
	bmkser(para);
}
function mybmkser_typesearch(type)
{
	var para,searchbmkname,pg,list,bmtype;
	
	document.bmksearch.bmtype.value=type;
	
	searchbmkname=document.bmksearch.searchbmkname.value;
	pg=document.bmksearch.pg.value;
	list=document.bmksearch.list_page.value;
	bmtype=document.bmksearch.bmtype.value;
	
	para="searchbmkname="+searchbmkname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	//alert(para);
	mybmkser(para);
}

function bmktagser_gotopage(page)
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	if(page)
		pg=page;
	else
		pg=document.bmktagsearch.pg.value;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmktagser(para);
}
function bmktagser_gotopagebot(page)
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	if(page)
		pg=page;
	else
		pg=document.bmktagsearch.pgbot.value;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmktagser(para);
}

function bmktagser_listpage()
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	pg=1;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmktagser(para);
}
function bmktagser_listpagebot()
{
	var para,searchtagname,pg,list,bmtype;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	pg=1;
	list=document.bmktagsearch.list_pagebot.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmktagser(para);
}

function bmktagser_typesearch(type)
{
	var para,searchtagname,pg,list,bmtype;
	
	document.bmktagsearch.bmtype.value=type;
	
	searchtagname=document.bmktagsearch.searchtagname.value;
	pg=document.bmktagsearch.pg.value;
	list=document.bmktagsearch.list_page.value;
	bmtype=document.bmktagsearch.bmtype.value;
	
	para="searchtagname="+searchtagname+"&pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	bmktagser(para);
}

function viewbmklink(bmk)
{
	para="bmkid="+bmk;
	loadrajax("../bmk/bmkdetailview.php","POST",para,"res");
}
function viewbmklinkcnt(id,url,type)
{
	
 var para;
 para="bmkid="+id+"&url="+url+"&type="+type;
 
 loadfajax("../bmk/viewcount.php","post",para,'','');
 window.open(url);
}


function bmkrep()
{
	alert('Coming Soon');
}
//second level links
	
function myprivatebmk()
{
	
}
function mysharedbmk()
{
	
}
function mygroupbmk()
{
	
}
function bmksave(bmkid)
{
	var para;
	
	para="bmkid="+bmkid;
	//loadrajax("../bmk/addbmk.php","POST",para,"res");
	loadfajax("../bmk/ajx_bmksave.php","post",para,stat_bmksave,'');
	
}
function stat_bmksave(res)
{
	arr=res.split("^^");
	if(arr[1] == 1)
	{
	  alert("Bookmark successfully saved!");
	  allbmk(); 
	}
	else 
	  alert("Error: Kindly Check");
    
}

function getUrlTagList(url)
{
	var para;
	if(url)
	{
		para="url="+url;
	
		loadfajax("../bmk/ajx_urltaglist.php","post",para,handle_urltag,'');
	}
}

function handle_urltag(res)
{
	document.addbk_frm.bktagname.value=res;
}

function share_unshare(flag,bmkid,divname)
{
	document.getElementById("groupbmkid_"+bmkid).value=bmkid;
}

function openreview(bmkid)
{
	para="bmkid="+bmkid;
	loadrajax("../community/community.php","GET",para,"mainsec");
}
function postreview(bmkid)
{
	para="bmkid="+bmkid;
	
	loadrajax("../community/postreview.php","POST",para,"res");
}
function chkloginuser(id)
{
	//alert(id);
	if(!id)
	 return false;
	else
	  return true;
}

function addreview()
{
	var para;
	
	if(!validateNotEmpty(document.review.review_comment.value))
		alert("Please post your review");
	else
	{
		var bmkid=document.review.bmkid.value;
		para="review_comment="+document.review.review_comment.value+"&bmkid="+bmkid;
		loadfajax("../community/ajx_addreview.php","post",para,handle_addreview,'');
	}
}
function handle_addreview(res)
{	
	document.review.review_comment.value="";
	//alert("Your review has been posted");
	document.getElementById('rev_list').innerHTML=res;
	document.getElementById('recoment').innerHTML="Reviews:";
}

function myreview_gotopage(page)
{
	var para,pg,list,bmtype;
	
	
	if(page)
		pg=page;
	else
		pg=document.myreview_frm.pg.value;
		list=document.myreview_frm.list_page.value;
	
	
	para="pg="+pg+"&list_page="+list;
	myreview(para);
}
function myreview_listpage()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.myreview_frm.list_page.value;
	
	
	para="pg="+pg+"&list_page="+list;
	myreview(para);
}
function myreview_gotopagebm(page)
{
	var para,pg,list,bmtype;
	
	
	if(page)
		pg=page;
	else
		pg=document.myreview_frm.pgbm.value;
		list=document.myreview_frm.list_pagebm.value;
	
	
	para="pg="+pg+"&list_page="+list;
	myreview(para);
}

function myreview_listpagebm()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.myreview_frm.list_pagebm.value;
	
	
	para="pg="+pg+"&list_page="+list;
	myreview(para);
}

function myreview(para)
{
	loadrajax("../community/myreview.php","POST",para,"res");
}
function recentreview(para)
{
	loadrajax("../community/recent_review.php","POST",para,"res");
}
function viewrating(divid,bmkid)
{
	if(document.getElementById(divid).style.display=="none")
	{
		para="mode=V&bmkid="+bmkid; //View mode...
 		loadfajax("../rating/rating.php","post",para,handle_rating,'');		
	}
	else
		document.getElementById(divid).style.display="none";
}
var prev_id="";
function handle_rating(res)
{
	arr=res.split("^^");

	if(prev_id)		
	   document.getElementById("thanks_"+prev_id).style.display="none";

	if(arr[1]=="A")
	{
		bmkid=arr[2];
		data=arr[0];
		
		document.getElementById("thanks_"+bmkid).style.display="block";
		document.getElementById("thanks_"+bmkid).innerHTML="Oops! Already rated.";
	}
	else
	{
		bmkid=arr[1];
		rvalue=arr[2];
		document.getElementById("thanks_"+bmkid).style.display="block";
		document.getElementById("thanks_"+bmkid).innerHTML="Thanks for rating!";
		
		//document.getElementById("rateval_"+bmkid).innerHTML=rvalue;
	}
	
	document.getElementById("rating_"+bmkid).innerHTML=arr[0];
	document.getElementById("rating_"+bmkid).style.display="block";
	
	setTimeout("hide_rating();",5000);
	if(prev_id!=bmkid)
	{
		prev_id=bmkid;
	}
}
function hide_rating()
{
	if(document.getElementById("thanks_"+prev_id))
		document.getElementById("thanks_"+prev_id).style.display="none";
}
function store_rating(bmkid,rateval,loc)
{
	if(loc=="H")
		alert("Please login to rate bookmarks");
	else
	{
		para="mode=A&bmkid="+bmkid+"&ratevalue="+rateval; //Add mode...
		loadfajax("../rating/rating.php","post",para,handle_rating,'');	
	}
}
function checkEnterBmkSer(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		bmkser_text();
		return false;
	}
	return true;
}
function checkEnterBmkTagSer(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
	}

	characterCode=e.keyCode;
	
	if(characterCode==13)
	{
		bmktagser_text();
		return false;
	}
	return true;
}



var reloadpag;
var reloadpagmy;
function deletbmk(bmkid,reload_fun)
{
	reloadpagmy=reload_fun;
	if(confirm(" Do you want to remove this bookmark?"))
	{
		para="bmkid="+bmkid; //Add mode...
		loadfajax("../bmk/stat_delet.php","post",para,stat_delet,'');
	}
	
}
 
function stat_delet(res)
{
	arr=res.split("^^");
	if(arr[1] == 1)
	  alert("Bookmark has been deleted.");
	else 
	  alert("Error: Kindly Check");
    eval(reloadpagmy);
}
function modifypage(bmkid,fun)
{
	  var para;
	 
	  para="bmkid="+bmkid+"&fun="+fun;
	  loadrajax("../bmk/bmk_modify.php","POST",para,"res");
	//window.location.href="../bmk/bmk_modify.php?bmkid="+bmkid;
	 window.scrollTo(10,10);
}

function modifybookmark(bmkid,fun)
{
	
	reloadpag=fun;
	//alert(bmkid);
	var key="";
	var bmarkname=document.getElementById("bkname").value;
	var url=document.getElementById("bkurl").value;
	var tag=document.getElementById("bktagname").value;
	var bktype;
	var RE;
	var favorite;
	bktype="";
	favorite="N";	
	if(!validateNotEmpty(bmarkname))
	{
		key+="Title\n";
	}
	
	if(!validateNotEmpty(url))
	{
		key+="Website Link\n";
	}
	
	if(!validateNotEmpty(tag))
	{
		key+="Tags\n";
	}
	
	if(key)
	{
		alert("Please fill in the required details\n\n"+key);
	}
	else
	{
		
		var str=tag;
		if(str.indexOf("'")!=-1)
			alert("Oops! Invalid Tag name. Single Quotes are not allowed");
		else if(str.indexOf("/")!=-1)
			alert("Oops! Invalid Tag name. Forward Slash are not allowed");
		else
		{
			var para="";
			if(document.getElementById("bmtype_p").checked==true)
				bktype="P";
			else if(document.getElementById("bmtype_u").checked==true)
				bktype="U";
			else if(document.getElementById("bmtype_s").checked==true)
				bktype="S";
				
			if(document.getElementById("favorite_Y").checked==true)
				favorite="Y";
			
		    url=escape(url);
			para="bkname="+bmarkname+"&bkurl="+url+"&bktagname="+tag+"&bktype="+bktype+"&bmkid="+bmkid+"&favorite="+favorite;
			
			document.getElementById('savebutton').disabled=true;
			document.getElementById('savebutton').value='Processing...';
			loadfajax("ajx_modifybmk.php","post",para,modify_result,'');
		}
	}
}
function modify_result(res)
{ 
    
    arr=res.split("^^");
	if(arr[1] == 1)
	{
		
		document.getElementById('savebutton').disabled=false;
		document.getElementById('savebutton').value='Modify';
	    alert("Bookmark modified");
		//eval(reloadpag);
	}
	else
	{	
	
		alert("Error: Kindly Check");
	}
}

function modify_cancle(fun)
{
	 reloadpag=fun;
	 eval(reloadpag);
}
function load_list()
{
	
}

//---------------------------------- Position the layer Starts -----------------------
var prevobj;
var curobj;

function getWinHeight() {
	height = 0;
	if (window.innerHeight) height = window.innerHeight - 18;
	else if (document.documentElement && document.documentElement.clientHeight) 
		height = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight) 
		height = document.body.clientHeight;
	return height;
}
  
function getWinWidth() {
    width = 0;
    if (window.innerWidth) width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		width = document.body.clientWidth;
	return width;
}
  
function getScrollX() {

   scrollX = 0;
  	if (typeof window.pageXOffset == "number") scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) scrollX = window.scrollX;

	return scrollX;
}

 function getScrollY() {
    scrollY = 0;    
    if (typeof window.pageYOffset == "number") scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
		scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		scrollY = document.body.scrollTop; 
  	else if (window.scrollY) scrollY = window.scrollY;
	return scrollY;
}  
function positionIt(e, obj, offx, offy) 
{
    var x=0, y=0;
    
	var objstr="document.getElementById('"+obj+"')";
	var o=eval(objstr);
	//var e = window.event;window.event
	o.style.display="block";
	
	scrollX=getScrollX();
	width=getWinWidth();
	
	scrollY=getScrollY();
	height=getWinHeight();
	
	x = e.pageX? e.pageX: e.clientX + scrollX;
	 
    if ( x + o.offsetWidth + offx > width + scrollX) 
        x = width + scrollX - o.offsetWidth;
    else x = x + offx;


    y = e.pageY? e.pageY: e.clientY + scrollY; 
   
    if ( y + o.offsetHeight + offy > height + scrollY )
        y = height + scrollY - o.offsetHeight-20;
		
    else y = y + offy;
    o.style.left = x + "px"; o.style.top = y + "px";
	o.style.display="block";
	
}
function positionFor(e, obj, offx, offy) 
{
    var x=0, y=0;

	var objstr="document.getElementById('"+obj+"')";
	var o=eval(objstr);
	o.style.display="block";
	
	scrollX=getScrollX();
	width=getWinWidth();
	
	scrollY=getScrollY();
	height=getWinHeight();
	
	x = e.pageX? e.pageX: e.clientX + scrollX;
	 
    if ( x + o.offsetWidth + offx > width + scrollX) 
        x = width + scrollX - o.offsetWidth;
    else x = x + offx;


    y = e.pageY? e.pageY: e.clientY + scrollY; 
   
    if ( y + o.offsetHeight + offy > height + scrollY )
        y = height + scrollY - o.offsetHeight-20;
		
    else y = y + offy;
    o.style.left = x + "px"; o.style.top = y + "px";
	o.style.display="block";
	
}

function serchdivpositionIt(e, obj, offx, offy) 
{
	
    var x=0, y=0;
     offx=Number(offx);
	 offy=Number(offy);
	//var o="document.getElementById("+obj+")";
	//alert(objstr);
	//var o=eval(objstr);
	
	document.getElementById(obj).style.display="block";
	//document.getElementById(obj).style.display="block";
	
	scrollX=getScrollX();
	width=getWinWidth();
	
	scrollY=getScrollY();
	height=getWinHeight();
	
	x = e.pageX? e.pageX: e.clientX + scrollX;
	 
    if ( x + document.getElementById(obj).offsetWidth + offx > width + scrollX) 
        x = width + scrollX - document.getElementById(obj).offsetWidth;
    else x = x + offx;


    y = e.pageY? e.pageY: e.clientY + scrollY; 
   
    if ( y + document.getElementById(obj).offsetHeight + offy > height + scrollY )
        y = height + scrollY - document.getElementById(obj).offsetHeight;
		
    else y = y + offy;

    document.getElementById(obj).style.left = x + "px"; document.getElementById(obj).style.top = y + "px";
	document.getElementById(obj).style.display="block";
	//alert(height);
	//alert("X="+x+"y="+y);
}

function mailposition(e, obj, offx, offy) 
{
    var x=0, y=0;

	var objstr="document.getElementById('"+obj+"')";
	var o=eval(objstr);
	o.style.display="block";
	
	scrollX=getScrollX();
	width=getWinWidth();
	
	scrollY=getScrollY();
	height=getWinHeight();
	
	/* x = e.pageX? e.pageX: e.clientX + scrollX;
	 
    if ( x + o.offsetWidth + offx > width + scrollX) 
        x = width + scrollX - o.offsetWidth;
    else x = x + offx; */

    x=538;
    y = e.pageY? e.pageY: e.clientY + scrollY; 
   
    if ( y + o.offsetHeight + offy > height + scrollY )
        y = height + scrollY - o.offsetHeight;
		
    else y = y + offy;
    o.style.left = x + "px"; o.style.top = y + "px";
	o.style.display="block";
}

//---------------------------------- Position the layer ends -----------------------
/* Friends group linking starts */
function update_friends_groupid(userid,usergroup)
{
	var newgrpname;
	var err="";

	newgrpname=document.getElementById("new_groupname_"+userid).value;
	if(usergroup==0 && newgrpname=="New Group")
	{
		err="Please enter the group name";
	}
	else if(usergroup>0 && newgrpname=="New Group")
	{
		var flag=false;
		for(i=0;i<usergroup;i++)
		{
			if(document.getElementById("group_"+userid+"_"+i).checked==true)
			{
				flag=true;
				break;
			}
		}
		if(flag==false)
			err="Please select the group name";
	}
	
	if(newgrpname!="New Group")
	{
		if(!validate_data(newgrpname,"Groupname"))
			err="Oops! Invalid group name. Special characters and spaces are not allowed. Only 5 to 30 characters are allowed";
	}
	
	if(err)
	{
		alert(err);
	}
	else
	{
		var para="";
		
		para="uid="+userid;
		
		if(newgrpname!="New Group")
			para+="&newgrpname="+newgrpname;
		
		for(i=0;i<usergroup;i++)
		{
			para+="&grpid[]="+document.getElementById("group_"+userid+"_"+i).value;
			para+="&grpstat[]="+document.getElementById("groupstat_"+userid+"_"+i).value;
		}
		
		document.getElementById("grouplink_btn_"+userid).value="Please wait..";
		document.getElementById("grouplink_btn_"+userid).disabled=true;

		loadfajax("../groups/ajx_friends_updategrp.php","post",para,update_friends_groupid_result,'');
	}
	
}

function update_friends_groupid_result(res)
{
	
	var arr=res.split("^^");
	
	bmkid=arr[2];
	document.getElementById("grouplink_btn_"+bmkid).value="Save";
	document.getElementById("grouplink_btn_"+bmkid).disabled=false;
	
	if(arr[1]==1)
		alert("Group name already exists. There are plenty of other names!");
	else if(arr[1]==2)
	{
		var resdivcont=arr[3];
		document.getElementById("group_list_"+bmkid).innerHTML=resdivcont;
		alert("Successfully updated");
	}
	else
		alert("Problem in updation");
}

/* checksend bmk mail form */
function Trim(str)
{ 
	while(str.charAt(0) == (" ") )
	{ 
		 str = str.substring(1);
	}
	while(str.charAt(str.length-1) == " " )
	{ 
		 str = str.substring(0,str.length-1);
	}
	  return str;
}

function validationbmkmail(bmkid)
{
	
    var errMsg='';
	var para,mailids,i,mail;
	var mailid = document.getElementById("emailid_"+bmkid).value;
	var cmnt = document.getElementById("comment_"+bmkid).value;
	//var name=document.getElementById("name_"+bmkid).value;
	document.getElementById("emer"+bmkid).style.display='none';
	document.getElementById("cmnter_"+bmkid).style.display='none';
	//document.getElementById("nmer"+bmkid).style.display='none';
	
	mailids=mailid.split(",");
	if(!validateNotEmpty(mailid))
	{
    	 errMsg="yes";
		 document.getElementById("emer"+bmkid).innerHTML="Oops! Fill me" ;
		 document.getElementById("emer"+bmkid).style.display='block';
	}
	else
	{	
	   for(i=0; i < mailids.length; i++)
	   {
	 		mailids[i]=Trim(mailids[i]);
			if(!validateEmail(mailids[i]))
			{
				 errMsg="yes";
				 document.getElementById("emer"+bmkid).innerHTML="Enter valid Email ID";
				 document.getElementById("emer"+bmkid).style.display='block';
				 //break();
			}
	   }
	} 
	
	/*if(!validateNotEmpty(cmnt))
	{
		errMsg="yes";
		document.getElementById("cmnter_"+bmkid).innerHTML="Oops! Fill me";
		document.getElementById("cmnter_"+bmkid).style.display='block';
	}
	if(!validateNotEmpty(name))
	{
		errMsg="yes";
		document.getElementById("nmer"+bmkid).innerHTML="Oops! Fill me";
		document.getElementById("nmer"+bmkid).style.display='block';
	}*/
	if(errMsg != '')
	{
		alert("Sorry! Unable to Submit");
		
	}
	 else
	 {
		 document.getElementById("emailid_"+bmkid).value="";
	     document.getElementById("comment_"+bmkid).value="";
	     //document.getElementById("name_"+bmkid).value="";
		 
		 para="mailid="+mailid+"&comments="+cmnt+"&bmkid="+bmkid;//+"&name="+name;
		 loadfajax("../bmk/ajx_bmksendmail.php","post",para,bmkmail_result,'');
		 document.getElementById("sentmail_"+bmkid).style.display='none';
		 
	 }
  }

function bmkmail_result(res)
{
	//alert(res);
   	arr=res.split("^^");
	if(arr[1] == 1)
		alert("Mail successfully sent!");
	else
	    alert("Error: Kindly Check");
}
function close_sentmail(bmkid)
{
	document.getElementById("sentmail_"+bmkid).style.display="none";
}




/* Friends group linking ends */
var reloalfunval;
function load_sharegroup(e,bmkid,reloalfun)
{
	var para="";
	document.getElementById("glist").style.display="none";
	document.getElementById("sharebmk_loadmsg").style.display="block";
	document.getElementById("groupbmkid").value=bmkid;
	positionIt(e, 'group_list',10,-35);
	
    if( typeof reloalfun == 'undefined')
	{
		reloalfunval=0;
	}
    else
	 reloalfunval=reloalfun;
	
	para="bmkid="+bmkid+"&mode=L"; //mode-L (Load group list
	
	loadfajax("../groups/ajx_updategrp.php","post",para,update_groupid_result,'');
}

function update_groupid(bmkid,bmkcnt,reloalfun)
{
	var newgrpname;
	var err="";
	newgrpname=document.getElementById("new_groupname_"+bmkid).value;
	if(bmkcnt==0 && newgrpname=="New Group")
	{
		err="Please enter the group name";
	}
	/* else if(bmkcnt>0 && newgrpname=="New Group")
	{
	 	var flag=false;
		for(i=0;i<bmkcnt;i++)
		{
			if(document.getElementById("group_"+bmkid+"_"+i).checked==true)
			{
				flag=true;
				break;
			}
		}
		if(flag==false)
			err="Please select the group name";
	}*/
	
	if(newgrpname!="New Group")
	{
		if(!validate_data(newgrpname,"Groupname"))
			err="Oops! Invalid group name. Special characters and spaces are not allowed.\n Only 3 to 30 characters are allowed";
	}
	
	if(err)
	{
		alert(err);
	}
	else
	{
		var para="";
		
		para="bmkid="+bmkid;
		
		if(newgrpname!="New Group")
			para+="&newgrpname="+newgrpname;
		
		for(i=0;i<bmkcnt;i++)
		{
			para+="&grpid[]="+document.getElementById("group_"+bmkid+"_"+i).value;
			para+="&grpstat[]="+document.getElementById("groupstat_"+bmkid+"_"+i).value;
		}
		
		document.getElementById("grouplink_btn_"+bmkid).value="Please wait..";
		document.getElementById("grouplink_btn_"+bmkid).disabled=true;
		
		loadfajax("../groups/ajx_updategrp.php","post",para,update_groupid_stat,'');
	}
	
}

function update_groupid_stat(res)
{
	var arr=res.split("^^");
	
	bmkid=arr[2];
	//document.getElementById("grouplink_btn_"+bmkid).value="Save";
	//document.getElementById("grouplink_btn_"+bmkid).disabled=false;
	
	if(arr[1]==1)
		alert("Group name already exists. There are plenty of other names!");
	else if(arr[1]==2)
	{
		var resdivcont=arr[3];
		document.getElementById("group_list").innerHTML=resdivcont;
		//document.getElementById("bmktypename_"+bmkid).innerHTML="Share";
		alert("Successfully updated");
		if(reloalfunval != 0)
		{
		 	eval(reloalfunval);
		}
		  
	}
	else if(arr[1]==3)
	{
		var resdivcont=arr[3];
		document.getElementById("group_list").innerHTML=resdivcont;
	}
	else
		alert("Problem in updation");
}

function update_friendgroup()
{
	
}
function close_linkgroup(bmkid)
{
    if(bmkid)
		document.getElementById("group_list_"+bmkid).style.display="none";
	else
	    document.getElementById("group_list").style.display="none";
}
function update_groupid_result(res)
{
	
	var arr=res.split("^^");
	
	bmkid=arr[2];
	//document.getElementById("grouplink_btn_"+bmkid).value="Save";
	//document.getElementById("grouplink_btn_"+bmkid).disabled=false;
	
	if(arr[1]==1)
		alert("Group name already exists. There are plenty of other names!");
	else if(arr[1]==2)
	{
		var resdivcont=arr[3];
		document.getElementById("group_list").innerHTML=resdivcont;
		document.getElementById("bmktypename_"+bmkid).innerHTML="Share";
		alert("Successfully updated");
	}
	else if(arr[1]==3)
	{
		var resdivcont=arr[3];
		document.getElementById("group_list").innerHTML=resdivcont;
	}
	else
		alert("Problem in updation");
}

function update_grpcheckbox_stat(bmkid,i)
{
	var obj;
	obj=document.getElementById("group_"+bmkid+"_"+i);
	if(obj.checked==true)
		document.getElementById("groupstat_"+bmkid+"_"+i).value="Y";
	else
		document.getElementById("groupstat_"+bmkid+"_"+i).value="N";
		
}
function clear_newgrp_text(bmkid)
{
	if(document.getElementById("new_groupname_"+bmkid).value=="New Group")
		document.getElementById("new_groupname_"+bmkid).value="";
}

function checkEnter(e)
{
	var characterCode;
	if(e && e.which)
	{
		e=e;
	}
	else
	{
		e=event;
		characterCode=e.keyCode;
	}
	
	if(characterCode==13)
	{
		alert('entered')
	}

}

function frpubbmk(para)
{
	loadrajax("../bmk/frndpublicbmk.php","POST",para,"mainsec");
}

function frpubbmk_listpage()
{
	
	var para,pg,list,bmtype,userid;
	pg=1;
	list=document.frpubbmk_frm.list_page.value;
	bmtype=document.frpubbmk_frm.bmtype.value;
	userid=document.frpubbmk_frm.userid.value;
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype+"&userid="+userid;
	
	frpubbmk(para);
}
function frpubbmk_gotopage(page)
{
	var para,pg,list,bmtype,userid;
	if(page)
		pg=page;
	else
		pg=document.frpubbmk_frm.pg.value;
	
	list=document.frpubbmk_frm.list_page.value;
	bmtype=document.frpubbmk_frm.bmtype.value;
	userid=document.frpubbmk_frm.userid.value;
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype+"&userid="+userid;
	
	frpubbmk(para);
}
function frpubbmk_listpagebot()
{
	var para,pg,list,bmtype,userid;
	pg=1;
	list=document.frpubbmk_frm.list_pagebot.value;
	bmtype=document.frpubbmk_frm.bmtype.value;
	userid=document.frpubbmk_frm.userid.value;
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype+"&userid="+userid;
	frpubbmk(para);
}
function frpubbmk_gotopagebot(page)
{
	var para,pg,list,bmtype,userid;
	if(page)
		pg=page;
	else
		pg=document.frpubbmk_frm.pgbot.value;
	
	list=document.frpubbmk_frm.list_pagebot.value;
	bmtype=document.frpubbmk_frm.bmtype.value;
	userid=document.frpubbmk_frm.userid.value;
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype+"&userid="+userid;
	frpubbmk(para);
}
function popularbmk(para)
{
	loadrajax("../bmk/popular_bmk.php","POST",para,"res");
}
function popbmk_gotopage(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.popbmk_frm.pg.value;
	list=document.popbmk_frm.list_page.value;
	bmtype=document.popbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	popularbmk(para);
}
function popbmk_listpage()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.popbmk_frm.list_page.value;
	bmtype=document.popbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	popularbmk(para);
}
function popbmk_gotopagebot(page)
{
	var para,pg,list,bmtype;
	
	if(page)
		pg=page;
	else
		pg=document.popbmk_frm.pgbot.value;
	list=document.popbmk_frm.list_pagebot.value;
	bmtype=document.popbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	
	popularbmk(para);
}

function popbmk_listpagebot()
{
	var para,pg,list,bmtype;
	
	pg=1;
	list=document.popbmk_frm.list_pagebot.value;
	bmtype=document.popbmk_frm.bmtype.value;
	
	para="pg="+pg+"&list_page="+list+"&bmtype="+bmtype;
	popularbmk(para);
}

function bmkstats(e, obj, offx, offy,userid)
{
	var para;
    positionFor(e, obj, offx, offy);
	para="userid="+userid;
	loadrajax("../bmk/bmkstats.php","POST",para,"bmkstats");
}
function loadchangpass(e, obj, offx, offy)
{
	positionFor(e, obj, offx, offy);
	loadrajax("../accounts/changepass.php","POST","","changepass");
}
function close_changepass()
{
	document.getElementById("changepass").style.display="none";
}
function ajax_chang_pass()
{
	var para,npass,olpass,cpass;
	var key="";
	olpass=document.getElementById("oldpass").value;
	npass=document.getElementById("newpass").value;
	cpass=document.getElementById("conpass").value;
	
	if(!validateNotEmpty(olpass))
	{
		key+="Old password\n";
	}
	if(!validateNotEmpty(npass))
	{
		key+="New password\n";
	}
	if(!validateNotEmpty(cpass))
	{
		key+="Confirm password\n";
	}
    if(key =="")
	{
		if(npass == cpass)
		{
			para="oldpass="+olpass+"&newpass="+npass;
			loadfajax("../accounts/ajax_chang_pass.php","post",para,ajax_chang_pass_result,'');
		}
		else
		  alert("New password and Confirm password mismatch");
	}
	else
	  alert(key);
}
function ajax_chang_pass_result(res)
{
	if(res ==1)
	{
		document.getElementById("changepass").style.display="none";
		alert("The password has been changed");
	}
	else
	  alert("please enter the correct password");
}
function Load_IEImport()
{
	loadrajax("../tools/import_ie.php","POST","","res");
}

function Load_FFImport()
{
	loadrajax("../tools/import_ff.php","POST","","res");
}
function Load_SFImport()
{
	loadrajax("../tools/import_sf.php","POST","","res");
}
function Load_OPImport()
{
	loadrajax("../tools/import_op.php","POST","","res");
}
function Load_DSImport()
{
	loadrajax("../tools/import_ds.php","POST","","res");
}
function Load_IEToolBar()
{
	loadrajax("../tools/toolbar_ie.php","POST","","res");
}
function Load_FFToolBar()
{
	loadrajax("../tools/toolbar_ff.php","POST","","res");
}
function Load_API_XML()
{
	loadrajax("../tools/api_xml.php","POST","","res");
}
function Load_API_JSON()
{
	loadrajax("../tools/api_json.php","POST","","res");
}
function Load_API_SOAP()
{
	loadrajax("../tools/api_soap.php","POST","","res");
}

function Load_AddThis()
{
	loadrajax("../tools/toolbar_addthis.php","POST","","res");
}

function loadstepimg(id)
{
 document.getElementById(id).style.display="block";	
}
function closestepimg(id)
{
	document.getElementById(id).style.display="none";	
}

/* Add Toolbar Bookmark */
function saveToolBarBookmark(bmkcnt)
{
	var key="";
	var bmarkname=document.getElementById("bkname").value;
	var url=document.getElementById("bkurl").value;
	var tag=document.getElementById("bktagname").value;
	var bktype;
	var RE;
	var favorite;
	bktype="";
	var err="";
	favorite="N";
	var bmkid="new";
	
	if(!validateNotEmpty(bmarkname))
	{
		key+="Title\n";
	}
	
	if(!validateNotEmpty(url))
	{
		key+="Website Link\n";
	}
	
	if(!validateNotEmpty(tag))
	{
		key+="Tags\n";
	}
	
	if(key)
	{
		alert("Please fill the required details\n\n"+key);
	}
	else
	{
		if(document.getElementById("bmtype_s").checked==true)
		{
			var newgrpname;
		
			newgrpname=document.getElementById("new_groupname_"+bmkid).value;
			if(bmkcnt==0 && newgrpname=="New Group")
			{
				err="Please enter the group name";
			}
			else if(bmkcnt>0 && newgrpname=="New Group")
			{
				var flag=false;
				for(i=0;i<bmkcnt;i++)
				{
					if(document.getElementById("group_"+bmkid+"_"+i).checked==true)
					{
						flag=true;
						break;
					}
				}
				if(flag==false)
					err="Please select the group name";
			}
			
			if(newgrpname!="New Group")
			{
				if(!validate_data(newgrpname,"Username"))
					err="Oops! Invalid group name. Special characters and spaces are not allowed.\n Only 5 to 30 characters are allowed";
			}
		}
		if(err)
		{
			alert(err);
		}
		else
		{
			var str=tag;
			if(str.indexOf("'")!=-1)
				alert("Oops! Invalid Tag name. Single Quotes are not allowed");
			else if(str.indexOf("/")!=-1)
				alert("Oops! Invalid Tag name. Forward Slash are not allowed");
			else
			{
				var para="";
				if(document.getElementById("bmtype_p").checked==true)
					bktype="P";
				else if(document.getElementById("bmtype_u").checked==true)
					bktype="U";
				else if(document.getElementById("bmtype_s").checked==true)
					bktype="S";
				
				if(document.getElementById("favorite_Y").checked==true)
					favorite="Y";
				
				url=escape(url);
				para="bkname="+bmarkname+"&bkurl="+url+"&bktagname="+tag+"&bktype="+bktype+"&favorite="+favorite;
				
				if(bktype=="S")
				{
					para+="&bmkid=new";
				
					if(newgrpname!="New Group")
						para+="&newgrpname="+newgrpname;
				
					for(i=0;i<bmkcnt;i++)
					{
						para+="&grpid[]="+document.getElementById("group_"+bmkid+"_"+i).value;
						para+="&grpstat[]="+document.getElementById("groupstat_"+bmkid+"_"+i).value;
					}
				}
				
				document.getElementById('savebutton').disabled=true;
				document.getElementById('savebutton').value='Processing...';
				loadfajax("../bmk/ajx_addtoolbarbmk.php","post",para,handle_saveToolBarBookmark,'');
			}
		}//if(err) close...
	}
}

function handle_saveToolBarBookmark(res)
{
     //alert(res);
	document.getElementById("toolbaradd").innerHTML=res;
}

function Export_mylink()
{
	var mylink;
	mylink=document.getElementById("cmbmylink").value;
	if(mylink=="")
		alert("Please select any one of the option");
	else
		window.iframe_export.location.href="../tools/export_mylink.php?optvalue="+mylink;
}

function Export_popularlinks()
{
	var poplinks;
	poplinks=document.getElementById("cmbpopularlinks").value;
	if(poplinks=="")
		alert("Please select any one of the option");
	else
		window.iframe_export.location.href="../tools/export_popularlinks.php?optvalue="+poplinks;
}

function Export_recentlinks()
{
	var recentlinks;
	recentlinks=document.getElementById("cmbrecentlinks").value;
	alert(recentlinks);
	if(recentlinks=="")
		alert("Please select any one of the option");
	else
		window.iframe_export.location.href="../tools/export_recentlinks.php?optvalue="+recentlinks;
}
function Export_bytag()
{
	var tagname="";

	tagname=document.getElementById("export_tag_name").value;
	if(tagname=="")
		alert("Please enter the tag name");
	else
		window.iframe_export.location.href="../tools/export_bytag.php?tagname="+tagname;
}

function Load_Interface_Export()
{
	loadrajax("../tools/export_excel.php","POST","","res");
}
function Load_Intreface_RSS()
{
	loadrajax("../tools/interface_rss.php","POST","","res");
}
function Load_Intreface_FaceBook()
{
	loadrajax("../tools/interface_facebook.php","POST","","res");
}
function Load_Interface_orkut()
{
	loadrajax("../tools/interface_orkut.php","POST","","res");
}
function Load_Intreface_ExcelExport()
{
	loadrajax("../tools/interface_excelexport.php","POST","","res");
}
function remove_favitem(favid)
{
	var para="";
	para="favid="+favid+"&action=remove";
	loadrajax("../bmk/myfavoritelist.php","POST",para,"res");
}
function Load_Soc_App()
{
	loadrajax("../tools/interface_facebook.php","POST","","res");
}
function addFB()
{
window.open("http://www.facebook.com/add.php?api_key=69f1fc46aae3bc85220c82503687ddb4","fb","");
}