function toggle(toggleId, e)
{
	if (!e) {
		e = window.event;
	}
	if (!document.getElementById) {
		return false;
	}
	var body = document.getElementById(toggleId);
	if (!body) {
		return false;
	}
	if (body.style.display == "none") {
		body.style.display = "block";
	} else {
		body.style.display = "none";
	}
}

function LargeView(URL,memberId,photoId,galleryId,pselect)
{
	var mywindow=window.open(URL+"MemberPhoto.php?memberId="+memberId+"&photoId="+photoId+"&galleryId="+galleryId+"&pselect="+pselect,"",'width=680,height=650,');
	mywindow.moveTo(200,10);
}

function LargeViewSecond(URL,memberId,photoId,galleryId,pselect)
{
	var mywindow=window.open(URL+"MemberPhotos.php?memberId="+memberId+"&photoId="+photoId+"&galleryId="+galleryId+"&pselect="+pselect,"",'width=680,height=650,');
	mywindow.moveTo(200,10);
}

function MoveToFolder(form,acurl)
{
	var xx =eval("document."+form);
	var flag=0;
	for (i=0;i<xx.length;i++)
	{
		var el = xx.elements[i];

			if (el.name == "photo[]")
			{
				if(el.checked==true)
				{
					flag=10;
				}
			}
	}
	if (flag==10)
	{
		if(xx.foldername.value=="")
		{
			alert("Please select the folder name.");
			xx.foldername.focus();
			return false;
		}
		else
		{
			if(confirm("Do you want to move selected photos?"))
			{
				xx.action=acurl;
				xx.submit();
			}	
		}	
	}
	else
	{
		alert("Please select at least one photo.");
		return false;
	}
}
function DeletePhotoConfirm(form,acurl)
{
	var xx =eval("document."+form);
	var flag=0;
	for (i=0;i<xx.length;i++)
	{
		var el = xx.elements[i];

			if (el.name == "photo[]")
			{
				if(el.checked==true)
				{
					flag=10;
				}
			}
	}
	if (flag==10)
	{
		if(confirm("Do you want to delete selected photos?"))
		{
			xx.action=acurl;
			xx.submit();
		}	
	}
	else
	{
		alert("Please select at least one photo.");
		return false;
	}
}

function NewProfileApprove(form,acurl)
{

	var xx =eval("document."+form);
	if(confirm("Do you want to approve this profile?"))
	{
		xx.action=acurl;
		xx.submit();
	}
	else
	{
		return false;
	}
}

function NewProfileReject(form,acurl)
{

	var xx =eval("document."+form);
	if(confirm("Do you want to reject this profile?"))
	{
		if(xx.reject_reason.value=="")
		{
			alert("Please select an appropriate reason to reject this profile.");
			xx.reject_reason.focus();
			return false;
		}
		xx.action=acurl;
		xx.submit();
	}
	else
	{
		return false;
	}
}

function expandCollapse(toggleId, e)
{
	if (!e) {
		e = window.event;
	}
	if (!document.getElementById) {
		return false;
	}
	var body = document.getElementById(toggleId);
	if (!body) {
		return false;
	}
	if (body.style.display == "none") 
	{
		body.style.display = "block";
	} 
	else 
	{
		body.style.display = "none";
	}
}

