// 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;
                                }
			}
                }
        }
}
// ajax.js -- end --
// lightbox.js -- start --
var documentwidth=document.width;
var documentheight=document.height;
var getheight=0;
var layerid1='';
var closeid1='';
function modalwin(width1,height1,layerid,msg,showsavebutton)
{	
	var modal1=document.getElementById('modal1');
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	var dsocleft=document.all? iebody.scrollLeft : pageXOffset
	var dsoctop=document.all? iebody.scrollTop : pageYOffset
	modal1.style.width='100%';
	findPos();
	newheight=alertSize();
	modal1.style.height=getheight+'px';
	modal1.style.background='#000';
	document.getElementById(layerid).style.width=width1+'px';
	document.getElementById(layerid).style.height=height1+'px';
	document.getElementById("framelayer").style.width='100%';
	document.getElementById("framelayer").style.height=getheight+'px';
	document.getElementById("lFrame1").style.width='100%';
	document.getElementById("lFrame1").style.height=getheight+'px';
	if(showsavebutton == 1)
	{
		document.getElementById("linkSaveJobs").style.display='block';
	}
	document.getElementById("idLayerMsg").innerHTML=msg;
	var clientheight=getheight;
	var clientwidth=document.body.clientWidth;
	var layershowobj=document.getElementById(layerid);
	clientwidth1=(clientwidth/2)-(width1/2);
	clientheight1= dsoctop+(newheight/2)-(height1/2);
	layershowobj.style.left=clientwidth1+'px';
	layershowobj.style.top=clientheight1+'px';
	closewidthpos=parseInt(clientwidth1, 10)+parseInt(width1, 10)-60;
	document.getElementById('modal1').style.display='block';
	document.getElementById(layerid).style.display='block';
	document.getElementById("framelayer").style.display='block';
	layerid1=layerid;
}

function hidemodal()
{
	document.getElementById('modal1').style.display='none';
	document.getElementById(layerid1).style.display='none';
	document.getElementById("framelayer").style.display='none';
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function findPos() {
	obj=document.getElementById('lastdiv');
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
getheight=curtop;
}
// lightbox.js -- end --
// 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');
								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 { adjust(); } 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('divHeader'))
	{
		setTimeout('showHeader()',10);
		return -1;
	}
	// HEADER --- START
//alert(strHeader);
	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('divHeader').innerHTML=strHeader;
	delete(strHeader);
	// HEADER --- END
}

function showPanel()
{
	if(flagPanel) return 0; else flagPanel=1;
        if(!document.getElementById('divPanel'))
        {
                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);  
	//*! 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('divPanel').innerHTML=strPanel;
	delete(strPanel);
	// PANEL --- END
}

function showBand()
{
	if(flagBand) return 0; else flagBand=1;
        if(!document.getElementById('divBand'))
        {
                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);
	document.getElementById('divBand').innerHTML=strBand;
	delete(strBand);	
	eval(strJSBandAfter);
	// BAND --- END
}

function showFooter()
{
	if(flagFooter) return 0; else flagFooter=1;
        if(!document.getElementById('divFooter'))
        {
                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('divFooter').innerHTML=strFooter;
	delete(strFooter);
	eval(strJSFooterAfter);
	// FOOTER --- END
}
