﻿/******************************************************************************************************
Modofied By Usha Yeli for MP-17Oct2011-62617 Twitter, Linkedin, Facebook Links not functioning
Modofied By Usha Yeli for MP-03jan2012-65093 To change Linkedin path

********************************************************************************************************/
// JScript File

var __search_strURL;
var __search_active_tab="ALL"; // Default  value (for first time)
//var __search_action_ind;

function searchOnEnter(e)
{
    var keycode;
    if (window.event) 
        {
            keycode = window.event.keyCode;
        }    
    else if (e) 
        {
            keycode = e.which;
        }    
    else 
        return;
        
    if (keycode == 13)
       {
       mainSearch();
       //keycode=0;
       }
    else
       return;
}

function getSearchPaging(pageNo,strTabInd)
{
    __search_strURL="";
    var strVal=document.getElementById("txtPageSearch").value;
    var strCntry=document.getElementById("search_cboCntry").value;
    
    var strUrl="/WebPages/Search.aspx?QSearchTxt="+strVal+"&QSearchCntry="+strCntry+"&QCPage="+pageNo+"&QTabInd="+strTabInd;
    __search_strURL=strUrl;
    //__search_action_ind="PAGING";
    //showPageProgress();
    //createResultBlocks();
    //hideMainDiv();
    
    funLoadPage(strUrl,"SearchCont");
}


function mainSearch()
{
   document.title="MigrantPlanet : Search Results";
   clearHRZSelection();
   
   /** Put Hash in the URL **/
   location.hash="#search";   
  
   var strVal=document.getElementById("txtPageSearch").value; 
   //alert(strVal);
   __search_strURL="";
   __search_strURL="/WebPages/Search.aspx?QSearchTxt="+encodeURIComponent(escape(strVal))+"&QPBInd=N&QTabInd=ALL";
   if(strim(strVal)=="" || strim(strVal)=="Search")
   {
   }
   else
   { 
    //__search_action_ind="MAINSEARCH"
    showPageProgress();
    //hideMainDiv();
    createResultBlocks();
   } 
}

function searchWithCntry()
{
   var strVal=document.getElementById("txtPageSearch").value;
   var strCntry=document.getElementById("search_cboCntry").value;
   
    __search_strURL="";
   __search_strURL="/WebPages/Search.aspx?QSearchTxt="+escape(strVal)+"&QSearchCntry="+strCntry+"&QPBInd=N&QTabInd="+__search_active_tab;
   if(strim(strVal)=="" || strim(strVal)=="Search")
   {
   }
   else
   { 
    //__search_action_ind="MAINSEARCH"
    showPageProgress();
    createResultBlocks();
   } 
}
function clearHRZSelection()
{
    if(ObjSel)
    {
        ObjSel.style.backgroundImage="";
        arrElem=document.getElementsByTagName("a");
        for(var i=0;i<arrElem.length;i++)
        {
            if(arrElem[i].getAttribute('TI')=="HRZ")
            {
                if(arrElem[i].parentNode.parentNode==ObjSel)
                {
                    arrElem[i].style.color="Black";
                } 
            }       
        } 
        ObjSel=null; 
        }
}
/*function hideMainDiv()
{
   $("#ParentDiv").fadeOut("normal",createResultBlocks); 
}*/
function createResultBlocks()
{
    
    var strVal=document.getElementById("txtPageSearch").value;
     
    __gbl_search_ind=0;   

    var strUrl=__search_strURL+"&now=";
    GetAjaxData(strUrl+Math.floor(Math.random()*1000),showSearchResultBlock);  

    
}

function showSearchResultBlock(strData)
{
    //alert(strData);
    $("#tdContentPane").fadeIn("normal");  
    document.getElementById("tdContentPane").innerHTML=strData; 
    removeElement("load");     // In cmnJS.js      
}

function setSearchActiveTabAndCallAjax(strTabInd,strSearchText,strTargetDiv)
{
    __search_active_tab=strTabInd;
    var strCntry=document.getElementById("search_cboCntry").value;
    funLoadPage("/WebPages/Search.aspx?QTabInd="+strTabInd+"&QSearchTxt="+strSearchText+"&QSearchCntry="+strCntry,strTargetDiv)
    
}

function go2twitter()
{
 window.open("http://twitter.com/#!/MigrantPlanet","twitter")
}


function go2linkedin()
{
 window.open("http://www.linkedin.com/groups/MigrantPlanetcom-Group-2822770?trk=myg_ugrp_ovr")
}


function go2facebook()
{
  window.open("http://www.facebook.com/pages/MigrantPlanet-Global-Immigration-Portal/183982798279254","FaceBook")
}
