// ajax.js -- start --
var dyn12;
var flagFooter=flagHeader=flagPanel=flagBand=0;
function makeRequestPlugin(url,divname,flag) {
	var randomnumber=Math.floor(Math.random()*1000);
        url=url+"&rnum="+randomnumber;
        var http_request = false;
        if (window.XMLHttpRequest) { // For Mozilla and other browsers
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                }
            }
            else if (window.ActiveXObject) { // For Internet Explorer
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                        http_request = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { displayContents11(http_request,divname,flag); };
        http_request.open('GET', url, true);
        http_request.send(null);

}

/*      Function Name : displayContents()
*       Description : 
*       This function returns the innerHTML for the parsed and formatted View Similar Jobs
*/
function displayContents11(http_request,info,flag) {
        if (http_request.readyState == 4) {
                if (http_request.status == 200) {
			if((http_request.responseText).length) 
			{ 
                                if(flag==2 && fetchJobDetails)
                                {
                                        if(http_request.responseXML.documentElement)
                                                fetchJobDetails(info,http_request.responseXML.documentElement);
                                }
                                else if(flag==3 && markJobAsApplied)
                                {
                                        if(http_request.responseText)
                                                markJobAsApplied(info,http_request.responseText);
                                }
                                else if(flag==4 && markJobAsSaved)
                                {
                                        if(http_request.responseText)
                                                markJobAsSaved(info,http_request.responseText);
                                }
                                else if(flag==5 && showApplyPattern)
                                {
                                        if(http_request.responseText)
                                                showApplyPattern(info,http_request.responseText);
                                }
				 else if(flag==6)
					displayMsngrResults(info,http_request.responseText); 
                                else
                                {
                                        if(http_request.responseText.length)
					{
                                                document.getElementById(info).innerHTML=http_request.responseText;
						if(flag == 7)
						{
							setTimeout('showUpdateWidget()',1000);
					                return -1;
						}
					}
                                }
			}
                }
        }
}
function showUpdateWidget()
{
      gbi('colR').innerHTML=gbi('recruit').innerHTML;
}
// googleadsx.js -- start --
function makeRequest(url, loc_id, params) {
	var http_request = false;
    	if (window.XMLHttpRequest) { // For Mozilla and other browsers
        	http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        	}
        } 
    	else if (window.ActiveXObject) { // For Internet Explorer
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            	http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } 
	catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    var randomnumber=Math.floor(Math.random()*1000);
	if(loc_id == 1) {
		url=url+"&rnum="+randomnumber;
	}
	else if(loc_id == 2) {
		querystr = getQueryString(params, true);
		//encode query string
		var tmp_querystr_arr = querystr.split('&');
		var newquerystr_arr = new Array();
		var idxcntr = 0;
		for(key in tmp_querystr_arr) {
			if(idxcntr > 0) {
				tmparr = tmp_querystr_arr[key].split('=');
				newquerystr_arr[idxcntr] = tmparr[0]+'='+encodeURIComponent(tmparr[1]);
			}
			else {
				newquerystr_arr[idxcntr] = tmp_querystr_arr[key];
			}
			idxcntr++;
		}
		 querystr = newquerystr_arr.join('&');
		url = url+"?rnum="+randomnumber+querystr;
	}
        http_request.onreadystatechange = function() { displayContents(http_request,loc_id); };
        http_request.open('GET', url, true);
        http_request.send(null);
}

