﻿// JScript File

	function SelectPreferences(selid,lines)
	{
		var sel=document.getElementById(selid);
		var lines=document.getElementById(lines);

		for (var k=0;k<sel.options.length;k++)
		{
			sel.options[k].selected = false;
		}
		
		for (var x=0;x<lines.value;x++)
		{
			sel.options[x].selected = true;
		}
	}

	function trim(sString) {
		start = 0
   		end = sString.length-1 
      	while (sString.charAt(start) == " ") {
			start++
			}
      		while (sString.charAt(end) == " ") {
			end--
			}
   		if (start > end)
	   		return ''
    	else	
       		return sString.substring(start,end+1)
   	}

		function moveUp(control) 
		{
			if(!document.getElementById(control)) return false;

			with(document.getElementById(control)) 
			{
				if(selectedIndex>0) 
				{
					var temp=options[selectedIndex].text;
					options[selectedIndex].text=options[selectedIndex-1].text;
					options[selectedIndex-1].text=temp;
				
					var temp=options[selectedIndex].value;
					options[selectedIndex].value=options[selectedIndex-1].value;
					options[selectedIndex-1].value=temp;
				
					selectedIndex=selectedIndex-1;
				}
			}
		}
		
	    function moveDown(control) 
	    {
		    if(!document.getElementById(control)) return false;
		    with(document.getElementById(control)) 
		    {
		        if(selectedIndex != -1)
		        {
			        if(selectedIndex<length-1) 
			        {
				        var temp=options[selectedIndex].text;
				        options[selectedIndex].text=options[selectedIndex+1].text;
				        options[selectedIndex+1].text=temp;
        				
				        var temp=options[selectedIndex].value;
				        options[selectedIndex].value=options[selectedIndex+1].value;
				        options[selectedIndex+1].value=temp;
        				
				        selectedIndex=selectedIndex+1;
			        }
			    }
		    }
	    } 
	
	function PreviewApp()
	{
		document.form1.hdnPreviewApp.value=1;
		document.form1.btnPreview.disabled = true;
		document.form1.submit();
	}
	
	function DisableButton()
	{
		document.form1.cmdSubmit.value='Submitting...';
		document.form1.cmdSubmit.disabled = true;
	}
	
	function OpenPreviewWin()
	{
		window.open("ApplyPreview.aspx","ApplyPreview","top=10,left=60,width=600,height=500,scrollbars,resizable,menubar")
	}
	
	function ShowCVUpload()
	{
		if (get_radio_value(document.form1.rdoCV) == 'Profile' )
		{
			document.getElementById("rowAttCV").disabled = true;
		}
		else
		{
			document.getElementById("rowAttCV").style.display = '';
			document.getElementById("rowAttCV").disabled = false;
		}		
	}
	
	function get_radio_value(radiocontrol)
	{
		for (var i=0; i < radiocontrol.length; i++)
		{
			if (radiocontrol[i].checked)
			{
				var rad_val = radiocontrol[i].value;
				return rad_val;
			}
		}
	}   			


