/**********************************************
VYOM AJAX PROCESSOR
(c) Vyom Technosoft Pvt. Ltd.
Author - Amit Mathur, 18 Jun 2006

Unauthorised copying or distribution is
prohibited.
***********************************************/

function vyomAJAXProcessor(strURL,divName)
{
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			updatepage(self.xmlHttpReq.responseText,divName);
		}
	}
	self.xmlHttpReq.send(strURL);
}
//***********************displaying read message*****************

function vyomAJAXPreProcessorForMessage(messageId,check)
{
	divName="result"+messageId 		
	updatepage("<font face=verdana size=1 color=black>Please wait; loading the message for the selected message subject...</font>",divName);
	if(check=='1')
	{
	strURL = "message-read-ajaxProcessor.asp?min=1&c=" + messageId ;
	}
	else
	{
	strURL = "message-read-ajaxProcessor.asp?c=" + messageId;
	}
	
	//alert(divName)
	vyomAJAXProcessor(strURL,divName);
}


//************************* displaying sent message****************


function vyomAJAXPreProcessorFromComm(messageId,check)
{
	divName="result"+messageId 		
	updatepage("<font face=verdana size=1 color=black>Please wait; loading the message for the selected message subject...</font>",divName);
	if(check=='1')
	{
	strURL = "message-read-ajaxProcessor.asp?from=comm&min=1&c=" + messageId ;
	}
	else
	{
	strURL = "message-read-ajaxProcessor.asp?from=comm&c=" + messageId;
	}
	
	//alert(divName)
	vyomAJAXProcessor(strURL,divName);
}

function vyomAJAXCheckUser()
{    
	updatepage("<font class='specialtext'>Checking...</font>","result");
	strURL = "/checkUser.asp?name=" + document.forms['register'].userName.value + "&firstName=" + document.forms['register'].firstName.value + "&lastName=" + document.forms['register'].lastName.value;
	vyomAJAXProcessor(strURL,"result");
}


function updatepage(str,divName){
	document.getElementById(divName).innerHTML = str;
}

function vyomAJAXCheckCommunity()
{
	updatepage("<font class='specialtext'>Checking...</font>","result");
	strURL = "/checkCommunity.asp?name=" + document.forms['frmAddCommunity'].name.value;
	vyomAJAXProcessor(strURL,"result");
}



function vyomAJAXChangeTimeZone()
{    
	updatepage("<font class='specialtext'>Please wait; loading the process page for Changing the Time Zone...</font>","result");
	strURL = "/timezone.asp"
	vyomAJAXProcessor(strURL,"result");
}


//******************* selecting the provider for sending the invitation ******

function vyomAJAXPreProcessorInvite(provider)
{
	
	divName="result"	
	updatepage("<font face=verdana size=1 color=black>Please wait; loading the process page for seleted provider...</font>",divName);
	
	strURL = "invite-friend-ajaxProcessor.asp?provider=" + provider ;		
	
	vyomAJAXProcessor(strURL,divName);
}

function vyomAJAXPreProcessorInvite1()
{
	
	divName="result1"	
	updatepage("<font face=verdana size=1 color=black>Please wait; loading the process page for seleted provider...</font>",divName);
	
	strURL = "invite-friend-ajaxProcessor1.asp" ;		
	
	vyomAJAXProcessor(strURL,divName);
}

	
function  vyomAJAXCommunitySubCategory()
{
	updatepage("<IMG SRC='images/loading.gif'>","result1");
	strURL = "getCommunitySubCategory.asp?id=" + document.forms['frmAddCommunity'].category.value;
	vyomAJAXProcessor(strURL,"result1");
}
function  vyomAJAXComm()
{
	alert('d')
	updatepage("<IMG SRC='images/loading.gif'>","commList");
	strURL = "subCommList.asp";
	alert('d'+strURL)
	vyomAJAXProcessor(strURL,"commList");
}
function  vyomAJAXCommList(strList,divName)
{
	
	updatepage("<IMG SRC='images/loading.gif'>",divName);
	strURL = ""+strList;
	
	vyomAJAXProcessor(strURL,divName);
}

