// JavaScript Document
var mdata;

//------------------------------------------------------------------------------------------------------------------------------//
function getHTTPObject()
{
	var xmlhttp;

	if(window.XMLHttpRequest)
	{
    	xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		if(!xmlhttp)
		{
        	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
	}
	return xmlhttp;
}

var http = getHTTPObject();
//------------------------------------------------------------------------------------------------------------------------------//

function body_onload()
{
	var currid = document.getElementById("hid_bcatid").value;	
	mover(currid);
}

function jumpto_comm(pagetype)
{
	if(pagetype == "comments")
	{
		pageurl = "?q=My+Profile&buzz=";
	}
	else if(pagetype == "gigya_stats")
	{
		pageurl = "?q=gigStats&buzz=";
	}
	else if(pagetype == "post_friends")
	{
		pageurl = "?q=post-buzzpod&buzz=";
	}
	
	var jumpto = document.getElementById("jumpto").value;
	if(jumpto == "")
	{
		return false;
	}
	else
	{
		window.location.href = pageurl + jumpto;
	}
}

function chgBackColor(action, tab)
{
	if(action == "mover")
	{
		document.getElementById(tab).style.backgroundColor = "#e96400";
	}
	else if(action == "mout")
	{
		document.getElementById(tab).style.backgroundColor = "#FFFFFF";
	}
}


/*********************************************** SIGN IN FORM - START **********************************************************/
function chkSigninFields()
{
	var un = document.getElementById("edit-name").value;
	var pass = document.getElementById("edit-pass").value;	

	if(un == "" || pass == "")
	{
		document.getElementById("errmsg").innerHTML = "User name and password is required field!";
		document.getElementById("errmsg").style.display = "inline";
		return false;
	}
	else
	{
		var url = "signin.php?un="+un+"&pass="+pass; // The server-side script
		http.open("GET",url,true);
		http.onreadystatechange = handleHttpResponse_Signin;
		http.send(null);
	}
}

function handleHttpResponse_Signin()
{
	if(http.readyState == 4)
	{
       	var results=http.responseText;		
			
		if(results != "ok")
		{
			document.getElementById("errmsg").innerHTML = results;
			document.getElementById("errmsg").style.display = "inline";		
			return false;
		}
		else if(results == "ok")
		{
			document.getElementById("errmsg").innerHTML = "";
			document.getElementById("errmsg").style.display = "";
			document.getElementById("errmsg").innerHTML = "Please wait while processing for login ...";			
			document.getElementById("edit-submit").disabled = true;
			document.frmlogin.submit();
		}
		return false;
	}
	return false;
}

function keyStroke(event)
{
	var KeyID = event.keyCode;
	if(KeyID == "13")
	{
		var val = chkSigninFields();
		if(val == "fasle")
			return false;
	}
}
/*********************************************** SIGN IN FORM - END **********************************************************/



/*********************************************** GALLERY FORM - START **********************************************************/
var act=0;
var btype=0;

function changexml2(bid)
{
	mout(document.getElementById("hid_bcatid").value,'onclick');
	mover(bid);
	document.getElementById("hid_bcatid").value = bid;
	btype = bid;
	mdata = '<embed src="buzzgallery.swf?btype='+bid+'" quality="high" bgcolor="#000000" width="665" height="350" name="buzzpodselect" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		
	var url = "getcatname.php?catid="+bid;
	http.open("GET",url,true);
	http.onreadystatechange = handleHttpResponse_gcn;
	http.send(null);
}

function handleHttpResponse_gcn()
{
	if(http.readyState == 4)
	{
		var results=http.responseText;
		document.getElementById("showing_all").innerHTML = "";
		document.getElementById("showing_all").innerHTML = results;
		document.getElementById("bmovie").innerHTML = "";
		document.getElementById("bmovie").innerHTML = mdata;
		return false;
	}
	return false;
}

function getpreview(ctval)
{
	create_buzzpod(ctval);
}

function create_buzzpod(ctval)
{	
	var bid = ctval;
	var cid = document.getElementById('hid_bcatid').value;
	window.location = "buzzkreator_editor?cid="+cid+"&bid="+bid;
}

function active(mid)
{
	if(act>0)
	{
		document.getElementById("arro"+act).style.display="none";
   		document.getElementById("arro"+mid).style.display="";
   	}
   	mover(mid);
   	act=mid;
}
 
function mover(mid)
{
	document.getElementById("row"+mid).style.color="#000000";
	document.getElementById("row"+mid).style.backgroundColor="#e4e4e4";
	document.getElementById("row"+mid).style.fontWeight="bold";
	document.getElementById("row"+mid).style.fontSize="13px";	
}

function mout(mid, act)
{
	var currid = document.getElementById("hid_bcatid").value;
	if((mid != currid) || (mid == currid && act == "onclick"))
	{		
		document.getElementById("row"+mid).style.color="#5c83aa";
		document.getElementById("row"+mid).style.backgroundColor="#FAFCFE";
		document.getElementById("row"+mid).style.fontWeight="bold";
		document.getElementById("row"+mid).style.fontSize="13px";
	}
}
/*********************************************** GALLERY FORM - END **********************************************************/

/*********************************************** EXPLORE FORM - START **********************************************************/
var act=0; 
function mover_ex(mid)
{
	document.getElementById("cat"+mid).style.color="#000000";
	document.getElementById("cat"+mid).style.backgroundColor="#e4e4e4";
	document.getElementById("cat"+mid).style.fontWeight="bold";
	document.getElementById("cat"+mid).style.fontSize="13px";
} 
function mout_ex(mid, act)
{	
	var currid = document.getElementById('hid_currid').value;
	if(mid != currid)
	{	
		document.getElementById("cat"+mid).style.color="#5c83aa";
		document.getElementById("cat"+mid).style.backgroundColor="#FAFCFE";
		document.getElementById("cat"+mid).style.fontWeight="bold";
		document.getElementById("cat"+mid).style.fontSize="13px";
	}
}
/*********************************************** EXPLORE FORM - END **********************************************************/

/******************************************* ANALYTICS & REPORTS - START ******************************************************/
function info()
{
	document.getElementById('graph').style.display="none";
	document.getElementById('infor').style.display="";
}

function graph()
{
	document.getElementById('graph').style.display="";
	document.getElementById('infor').style.display="none";
}

function interload()
{
	document.getElementById('load').style.display="";
	document.getElementById('view').style.display="none";
	document.getElementById('profile').style.display="none";
	document.getElementById('bulletine').style.display="none";
	document.getElementById('innetwork').style.display="none";
}

function interview()
{
	document.getElementById('load').style.display="none";
	document.getElementById('view').style.display="";
	document.getElementById('profile').style.display="none";
	document.getElementById('bulletine').style.display="none";
	document.getElementById('innetwork').style.display="none";
}

function interprofile()
{
	document.getElementById('load').style.display="none";
	document.getElementById('view').style.display="none";
	document.getElementById('profile').style.display="";
	document.getElementById('bulletine').style.display="none";
	document.getElementById('innetwork').style.display="none";
}

function interbulletine()
{
	document.getElementById('load').style.display="none";
	document.getElementById('view').style.display="none";
	document.getElementById('profile').style.display="none";
	document.getElementById('bulletine').style.display="";
	document.getElementById('innetwork').style.display="none";
}

function inetwork()
{
	document.getElementById('load').style.display="none";
	document.getElementById('view').style.display="none";
	document.getElementById('profile').style.display="none";
	document.getElementById('bulletine').style.display="none";
	document.getElementById('innetwork').style.display="";
}

function chbuzz()
{  
var nwt=document.getElementById("network").value;
var bzid=document.getElementById("buzzid").value;
var ss_dt=document.getElementById("date_from").value;
var en_dt=document.getElementById("date_to").value;
if(bzid=="")
{
	alert("Please select a buzzpod to see details!");
	return false;
}
else{
	window.location="?q=gigStats&buzz="+bzid+"&nwt="+nwt+"&s_t="+ss_dt+"&e_t="+en_dt;
}
}
function close_info(close_id)
{
	document.getElementById(close_id).style.display="none";
	document.getElementById(close_id+'close').style.display="none";
	document.getElementById(close_id+'open').style.display="";
}
function open_info(open_id)
{
	document.getElementById(open_id).style.display="";
	document.getElementById(open_id+'open').style.display="none";
	document.getElementById(open_id+'close').style.display="";
}

/******************************************* ANALYTICS & REPORTS - END ******************************************************/

/******************************************* EXPLORE SEARCH - START ******************************************************/

function srhtag()
{
	var ftype = document.getElementById("hid_type").value;
	var st = document.getElementById("txtsearch").value;
	var pageno = document.getElementById("hid_pageno").value;
	if(pageno == 1)
	{
		if(st == "Search by Tag" || st == "")
		{
			window.location = "?q=explore&type="+ftype;
		}
		else
		{
			window.location = "?q=explore&type="+ftype+"&st="+st;
		}
	}
	else
	{
		if(st == "Search by Tag" || st == "")
		{
			window.location = "?q=explore&type="+ftype+"&page="+pageno;
		}
		else
		{
			window.location = "?q=explore&type="+ftype+"&st="+st+"&page="+pageno;
		}
	}
}

function srhfocus()
{
	var st = document.getElementById("txtsearch").value;
	if(st == "Search by Tag")
	{
		document.getElementById("txtsearch").value = "";
	}	
}

function srhblur()
{
	var st = document.getElementById("txtsearch").value;
	if(st == "")
	{
		document.getElementById("txtsearch").value = "Search by Tag";
	}
}

function srhtag1()
{
	document.getElementById("hid_pageno").value = 1;
	srhtag();
}

function chkkey(e)
{
	if(e.keyCode == 13)
	{
		document.getElementById("hid_pageno").value = 1;
		srhtag();
	}
	else
	{
		return false;
	}
}

function settype(ftype)
{
	document.getElementById("hid_type").value = ftype;
	srhtag();
}

function setpage(pageno)
{
	document.getElementById("hid_pageno").value = pageno;
	srhtag();
}

/******************************************* EXPLORE SEARCH - END ******************************************************/
