document.write("<script type='text/javascript' src='scripts/misc.js'></"+"script>");


var strRollColor = '#E68326';

var strRowOneColor = '#EB9F5A';

var useHighlighting = true;

var strRowTwoColor = '#EEAE75';

var strToggleColor = '#E68326';




function selectedCheckbox(element)
{
	var ctlForm = element.form;
	var ctlTR = null;
	var flag=0;
	var jobIds="";
	for (var i = 0; i < ctlForm.elements.length; i++)
	{
	  var ctl = ctlForm.elements[i];
	  if (ctl.id.indexOf("check") == 0 )
	  {
	  	if(ctl.checked==true)
		{
			flag=1;
			jobIds=jobIds+ctl.value+",";
		}
	  }
	}
	if(flag==0)
	{
		alert("Please select job")
		return false;
	}else{
	var url = "applyForJob.php?jobIds="+jobIds;
	var width=900;
	var height=600;
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',resizable=1,menubar=0,toolbar=0,status=0,scrollbars=1'
	newwindow=window.open(url,'Application',winprops);
	if (window.focus) {newwindow.focus()}
		return false;
	}
}


function showJobDetails(id)
{
	var url = "viewJob.php?jobIds="+id;
	var width=900;
	var height=600;
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',resizable=1,menubar=0,toolbar=0,status=0,scrollbars=1'
	newwindow=window.open(url,'Application',winprops);
	if (window.focus) {newwindow.focus()}
		return false;
	
}





function toggleCBs(ctlToggleAllCB) {

	var ctlForm = ctlToggleAllCB.form;

	var ctlTR = null;

	for (var i = 0; i < ctlForm.elements.length; i++)

	{

	  var ctl = ctlForm.elements[i];

	   if (ctl.id.indexOf("check") == 0 && ctl.checked != ctlToggleAllCB.checked) 

	   {

			ctl.checked = ctlToggleAllCB.checked;

			ctlTR = getTRFromCB(ctl);

			if (ctlTR)

				 changeAppearance(ctlTR, ctl.checked, 0, strToggleColor);

	    }

	}

}

function getTRFromCB(ctlCB) {

	var ctlTR = null;

	if (ctlCB.parentNode && ctlCB.parentNode.parentNode)

	 ctlTR = ctlCB.parentNode.parentNode;

	 else if (ctlCB.parentElement && ctlCB.parentElement.parentElement)

	  ctlTR = ctlCB.parentElement.parentElement;

	return ctlTR;

}



function rollTR(strID, nState) {

	var ctlCB = document.getElementById('check[' + strID+']');

	var ctlTR = document.getElementById('myRow' + strID);

	

	if ((!ctlCB || !ctlCB.checked) && ctlTR)

	 changeAppearance(ctlTR, false, nState, strRollColor);

}





function changeAppearance(ctlTR, bIsRowChecked, nState, strOnColor) {

	if (useHighlighting) {

		if (ctlTR && ctlTR.className == "firstrow")

		 ctlTR.style.backgroundColor = bIsRowChecked || (nState == 1) ? strOnColor : strRowOneColor;

		else if (ctlTR && ctlTR.className == "secrow")

		  ctlTR.style.backgroundColor = bIsRowChecked || (nState == 1) ? strOnColor : strRowTwoColor;

		

	}

}



function changeRowStyle(cntrl,id)

{

	if(document.getElementById(cntrl+"["+id+"]").checked==true)

	{

		if(document.getElementById("myRow"+id))

		{

			document.getElementById("myRow"+id).className='firstrowmovr';

		}

	}

	if(document.getElementById(cntrl+"["+id+"]").checked==false)

	{

		if(document.getElementById("myRow"+id))

		{

			if((id%2)==0)

				document.getElementById("myRow"+id).className='secrow';

			else

				document.getElementById("myRow"+id).className='firstrow';

		}

	}

}

function uploadImage(cntrl,id,dir,table,tableid)
{
	var url="uploadImage.php?cntrl="+cntrl+"&id="+id+"&dir="+encodeURIComponent(dir)+"&table="+encodeURIComponent(table)+"&tableid="+encodeURIComponent(tableid);
	var width=450;
	var height=200;
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',menubar=0,toolbar=0,scrollbars=0,status=0,resizable=0'
	newwindow=window.open(url,'name',winprops);
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}

function changefilename(str,cntrl)
{  
	opener.document.getElementById(cntrl).value = str;
}


function showImage(src)
{
	
	newwindow=window.open("popup.html?"+src, "ImageViewer", "resizable=1,HEIGHT=200,WIDTH=200");
	newwindow.document.title="Image Preview";
	if (window.focus) {newwindow.focus()}
		return false;
}

function editUploadedImage(cntrl,name,dir)
{
	var url="editImage.php?cntrl="+cntrl+"&name="+name+"&dir="+encodeURIComponent(dir);
	var width=450;
	var height=200;
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',menubar=0,toolbar=0,scrollbars=0,status=0,resizable=0'
	newwindow=window.open(url,'name',winprops);
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}

function changeImage(newImage,cntrl,imgurl)
{
	action="changeImage";
	var imgurl=imgurl+newImage;
	opener.document.getElementById("editedImage").innerHTML="<img src=\""+imgurl+"\" width=\"70\" height=\"70\"  border=\"0\">";
	opener.document.getElementById(cntrl).value = newImage;
}