function getApproveEmailContent(form)
{
	var xx =eval("document."+form);
	xx.ApporveMessageSubject.value=xx.temp_approve_subject.value;
	var body=xx.temp_approve_message.value;
	body=body.replace(/##Approve-Reason##/g,xx.approve_reason.value);
	xx.ApproveMessageContent.value=body;

	if(xx.approve_reason.value=="")
	{
		document.all["_ApproveMessageContent_editor"].contentWindow.document.body.innerHTML="";	
	}
	else
	{
		document.all["_ApproveMessageContent_editor"].contentWindow.document.body.innerHTML="";
		editor_insertHTML('ApproveMessageContent',body,"");
	}	
}

function getRejectEmailContent(form)
{
	var xx =eval("document."+form);
	xx.RejectMessageSubject.value=xx.temp_reject_subject.value;
	var body=xx.temp_reject_message.value;
	body=body.replace(/##Reject-Reason##/g,xx.reject_reason.value);
	xx.RejectMessageContent.value=body;
	
	if(xx.reject_reason.value=="")
	{
		document.all["_RejectMessageContent_editor"].contentWindow.document.body.innerHTML="";
	}
	else
	{
		document.all["_RejectMessageContent_editor"].contentWindow.document.body.innerHTML="";
		editor_insertHTML('RejectMessageContent',body,"");
	}	
}

function expandCollapseApproveEmail(form,toggleId)
{
	var xx =eval("document."+form);
	if (!document.getElementById) {
		return false;
	}
	var body = document.getElementById(toggleId);
	
	if (!body) {
		return false;
	}

	if(xx.approve_reason.value=="")
	{
		body.style.display = "none";
	}
	else
	{
		body.style.display = "block";
	}
}

function expandCollapseRejectEmail(form,toggleId)
{
	var xx =eval("document."+form);
	if (!document.getElementById) {
		return false;
	}
	var body = document.getElementById(toggleId);
	
	if (!body) {
		return false;
	}

	if(xx.reject_reason.value=="")
	{
		body.style.display = "none";
	}
	else
	{
		body.style.display = "block";
	}
}

function getSiteMaintenanceData(form,mess)
{
	var xx =eval("document."+form);
	var body=mess;
	xx.message.value=body;
	alert(body);
	if(xx.branchId.value=="")
	{
		document.all["_message_editor"].contentWindow.document.body.innerHTML="";
	}
	else
	{
		document.all["_message_editor"].contentWindow.document.body.innerHTML="";
		editor_insertHTML('message',body,"");
	}	
}

function delete_confirm(form)
{
	if(form.btn_submit.value == "Delete")
	{	
		if(confirm("Are you sure you want to Delete? "))
		{
			form.submit;
		}
		else
		{
			return false;
		}
	}
}
function checkall(objForm)
{
	len = objForm.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) 
	{
		if (objForm.elements[i].type=='checkbox') 
		{
			objForm.elements[i].checked=objForm.check_all.checked;
		}
	}
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var tableBusy = false;
var tableHttp = getHTTPObject();
var step1Over = false;
var row = "";



/* #################################### SUB CATEGORY ####################################### */
function getAccociateList(objCatId)
{
	if(!tableBusy)
	{
		document.form1.nAccociateId.options.length = 0;
		document.form1.nAccociateId.options[0] = new Option("Loading...","");
		var url = "displayaccociate.php?id=" + objCatId;
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkAccociate;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}

function checkAccociate()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('Subcategories');
				
				var output = xmlRecord[0].getElementsByTagName('subcatname').item(0).firstChild.data;

				if (output == "N State|")
				{
					document.form1.nAccociateId.options.length = 0;
				}
				else
				{
					var nAccociateId = document.form1.nAccociateId;
					nAccociateId.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						nAccociateId.options[i] = new Option(stateArr[1],stateArr[0]);
					}
				}
				tableBusy = false;
			}
			catch(e)
			{
				alert("Error: " + e) ;
			}
		}
	}
}

/* #################################### SUB SUB CATEGORY ####################################### */

function getLocation( objSubCatId)
//ratnesh
{	
	if(!tableBusy)
	{
//		alert(objSubCatId);
	//	alert(name);
		document.form2.nLocationId.options.length = 0;
		document.form2.nLocationId.options[0] = new Option("Loading...","");
		var url = "displaylocation.php?id=" + objSubCatId;
		//alert(url);
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkSubSubCategoryListResponse;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}


function checkSubSubCategoryListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('Location');
				
				var output = xmlRecord[0].getElementsByTagName('location').item(0).firstChild.data;

				if (output == "N State|")
				{
					document.form2.nLocationId.options.length = 0;
				}
				else
				{
					var nLocationId = document.form2.nLocationId;
					nLocationId.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						nLocationId.options[i] = new Option(stateArr[1],stateArr[0]);	//new Option('new text','new value');
					}
				}
				// Draw Record status and nav buttons
				//document.getElementById('checkresponse').innerHTML = output;
				tableBusy = false;
				//document.getElementById('imgProgress2').style.display = 'none';
			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function

/*##################################Sub Type######################################*/


function getSubType(objSubCatId)
{	
	if(!tableBusy)
	{
		document.form1.nSubType.options.length = 0;
		document.form1.nSubType.options[0] = new Option("Loading...","");
		var url = "displaynsubtype.php?id=" + objSubCatId;
		//alert(url);
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkSubTypeResponse;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}


function checkSubTypeResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('SubType');
				
				var output = xmlRecord[0].getElementsByTagName('subtype').item(0).firstChild.data;

				if (output == "N State|")
				{
					document.form1.nSubType.options.length = 0;
				}
				else
				{
					var nSubType = document.form1.nSubType;
					nSubType.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						nSubType.options[i] = new Option(stateArr[1],stateArr[0]);	//new Option('new text','new value');
					}
				}
				// Draw Record status and nav buttons
				//document.getElementById('checkresponse').innerHTML = output;
				tableBusy = false;
				//document.getElementById('imgProgress2').style.display = 'none';
			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function





////////////////////////////////////////////////////////////////////////////
function getCityList(objSubCatId)
{	
	if(!tableBusy)
	{
		document.form1.nCityId.options.length = 0;
		document.form1.nCityId.options[0] = new Option("Loading...","");
		var url = "displaycity.php?id=" + objSubCatId;
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkCityListResponse;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}
function checkCityListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('Subcategories');
				
				var output = xmlRecord[0].getElementsByTagName('subcatname').item(0).firstChild.data;

				if (output == "N City|")
				{
					document.form1.nCityId.options.length = 0;
				}
				else
				{
					var nCityId = document.form1.nCityId;
					nCityId.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						nCityId.options[i] = new Option(stateArr[1],stateArr[0]);	//new Option('new text','new value');
					}
				}
				// Draw Record status and nav buttons
				//document.getElementById('checkresponse').innerHTML = output;
				tableBusy = false;
				//document.getElementById('imgProgress2').style.display = 'none';
			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function

