﻿var applpath="http://cg.skillbell.com/";


function ShowVideo(str)
    {
    if (str=="")
    {   
        document.getElementById("ShowReelId").innerHTML="Could not load search results.";
        return;
    }
    document.getElementById("ShowReelId").innerHTML="<span class='error_text'>Loading....</span>";
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url=applpath +"home/showreel/" + str;
    
    xmlHttp.onreadystatechange=ResultVideo;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }

function ResultVideo() 
{ 
    if (xmlHttp.readyState==4)
    { 
        document.getElementById("ShowReelId").innerHTML=xmlHttp.responseText;
    }
}

function loadPagingResults(str)
    {
   var JobCategory=null;
   var Skills=null;
   var Location=null;
   JobCategory=document.getElementById("JobCategory").value;
   Skills=document.getElementById("Skills").value;
   Location=document.getElementById("Location").value;    
    if (str=="")
    {   
        document.getElementById("GridResult").innerHTML="Could not load search results.";
        return;
    }
    //document.getElementById("GridResult").innerHTML="<span class='error_text'>Loading....</span>";
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var Variables="PageNumber="+str+"&JobCategory="+JobCategory+"&Skills="+Skills+"&Location="+ Location;
    
    var url=applpath +"home/pagingsearchresult/?" + Variables;
    
    xmlHttp.onreadystatechange=PagingResult;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }

function PagingResult() 
{ 
    if (xmlHttp.readyState==4)
    { 
        document.getElementById("GridResult").innerHTML=xmlHttp.responseText;
    }
}
 function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
      xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}




/* Apply Job End*/
/*Change Status in Admin*/
/* Need this variables for change status*/
var UJobEntryID;
var UJobStatus;
/* Need this variables for change status*/
function ChangeStatus(JobEntryId,PresentStatus)
{

UJobEntryID=JobEntryId;
UJobStatus=PresentStatus;
if(PresentStatus==1)
{
    if(!confirm("Are you sure you want to activate?"))
    {
    return false;
    }
}
else
{
   if(!confirm("Are you sure you want to deactivate?"))
    {
    return false;
    }
}
xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url=applpath+"Admin/ChangeStatus/?JobEntryID="+ JobEntryId + "&JobStatus=" +PresentStatus;
    xmlHttp.onreadystatechange=AppendResult;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);  
}

function AppendResult() 
{ 
    if (xmlHttp.readyState==4)
    { 
        if(xmlHttp.responseText == 1)
        { 
            if (UJobStatus== 1)
            {
            document.getElementById("Status_"+UJobEntryID).innerHTML="Active";
            document.getElementById("ChangeStatus_"+UJobEntryID).innerHTML="<a href='#' onclick='return ChangeStatus("+UJobEntryID+",0);'>DeActivate</a>";
            alert("Successfully activated the job.");
            }
            else
            {            
            document.getElementById("Status_"+UJobEntryID).innerHTML="In Active";
            document.getElementById("ChangeStatus_"+UJobEntryID).innerHTML="<a href='#' onclick='return ChangeStatus("+UJobEntryID+",1);'>Activate</a>";
            alert("Successfully deactivated the job.");
            }
            
        }
    }
}
function OpenTextBox()
{

document.getElementById("OpenTextBox").style.display="inline";
return;
}
function isValidEmail(str) 
{

  return (/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/i.test(str));
} 

function SendEmail()
{
    var SendEmailID =document.getElementById("EmailID").value;
    if(SendEmailID=="")
    {
    alert("Please enter E-mail ID");
    return false;
    }
    else if(!isValidEmail(SendEmailID))
    {
    alert("Please enter valid E-mail ID");
    return false;
    }

    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url=applpath+"home/sendmail/?EmailID="+ SendEmailID;
    
    xmlHttp.onreadystatechange=SendEmailResult;
    xmlHttp.open("GET",url,true);
    //alert(url);
    xmlHttp.send(null);  
}

function SendEmailResult() 
{ 

    if (xmlHttp.readyState==4)
    { 
        if(xmlHttp.responseText == "1")
        {         
            document.getElementById("EmailID").value="";
            document.getElementById("OpenTextBox").style.display="none";
            alert("We have sent this job details to the email you provided.");            
        }
    }
}


function DivPrinting()
{
 var printContent = document.getElementById("HtmlForm");
 var windowUrl = 'about:blank';
 var uniqueName = new Date();
 var windowName = 'Print' + uniqueName.getTime();
 var printWindow = window.open(windowUrl, windowName, 'left=100,top=50,width=750,height=400');

 printWindow.document.write("<img src='../images/logo-new.gif' /><br />&nbsp;<br />" + printContent.innerHTML);
 printWindow.document.close();
 printWindow.focus();
 printWindow.print();
 printWindow.close();
}

function LoadResult(PgNo)
{

   var JobCategory=null;
   var Skills=null;
   var Location=null;
   JobCategory=document.getElementById("JobCategory").value;
   Skills=document.getElementById("Skills").value;
   Location=document.getElementById("Location").value;       
    if (PgNo=="")
    {   
        document.getElementById("GridResult").innerHTML="Could not load search results.";
        return;
    }
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 

    var Variables="PageNumber="+PgNo+"&JobCategory="+JobCategory+"&Skills="+Skills+"&Location="+ Location;
    
    var url=applpath +"admin/jobsearchresult/?" + Variables;
    xmlHttp.onreadystatechange=AdminGridResult;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function AdminGridResult() 
{ 
    if (xmlHttp.readyState==4)
    {  
        document.getElementById("AdminGridResult").innerHTML=xmlHttp.responseText;
    }
}


function HideContent(d) 
{
document.getElementById(d).style.display = "none";
}

function ShowContent(d)
{
if(d.length < 1) 
{ 
return; 
}
var dd = document.getElementById(d);
//AssignPosition(dd);
dd.style.display = "block";
}



