/**
 * Company Basic Info Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage companysignup
 */
var ajaxObjects = new Array();
var intTotalPage = 0;

function fnAjaxContentProcess(intContentPageId, strAction, objLink)
{
	document.getElementById("commentAddShow").style.display = "none";
	var url = sitename+'/index.php?action='+strAction+'&mode=ajax&ajax_action=showpagecontent&page='+Base64.encode(intContentPageId);
	
	fnShowInfoLoadingImage("id_ShowCompanyContent");
	
	ajaxObjects[0] = new sack();
	ajaxObjects[0].requestFile = url;
	ajaxObjects[0].onCompletion = function(){
												document.getElementById("id_ShowCompanyContent").innerHTML = ajaxObjects[0].response;
												if (intTotalPage)
												{
													for (intPage = 1; intPage <= intTotalPage; intPage++)
													{
														if (intPage == parseInt(objLink.id))
															document.getElementById(intPage).className = "activeOption";
														else
															document.getElementById(intPage).className = "";
													}
												}
											}
	ajaxObjects[0].runAJAX();
}

function fnShowChangePhoto()
{
	document.getElementById('id_changelogo').style.display = "";
}

function fnHideChangePhoto()
{
	document.getElementById('id_changelogo').style.display = "none";
}

function fnShowChangeImageBox(strDivId,boolAlwaysShow)
{
	window.scroll(0,0);
	try{
		if (boolAlwaysShow == 0)
			document.getElementById('id_editcompanylogo').style.display = "none";	
		
		Lightbox.showBoxByID(strDivId, 470,370);
	}
	catch (e)
	{alert(e)}
}

function fnAddNewSubpage()
{
	Lightbox.showBoxByID("id_ManageSubPage", 500,480);
	document.getElementById("id_SubPageFrame").src = sitename+'/managesubpage?pageid=0';
}

function fnEditNewSubpage(intContentPageId)
{
	if (parseInt(intContentPageId) > 0)
	{
		Lightbox.showBoxByID("id_ManageSubPage", 500,480);
		document.getElementById("id_SubPageFrame").src = sitename+'/managesubpage?pageid='+intContentPageId;
	}
	else if (intContentPageId == "about")
	{
		Lightbox.showBoxByID("id_ManageSubPage", 500,480);
		document.getElementById("id_SubPageFrame").src = sitename+'/managesubpage?pageid=about';
	}
}

function fnDeleteSubpage(intContentPageId)
{
	if (isNaN(parseInt(intContentPageId)))
		return false;
		
	if (confirm("Are you sure? You want to delete this page?") == false)
		return false;

	ajaxObjects[1] = new sack();
	ajaxObjects[1].requestFile = sitename + "/managecompanyprofile?mode=ajax&ajax_action=deletesubpage&page="+intContentPageId;
	ajaxObjects[1].onCompletion = function(){
												document.getElementById("id_LeftSubPages").innerHTML = ajaxObjects[1].response;
											}
	ajaxObjects[1].runAJAX();

	fnAjaxContentProcess("aboutme","managecompanyprofile");
}

function fnShowEditContactInfo()
{
	Lightbox.showBoxByID("id_CompanyContactInfo", 500,480);
}

function fnShowCommentListing()
{
	if (document.getElementById("id_CommentListing").style.display == "none")
	{
		document.getElementById("id_CommentListing").style.display = "";
		document.getElementById("id_ShowCommentLink").innerHTML = document.getElementById("id_ShowCommentLink").innerHTML.replace("Show","Hide");
	}
	else
	{
		document.getElementById("id_CommentListing").style.display = "none";
		document.getElementById("id_ShowCommentLink").innerHTML = document.getElementById("id_ShowCommentLink").innerHTML.replace("Hide","Show");
	}
}

function fnSetFadeEffects(strDivId)
{
	if (strDivId != "")
	{
		try{
		setTimeout("fnChangeColorOfElement('"+strDivId+"','0.50')",1500);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','0.40')",1580);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','0.30')",1660);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','0.20')",1740);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','0.10')",1820);
		}
		catch(e)
		{}
	}
}

function fnChangeColorOfElement(intIdOfElement,strColor)
{
	document.getElementById(intIdOfElement).style.opacity = strColor;
}

function fnHideMessageDiv(strMessageDiv)
{
	try{
		document.getElementById(strMessageDiv).innerHTML = "";
		document.getElementById(strMessageDiv).style.display = "none";
	}
	catch(e)
	{}
}

function fnShowInfoLoadingImage(strContainerHtml)
{
	document.getElementById(strContainerHtml).innerHTML = "<div style='text-align:center; padding: 40px;'><span style='font-size: 20px; font-weight: bold; color: #AAAAAA;'>Loading...</span><br /><br /><img src='images/big_slide_loader.gif' align='absmiddle'></div>";
}

function fnAjaxPaginationLoader(strContentId)
{
	strHtml = "";
	strHtml = strHtml + "<div style='text-align:center; padding: 40px 0  40px 0;'>";
	strHtml = strHtml + "<span style='font-size: 14px; font-weight: bold; color: #AAAAAA;'>Loading...</span><br /><br />";
	strHtml = strHtml + "<img src='images/ajax-loader-small-bar.gif' align='absmiddle'>";
	strHtml = strHtml + "</div>";
	document.getElementById(strContentId).innerHTML = strHtml;
}

function fnShowCompanyVideo(intVideoId)
{
	document.getElementById("id_Video_Popup_"+intVideoId).innerHTML = document.getElementById("id_FrameContainer").innerHTML;
	document.getElementById("id_Video_Frame").src = sitename+"/viewvideoplayer?video="+intVideoId;
	Lightbox.showBoxByID("id_Video_Popup_"+intVideoId, 455,450);
}