//  ###################################################   Locality List #########################################################
function postRequest(strURL)
{
    var xmlHttp;
    if(window.XMLHttpRequest)
    {
        var xmlHttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.open('POST', strURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById("nLocalityId").innerHTML=xmlHttp.responseText;
			//getAllcomments(uid);
        }
    }
    xmlHttp.send(strURL);
}

function getLocalityList_sub(objCatId, objState)
{
	var url = "getlocalitylist.php?id=" + objCatId + "&sid="+objState;
	postRequest(url);
}
// ###################################################   Locality List #########################################################

function getLocalityList(objCatId, objState)
{	
	//document.getElementById('imgProgress1').style.display = 'inline';
	if (!tableBusy)
	{
		//document.getElementById('imgProgress1').style.display = 'inline';
		document.form1.nLocalityId.options.length = 0;
		document.form1.nLocalityId.options[0] = new Option("Loading...","");
		var url = "displaylocalitylist.php?id=" + objCatId + "&sid="+objState;
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkLocalityListResponse;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}

function checkLocalityListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('Subcategories');
				
				var output = xmlRecord[0].getElementsByTagName('subcatname').item(0).firstChild.data;

				if (output == "N City|")
				{
					document.form1.nLocalityId.options.length = 0;
				}
				else
				{
					var nLocalityId = document.form1.nLocalityId;
					nLocalityId.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						nLocalityId.options[i] = new Option(stateArr[1],stateArr[0]);	//new Option('new text','new value');
					}
				}
				// Draw Record status and nav buttons
				//document.getElementById('checkresponse').innerHTML = output;
				tableBusy = false;
				//document.getElementById('imgProgress2').style.display = 'none';
			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
}
// ###################################################  End City List #########################################################
function getLocalityRequest(strURL)
{
    var xmlHttp;
    if(window.XMLHttpRequest)
    {
        var xmlHttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.open('POST', strURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById("DivLocality").innerHTML=xmlHttp.responseText;
			//getAllcomments(uid);
        }
    }
    xmlHttp.send(strURL);
}
function getLocality(objCoId)
{
	var url = "getColocalitylist.php?id=" + objCoId;
	getLocalityRequest(url);
}
// ###################################################  Products Company Locality List #########################################################
function getCoLocalityList(objCoId)
{	
	if (!tableBusy)
	{
		document.form1.nLocalityId.options.length = 0;
		document.form1.nLocalityId.options[0] = new Option("Loading...","");
		var url = "displaycolocalitylist.php?id=" + objCoId;
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkCoLocalityListResponse;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}

function checkCoLocalityListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('Subcategories');
				
				var output = xmlRecord[0].getElementsByTagName('subcatname').item(0).firstChild.data;
				//document.getElementById('imgProgress1').style.display = 'inline';
				if (output == "No Locality|")
				{
					document.form1.nLocalityId.options.length = 0;
				}
				else
				{
					var nLocalityId = document.getElementById('nLocalityId');
					nLocalityId.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						nLocalityId.options[i] = new Option(stateArr[1],stateArr[0]);	//new Option('new text','new value');
					}
				}
				// Draw Record status and nav buttons
				//document.getElementById('checkresponse').innerHTML = output;
				tableBusy = false;
				//document.getElementById('imgProgress2').style.display = 'none';
			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
}
// ###################################################  End City List #########################################################


/* #################################### SUB Location ####################################### */

function getSubLocation( indposation,  objSubCatId)
{		
	if(!tableBusy)
	{
		//alert(objSubCatId);
		//alert(indposation);
		document.form2.sublocationid.options.length = 0;
		document.form2.sublocationid.options[0] = new Option("Loading...","");
		var url = "displaySublocation.php?id=" + objSubCatId +"&"+"IndexPos=" +indposation;
		//alert(url);
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkSubLocationListResponseNew;
		tableHttp.send(null);
		tableBusy = true;
		tableHttp.send(null);
	}
}
function checkSubLocationListResponseNew()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var xmlRecord = tableHttp.responseXML.getElementsByTagName('Location');
				
				var output = xmlRecord[0].getElementsByTagName('locations').item(0).firstChild.data;

				if (output == "N City|")
				{
					document.form2.sublocationid.options.length = 0;
				}
				else
				{
					var sublocationid = document.form2.sublocationid;
					sublocationid.options.length = 0;
					var outputArr = new Array();
					outputArr = output.split(":");
					var list = outputArr;
					for(i=0;i<list.length;i=i+1)
					{
						var stateString = list[i];
						var stateArr = new Array();
						stateArr = stateString.split("|");
						sublocationid.options[i] = new Option(stateArr[1],stateArr[0]);	//new Option('new text','new value');
					}
				}
				// Draw Record status and nav buttons
				//document.getElementById('checkresponse').innerHTML = output;
				tableBusy = false;
				//document.getElementById('imgProgress2').style.display = 'none';
			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function