function vyomAJAXPreProcessorHindi()
{
	
	divName="scrapWriteDiv"	
	updatepage("<font face=verdana size=1 color=black>Please wait; loading Hindi writing interface....</font>",divName);
	
	strURL = "/language/writer.asp?l=hi" ;		
	
	vyomAJAXProcessor(strURL,divName);
}

function vyomAJAXShoutout()
{
	//updatepage("<font class='specialtext'>Retrieving...</font>","result");
	strURL = "/shoutout-process.asp?message=" + document.forms['frmShoutout'].message.value;
	vyomAJAXProcessor(strURL,"result");
}

function vyomAJAXGetFolderName()
{    
	updatepage("<font class='specialtext'>Getting...</font>","result");
	strURL = "/getFolderName.asp?name=" + document.forms['form'].templateName.value 
	vyomAJAXProcessor(strURL,"result");
}

function vyomAJAXPreProcessorForImage(fileName,qs,manip,save)
{
    
	updatepage("<font face=verdana size=1 color=black>Please wait; loading the image ......</font>","result");
	strURL = "/image-manipulations-ajax.asp?i=" + fileName + "&" + qs + "=" + manip + "&save=" + save;
	vyomAJAXProcessor(strURL,"result");
}


function Ajaxeditalbum(albumId)
{
	updatepage("<img src='/images/loading.gif'>", "album"+albumId)
	strURL = "/albums/edit-album.asp?aid=" + albumId;
	vyomAJAXProcessor(strURL,"album"+albumId)
}

function Ajaxeditalbumprocess()
{
	albumId = document.forms['albumfrm'].albumId.value;
	albumName = document.forms['albumfrm'].albumName.value;
	albumDesc = document.forms['albumfrm'].albumDescription.value;
	updatepage("<img src='/images/loading.gif'>","album"+albumId)
	strURL = "/albums/edit-album-process.asp?aid="+ albumId + "&an=" + albumName + "&ad=" + albumDesc;
	vyomAJAXProcessor(strURL,"album"+albumId)
}

function AJAXCancelEditAlbum()
{
	albumId2 = document.forms['albumfrm'].albumId.value;
	updatepage("<img src='/images/loading.gif'>","album"+albumId2)
	strURL = "/albums/cancel-edit-album.asp?aid="+albumId2;
	vyomAJAXProcessor(strURL,"album"+albumId2)
}

function Ajaxeditphoto(photoId)
{
	updatepage("<img src='/images/loading.gif'>","photo"+photoId);
	strURL = "/albums/edit-album-photo.asp?pid=" + photoId;
	vyomAJAXProcessor(strURL,"photo"+photoId);
}

function AjaxEditPhotoProcess()
{
	photoId3 = document.forms['photofrm'].photoId2.value;
	photoCaption = document.forms['photofrm'].photoCaption.value;
	photoDescription = document.forms['photofrm'].photoDescription.value;
	if (document.forms['photofrm'].cover.checked == true)
	{
		chk = 1
	}
	else
	{
		chk = 0
	}
	
	updatepage("<img src='/images/loading.gif'>","photo"+photoId3);
	strURL = "/albums/edit-album-photo-process.asp?pid="+ photoId3 + "&pcap="+ photoCaption + "&pdesc="+ photoDescription + "&chk="+ chk;
	vyomAJAXProcessor(strURL,"photo"+photoId3)
}

function AJAXCancelEditAlbumPhoto()
{
	photoId4 = document.forms['photofrm'].photoId2.value;
	updatepage("<img src='/images/loading.gif'>","photo"+photoId4)
	strURL = "/albums/cancel-edit-album-photo.asp?pid="+photoId4;
	vyomAJAXProcessor(strURL,"photo"+photoId4)
}