var switchclassCounter = 0;
var previousclass;
function radcheck(elemId)
{
	try
	{
		var elemObj = document.getElementById(elemId);
		var cellObj = elemObj.parentNode;
		var rowObj = cellObj.parentNode;
		var defaultClassName = "Normal";
		if(switchclassCounter != 0)
		{
			//Previously selected Item
			var pElemObj = document.getElementById(previousclass);
			var pCellObj = pElemObj.parentNode;
			var pRowObj = pCellObj.parentNode;
			pRowObj.className = defaultClassName;
		}
		else
		{
			previousSelectionU = elemId;
		}
		rowObj.className = "bold";
		previousclass = elemId;
		switchclassCounter = switchclassCounter +1;
	}
	catch(e)
	{
		alert(e.description);
	}
}

function CheckEditPossible(ddl,editId)
{
    var selectedVal= ddl.value;
    if(selectedVal <100000)
        editId.disabled= true;        
    else
       editId.disabled = false ; 
}
    
function CheckThemeSelected(themeDDL,editBtn)
{
    if(themeDDL.value < 100000)
    {
        editBtn.disabled = true;
        editBtn.className='button-mouseout' ;
        return false ;
    }
}

//CODE done by Usability IDC 
//This function is used for changing the row bg in BT_Myaccount_mysavedfiles.html
function Mover(id,imgId)
{
    id.className='ruled';
    imgId.className='show';
}
function Mout(id,imgId)
{
    id.className='ruler';
    imgId.className='hide';
}

function Mover1(id)
{
id.className='ruled';
}
function Mout1(id)
{
id.className='ruler';
}
function Mover2(id)
{
	id.className='ruled';
}
function Mout2(id)
{
	id.className='ruler';
}
function ReviewHighligt(id,chkboxStatus)
{
	var colObj = id.parentNode;
	var rowObj = colObj.parentNode;
	if(chkboxStatus == 'H')
	rowObj.className='bg-Bus-100100';
	else
	rowObj.className='bg-Bus-001111';
}
function ReviewNoHighligt(id)
{
    id.className='bg-Bus-100100';
}

//This Switchrad function is used in printoptions1.html , printoptions.html for disabling the byfile and preview in csspopup of add special pages.
function switchrad()
{
	if(document.getElementById("radio_preview").checked == true)
	{
	    document.getElementById("preveiw").disabled="";
	    document.getElementById("byfile").disabled="disabled";	
	}
	if(document.getElementById("radio_byfile").checked == true)
	{
		document.getElementById("byfile").disabled="";
		document.getElementById("preveiw").disabled="disabled";		
	}
}

//This Switchrad function is used in printoptions1.html , printoptions.html for disabling the byfile and preview in csspopup of add special pages.
function switchrad2(byFileId, byPageId, fileSelectionId, pageRangeId)
{
    if(document.getElementById(byFileId).checked == true)
    {
        document.getElementById(fileSelectionId).disabled = false;
        document.getElementById(pageRangeId).disabled = true;
    }
    
    if(document.getElementById(byPageId).checked == true)
    {
        document.getElementById(fileSelectionId).disabled = true;
        document.getElementById(pageRangeId).disabled = false;
    }
}

//This showhide function is used in printoptions1.html, prinoptions.html for hiding the properties like Binding & Covers and Finishing.
function showhide(id,status) 
{
	if(status == "hide")
	{
		document.getElementById(id).style.display='none';
	}	
	else if(status == "show")
	{
		document.getElementById(id).style.display='';	
	}
}


//This display funtion is used in printoptions1.html, printoption.html for media control.
var displayStatus = true;
function Display(whichLayer,id,id1)
{
	if (document.getElementById)
		{
	// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		var style1 = document.getElementById(id).style;
		var style3 = document.getElementById(id1).style;
		if(displayStatus)
		{
		    //alert("false");
			style1.display = 'none';
			style2.display = '';
			style3.display = '';			
			displayStatus = false;
		}
		else
		{
//			alert("true");
			//alert("WL " + whichLayer + "   Layer Id " + id );
			style1.display = '';
			style2.display = 'none';
			style3.display = 'none';
			displayStatus = true;
		}	
	}
}

//This tooltop function is used in BT_Xmpieproduct.html for hiding the batchimport div
function tooltip(id)
{
    //alert(document.getElementById(id));
    document.getElementById(id).style.display='none';
}

function isNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}

// allow only numbers and decimal
function isNumberOrDecimalKey(obj, evt)
{
    var liAsc = (evt.which) ? evt.which : event.keyCode;
    var value = obj.value;
    if(evt==null)
    {
        evt=window.event;
    }
    
    if (liAsc > 31 && (liAsc < 48 || liAsc > 57) && liAsc != 46)
        return false;
    else if (liAsc == 46)
    {
        evt.returnValue = (value.lastIndexOf('.') == -1);
        return (value.lastIndexOf('.') == -1);
    }

    return true;
}
      
function isAlphaNumeric(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && ( (charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) ) )
        return true;

    return false;
}

//function used to make sure only one radio button is selected, when radio button used within a DataList control.
//ASP.Net has an issue with radio button within DataList control, the GroupName property won't work and all buttons are selectable at once.
//This method unchecks all other radios and also sets the hidden field with the selected controls Id. 
//Caller can just do hiddenfield.selectedvalue to retrive the user selected radio, within the datalist.
function DataListSelectOneRadio(radioButton, datalistId, valueFieldId)
    {    
    /* Getting an array of all the "INPUT" controls on the DataGrid.*/  
     var dgGrid = document.getElementById(datalistId);
     var all= dgGrid.getElementsByTagName("input");
     for(i=0;i<all.length;i++)
     {
      if(all[i].type=="radio")/*Checking if it is a radio button*/
      {         
       if(all!= null)
       {
        all[i].checked=false; //un-check all the radios
       }
      }
     }
     radioButton.checked=true; //check the one user just clicked.
     
     //set the value of the checked radio to the hidden field.
     var hiddenVal = document.getElementById(valueFieldId);
     if(hiddenVal != null)
     {
        hiddenVal.value = radioButton.value;
     }
    }