/***********************************************************/
//Function To Generate New Captcha Image And Ajax Function
/***********************************************************/
var ajaxObj;
var divID; //To Get Div Desired Div ID
function getNewImage(getDivID, getFileToBeCalled){
	divID=getDivID;//Assigning The Div ID To Globle Variable
	ajaxObj=GetXmlHttpObject();
	if(ajaxObj==null){
		alert('Error: Your browser doesn\'t support ajax');
		return false;
	}
	var callFile=getFileToBeCalled+'?divID='+getDivID;
	ajaxObj.onreadystatechange=stateChanged;
	ajaxObj.open('GET', callFile, true);
	ajaxObj.send(null);
}

/*********************************************/
//Return the price list as the Buying Or Rent
/*********************************************/
function FUNC_getPriceListBuyingAndRent(getDivID, getFileToBeCalled, extraPeram){
	divID=getDivID;//Assigning The Div ID To Globle Variable
	ajaxObj=GetXmlHttpObject();
	if(ajaxObj==null){
		alert('Error: Your browser doesn\'t support ajax');
		return false;
	}
	var callFile=getFileToBeCalled+'?divID='+getDivID+extraPeram;
	ajaxObj.onreadystatechange=stateChanged;
	ajaxObj.open('GET', callFile, true);
	ajaxObj.send(null);
}

/*********************************************/
//Close the previous div and open clickedone
/*********************************************/
function FUNC_closePreviousDivOpenClickOne(getDivID, getFileToBeCalled, totalDivGenerated, getDivNames, extraPeram){
	
	//Closing prvious generated div (If any) expect currently clicked div
	var i=0;
	for(i=1; i<=totalDivGenerated; i++){
		
		//Generating name of div by concatination
		var divFinalName=getDivNames+i;
		
		if(!(divFinalName==getDivID)){
			document.getElementById(divFinalName).innerHTML='';
		}
	}
	
	divID=getDivID;//Assigning The Div ID To Globle Variable
	ajaxObj=GetXmlHttpObject();
	if(ajaxObj==null){
		alert('Error: Your browser doesn\'t support ajax');
		return false;
	}
	var callFile=getFileToBeCalled+'?divID='+getDivID+extraPeram;
	ajaxObj.onreadystatechange=stateChanged;
	ajaxObj.open('GET', callFile, true);
	ajaxObj.send(null);
}


function stateChanged(){
	if(ajaxObj.readyState==4){
		document.getElementById(divID).innerHTML=ajaxObj.responseText;	
	}else{
		document.getElementById(divID).innerHTML='<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center"><tr><td align="center"><img src="images/icons/loading.gif" border="0" alt="loading..."></td></tr></table>';	
	}
}

function FUNC_getCommentList(getDivID, getFileToBeCalled){

	divID=getDivID;//Assigning The Div ID To Globle Variable
	ajaxObj=GetXmlHttpObject();
	if(ajaxObj==null){
		alert('Error: Your browser doesn\'t support ajax');
		return false;
	}
	var callFile=getFileToBeCalled+'?divID='+getDivID;
	ajaxObj.onreadystatechange=stateChanged10;
	ajaxObj.open('GET', callFile, true);
	ajaxObj.send(null);
}


function stateChanged10(){
	if(ajaxObj.readyState==4){
		document.getElementById(divID).innerHTML=ajaxObj.responseText;	
	}else{
		document.getElementById(divID).innerHTML='<img src="images/icons/loading.gif" border="0" alt="loading...">';	
	}
}




function GetXmlHttpObject(){
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}
	if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}


/**************************************************************/
//To Select And Unselect All Check Boxes
/**************************************************************/
function FUNC_checkSelectBox(checkBoxMain ,checkBoxPreFix, totalCheckBoxesHolder){
	var checkBoxFlag=document.getElementById(checkBoxMain).checked; //Checkbox Flag Active or Inactive (0 or 1)
	var totalCheckBoxesCounter=document.getElementById(totalCheckBoxesHolder).value; //Fetch Total Checkboxes Counter From Hidden Field
	
	//To Activate The Checkboxes
	if(checkBoxFlag == true){
		for(i=1; i<=totalCheckBoxesCounter; i++)
		{
			var org=checkBoxPreFix+i;
			document.getElementById(org).checked = true;
			flagCheckBox=1;
		}
	}

	//To InActivate The Checkboxes
	if(!(checkBoxFlag == true)){
		for(i=1; i<=totalCheckBoxesCounter; i++)
		{
			var org=checkBoxPreFix+i;
			document.getElementById(org).checked = false;
			flagCheckBox=0;
		}
	}
}

/********************************************************************/
//To validate that user can't enter the string value in num section
/********************************************************************/
function FUNC_numValidation(getDivId, forWhat, exampleIs){
	
	//Get the value in input field
	var valueIs=document.getElementById(getDivId).value;
	
	//Now start validating the input value
	if(isNaN(valueIs)==true){
		alert('Please enter the '+forWhat+' in numeric value like. '+exampleIs);
		document.getElementById(getDivId).value='';
		return false;
	}	
	
	//Validate only in the case of price to avoid the , and .
	if(forWhat=='price'){
		if(!(valueIs.indexOf(',')==-1) || !(valueIs.indexOf('.')==-1)){
			alert('Please enter the '+forWhat+' in numeric value without using (,) and (.) like. '+exampleIs);
			document.getElementById(getDivId).value='';
			return false;
		}
	}
}
