// JavaScript Document
var http;
var idToDisplayMsg;
var urlForAjax;

function showSearchRslt(fullUrl,choice){
	idToDisplayMsg="showResultContents";
	urlForAjax=fullUrl+"/ajaxPages/searchResult.php?choiceExtra="+choice+"&mathRandom="+Math.random();	
	callAjaxFunction(urlForAjax);	
	url=fullUrl+"/ajaxPages/googleMap.php?mathRandom="+Math.random();	
	http2=null;
	http2 = getHTTPObject();		
	http2.open("GET", url , true);	
	http2.onreadystatechange = function (){
			if( http2.readyState == 4){								
				document.getElementById('map_canvas').innerHTML=http2.responseText;
				var scripts=document.getElementById('map_canvas').getElementsByTagName("SCRIPT");	
				//alert(scripts.length);
				for(i=0;i<scripts.length;i++)
				{
					eval("("+scripts[i].childNodes[0].textContent+")");					
				}
			
							
			}
			else{
				document.getElementById('map_canvas').innerHTML="Loading...";
				}
		};	
	http2.send(null);	
	}
function validateRegister(fullurl,fieldName,value){
	if(fieldName=='username')
		idToDisplayMsg="showUserMsg";
	else	
		idToDisplayMsg="showEmailMsg";
	urlForAjax=fullurl+"/ajaxPages/validateUser.php?fieldName="+fieldName+"&value="+value+"&mathRandom="+Math.random();	
	callAjaxFunction(urlForAjax);
	}
	
function showSrcLoc(path,cityId){
	if(cityId!=0){
		idToDisplayMsg="idSrcLeftLoc";	
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showLocation4Src&cityId="+cityId+"&mathRandomNum="+Math.random();	
		callAjaxFunction(urlForAjax);
		}	
	}	

function showSrcSubCat(path,CatId){
	if(CatId!=0){
		idToDisplayMsg="idSrcLeftSubCat";	
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showSubCat4Src&CatId="+CatId+"&mathRandomNum="+Math.random();	
		callAjaxFunction(urlForAjax);
		}
	}	


function updateHelpful(fullurl, reviewId, updatevalue){
	//updatevalue=document.getElementById('radioHelpful_'+reviewId).value;
	//alert(updatevalue);
	idToDisplayMsg="msgUpdateHelp_"+reviewId;
	urlForAjax = fullurl+"/ajaxPages/ajaxPage.php?choice=updateHelpful&updatevalue="+updatevalue+"&reviewId="+reviewId+"&mathRandomNum="+Math.random();	
	//alert(urlForAjax);
	callAjaxFunction(urlForAjax);
	}
function showFriendRequest(uId){
	idToDisplayMsg="sendRequest";
	urlForAjax="pages/sendrequest.php?uId="+uId+"&mathRandom="+Math.random();
	callAjaxFunction(urlForAjax);
	}
function showMessage(cId){
		idToDisplayMsg="showMessageForm";
		urlForAjax="../pages/inbox.php?cId="+cId+"&mathRandom="+Math.random();
		callAjaxFunction(urlForAjax);
		}
function ajaxPaging(fullurl,choice,page){	
	idToDisplayMsg="showResultContents";	
	urlForAjax = fullurl+"/ajaxPages/ajaxPaging.php?choice="+choice+"&paginationPage="+page+"&mathRandomNum="+Math.random();
	callAjaxFunction(urlForAjax);
	}
function showSubCat(path, categoryId){	
	if(categoryId!=0){
		idToDisplayMsg="showSubCategoryId";
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showSubCategory&categoryId="+categoryId+"&mathRandomNum="+Math.random();			
		callAjaxFunction(urlForAjax);
		}
	}
function blogArchives(year,month){
	idToDisplayMsg="showComment";
	urlForAjax = "../ajaxPages/blogAjax.php?cId="+year+"&mathRandom="+Math.random();	
	callAjaxFunction(urlForAjax);
	}
	function blogList(cId){
		idToDisplayMsg="showList";
		urlForAjax="../ajaxPages/blog.php?cId="+cId+"&mathRandom="+Math.random();
		callAjaxFunction(urlForAjax);
		}
function showCommentBoxForArchives(cId){
	idToDisplayMsg="showList";
	urlForAjax="../../ajaxPages/blogAjax.php?cId="+cId+"&mathRandom="+Math.random();
	callAjaxFunction(urlForAjax);
	}
	
function showCommentBox(cId){
	idToDisplayMsg="showList";
	urlForAjax = "../ajaxPages/blogAjax.php?cId="+cId+"&mathRandom="+Math.random();	
	callAjaxFunction(urlForAjax);
	}
	
function showCity(countryId,path){	
	if(countryId!=0){
		idToDisplayMsg="showCity";	
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showCity&countryId="+countryId+"&mathRandomNum="+Math.random();	
		callAjaxFunction(urlForAjax);	
		document.getElementById('showLocation').innerHTML="<input type='text' id='txtLocation' name='txtLocation' value='' class='logininput' />";
	}
	else{		
		document.getElementById('showCity').innerHTML="<input type='hidden' id='City' name='City' value='' class='logininput' /><input type='text' id='txtCity' name='txtCity' value=''  class='logininput' />";
		document.getElementById('showLocation').innerHTML="<input type='text' id='txtLocation' name='txtLocation' value=''  class='logininput' />";
		}
}

function showShoutCity(countryId,path){	
	if(countryId!=0){
		idToDisplayMsg="showCity";	
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showAdminCity&countryId="+countryId+"&mathRandomNum="+Math.random();	
		callAjaxFunction(urlForAjax);			
	}
	else{		
		document.getElementById('showCity').innerHTML="<input type='hidden' id='AdminCity' name='AdminCity' value='' class='logininput' /><input type='text' id='txtAdminCity' name='txtAdminCity' value=''  class='logininput' />";		
		}
}

function showCity1(countryId,path){
	if(countryId!=0){
		idToDisplayMsg="showCity";	
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showCity1&countryId="+countryId+"&mathRandomNum="+Math.random();
		callAjaxFunction(urlForAjax);	
	}	
}

function showLocation(cityId,path){
	if(cityId!=0){
		idToDisplayMsg="showLocation";	
		urlForAjax = path+"/ajaxPages/ajaxPage.php?choice=showLocation&cityId="+cityId+"&mathRandomNum="+Math.random();	
		callAjaxFunction(urlForAjax);
	}
	else{		
		document.getElementById('showLocation').innerHTML="<input type='text' id='txtLocation' name='txtLocation' value='' />";
		}
}
function callAjaxFunction(url){	
	http=null;
	http = getHTTPObject();		
	http.open("GET", url , true);	
	http.onreadystatechange = stateChanged;	
	http.send(null);
	}
function stateChanged(){		
		var docEle=eval("document.getElementById('"+idToDisplayMsg+"')");			
		if( http.readyState == 4){			
			docEle.innerHTML=http.responseText;			
		}
		else{
			docEle.innerHTML="Loading...";
			}

	}

function getHTTPObject() {
	var xmlhttp=null;
 	if(window.XMLHttpRequest){
    	xmlhttp = new XMLHttpRequest();
  	}
  	else if (window.ActiveXObject){
    	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	if (!xmlhttp){
        	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
    }
  	return xmlhttp;
}