function getQueryString(params, isjs) {
	try {
		querystr = '';
		isjs = (isjs == undefined || isjs == false)?false:true;
		if(isjs) {
			param_arr = params.split(",");
			for(cntr=0;cntr<param_arr.length;cntr++) {
				querystr += eval(param_arr[cntr]);			
			}
		}
		else {
			// to fetch elements by Id
		}
		return querystr;
	}catch(e){}
}
/*	Function Name : displayContents()
*  	Description : 
*	This function returns the innerHTML for the parsed and formatted google ads
*/
function displayContents(http_request,loc_id) {
	// Loc_id : (1) Google, (2) Widgets
	if (http_request.readyState == 4) {
		
        	if (http_request.status == 200) {
	            var doc = http_request.responseText;
				if(loc_id == 1) {
				var arrayContent=doc.split("|XX|XX|");
				if(document.getElementById("GOOGLEADS_BOT"))
					document.getElementById("GOOGLEADS_BOT").innerHTML=arrayContent[1];
				if(document.getElementById("GOOGLEADS_RT"))
					document.getElementById("GOOGLEADS_RT").innerHTML=arrayContent[0];
				if(document.getElementById("GOOGLEADS_RT1"))
					document.getElementById("GOOGLEADS_RT1").innerHTML=arrayContent[2];
				if(document.getElementById("GOOGLEADS_CENTER"))
					document.getElementById("GOOGLEADS_CENTER").innerHTML=arrayContent[3];
				}
				else if(loc_id == 2) {
					var arrayContent = doc.split("|xXx|");
						if(arrayContent[2] != '') {
							widgetscommon = false;
							eval(arrayContent[2]);
						}
						var content = arrayContent[1];
						var arrData = content.split("|:sep1|");
						for(cntr=0;cntr<arrData.length;cntr++) {
							arrContent = arrData[cntr].split('|:sep2|');
							if(document.getElementById(arrContent[0])) {
								objOldDiv = document.getElementById(arrContent[0]);
								objNewDiv = document.createElement('div');
								if(arrContent[1])
								{
								arrSepContent = arrContent[1].split("|:sepscript|");
								objNewDiv.innerHTML = arrSepContent[0];
//								Hack for browsers as data in innerHTML doesn't get executed.
								objNewDiv.id = objOldDiv.id;
									
								objNewDiv.className = objOldDiv.className;
								objOldDiv.parentNode.replaceChild(objNewDiv, objOldDiv);
//								Hack to center align the widget block			
								if(objNewDiv.id == "widget2"){
									var objWid=document.getElementById('widget2');
									objWid.style.margin='0 auto';
									objWid.style.width='368px';
									objWid.style.height='346px';
									objWid.style.overflow='hidden';
								}
							
								if(arrSepContent[1] != '') {
									dynInterval = 'timer'+cntr;
									dynScript = 'data'+cntr;
									eval(dynScript+"=arrSepContent[1]");
//									Hack to wait for execution till .js is loaded.
									eval(dynInterval +" = setInterval(\"if(widgetscommon == true){clearInterval("+dynInterval+");eval("+dynScript+");}\",500);");
								}
								}
							}
						}
				}
                                try { adjustFoot(); } catch(e) {}
			} 
			else {
//                alert('There was a problem with the request.');
        	}
        }
}
// googleadsx.js -- end --
function showHeader()
{
	if(flagHeader) return 0; else flagHeader=1;
	if(!document.getElementById('header'))
	{
		setTimeout('showHeader()',10);
		return -1;
	}
	// HEADER --- START
	strHeader = strHeader.replace(/###__MYNAUK_URL__###/g,mynaukurl);
        strHeader = strHeader.replace(/###__RECOMMEND_URL__###/g,recommends);
	strHeader = strHeader.replace(/###__MYNAUK_URL1__###/g,mynaukLoginUrl);
	strHeader = strHeader.replace(/###__REPORT_PROBLEM__###/g,reportProblem);
	strHeader = strHeader.replace(/###__IMGURL__###/g,imgurl);
	strHeader = strHeader.replace(/###__zonedisp__###/g,document.getElementById('zonestr').innerHTML);
	strHeader = strHeader.replace(/###__SHOW_REPORTAPROBLEM__###/g,document.getElementById('SHOW_REPORTAPROBLEM').innerHTML);
        strHeader = strHeader.replace(/###__USERNAME__###/g,username);
        strHeader = strHeader.replace(/###__ID__###/g,id);
	document.getElementById('header').innerHTML=strHeader;
	delete(strHeader);
	// HEADER --- END
}

function showPanel()
{
	if(flagPanel) return 0; else flagPanel=1;
        if(!document.getElementById('navBG'))
        {
                setTimeout('showPanel()',10);
                return -1;
        }
	// PANEL --- START
	strPanel = strPanel.replace(/###__SEARCHPATH__###/g,m_u);
	strPanel = strPanel.replace(/###__SEARCHFILENAME__###/g,sr_f);
	strPanel = strPanel.replace(/###__LINK__###/g,link);
	strPanel = strPanel.replace(/###__MYNAUK_URL__###/g,mynaukurl);
	strPanel = strPanel.replace(/###__CAREER_SERVICES__###/g,careersrv);
	strPanel = strPanel.replace(/###__ID__###/g,id);  
	strPanel = strPanel.replace(/###__applyHistoryUrl__###/g,applyHistoryUrl); 
        strPanel = strPanel.replace(/###__QP__###/g,val_qp);
        strPanel = strPanel.replace(/###__QL__###/g,val_ql);


	//*! GNB START
	var idm = id.replace(/&/g,'?');
	strPanel = strPanel.replace(/###__IDM__###/g,idm);
	strPanel = strPanel.replace(/###__MOBILE_HOME_URL__###/g,mobileHomeURL);
	strPanel = strPanel.replace(/###__NAUKRI_HOME_URL__###/g,naukriHomeURL);
	strPanel = strPanel.replace(/###__RESPONSE_BOOSTER__###/g,responseBooster);
	strPanel = strPanel.replace(/###__RESUME_SERVICE__###/g,resBillingPath);
	strPanel = strPanel.replace(/###__PAYCHECK_URL__###/g,paycheckUrl);
	strPanel = strPanel.replace(/###__POSTRESUME__###/g,postResumeLinks);

	//*! GNB END
	strPanel = strPanel.replace(/###__BLOG_URL__###/g,blog_url);
	document.getElementById('navBG').innerHTML=strPanel;
	delete(strPanel);

	// PANEL --- END
}

function showBand()
{
	if(flagBand) return 0; else flagBand=1;
        if(!document.getElementById('srcBg100'))
        {
                setTimeout('showBand()',10);
                return -1;
        }
	// BAND --- START
	//eval(strJSBandBefore);
	strBand = strBand.replace(/###__SEARCHFILENAME__###/g,sr_f);
	strBand = strBand.replace(/###__LINK__###/g,link);
	strBand = strBand.replace(/###__HIDDEN_VARS__###/g,HIDDENVARS);
	strBand = strBand.replace(/###__SEARCH_CRITERIA__###/g,SEARCH_CRITERIA);
	strBand = strBand.replace(/###__IMGURL__###/g,imgurl);
	strBand = strBand.replace(/###__BLOG_URL__###/g,blog_url);
	strBand = strBand.replace(/###__QP__###/g,val_qp);
	strBand = strBand.replace(/###__QL__###/g,val_ql);
	if(jobsCnt <= 0)
		str_savedjobs = "";
       	strBand = strBand.replace(/###__SAVEDJOBS__###/g,str_savedjobs);
	strBand = strBand.replace(/###__SEARCHPATH__###/g,m_u);
        strBand = strBand.replace(/###__ID__###/g,id);
        strBand = strBand.replace(/###__NAUKRIHOME__###/g,naukrihome);
        strBand = strBand.replace(/###__NAUKRIHOMEPLUS__###/g,naukrihomeplus);

	document.getElementById('srcBg100').innerHTML=strBand;
	delete(strBand);	
	eval(strJSBandAfter);
	// BAND --- END
}

function showFooter()
{
	if(flagFooter) return 0; else flagFooter=1;
        if(!document.getElementById('footN'))
        {
                setTimeout('showFooter()',10);
                return -1;
        }
	// FOOTER --- START
	strFooter = strFooter.replace(/###__SEARCHPATH__###/g,m_u);
	strFooter = strFooter.replace(/###__REPORT_PROBLEM__###/g,reportProblem);
	strFooter = strFooter.replace(/###__ID__###/g,id);
	document.getElementById('footN').innerHTML=strFooter;
	delete(strFooter);
	eval(strJSFooterAfter);
	// FOOTER --- END
}
function ChangeURL(obj)
{
	defaultText1('s');
	defaultText('band','s');
        if(document.quickbar)
        {
                var plus_url;
                var qp=document.getElementById('qp').value;
                var ql=document.getElementById('ql').value;
                qp=qp.replace(/&/g,"%26");
                ql=ql.replace(/&/g,"%26");
                plus_url=obj.href+"&qp="+qp+"&ql="+ql+"&qe="+document.getElementById('expSL').value+"&qf[]="+document.getElementById('fareaSL').value+"&qm="+document.getElementById('minSal').value+"&qx="+document.getElementById('maxSal').value;
                plus_url=plus_url.replace(/#/g,"%23");
                plus_url=plus_url.replace(/\+/g,"%2B");
                obj.href=plus_url;
                delete(plus_url);
        }
}

