function DeleteModule()
{
	return confirm('Are you sure you want to delete this Module? This action can not be reversed.');
}
function OpenAddModuleWindow(pageid, placeholder)
{
    if(pageid.valueOf() > 0 && placeholder.valueOf() > 0 )
	{
		// added the random number as one more query string to render page every time from server.
	    var randomnumber=Math.floor(Math.random()*1111)
		var url = '/NewAdmin/Pages/AddEditModule.aspx?pgid=' + pageid  + '&phid=' + placeholder + '&ran=' + randomnumber;
		var result = window.showModalDialog(url,'AddEditModule','dialogWidth:430px;dialogHeight:230px;dialogTop:300px;dialogLeft:300px');
		if(result == true)
	       window.document.forms(0).submit();
       //if (result == false)
        //    alert ('The Featured Content Module has been already added in this Page');
		return false;
	}
}
function OpenResourseEditModuleWindow(textResourseId, modid, isGlobal) {
    // added the random number as one more query string to render page every time from server.
    var randomnumber = Math.floor(Math.random() * 1111)
    var url = '/NewAdmin/Pages/TextResourcesEdit.aspx?trid=' + textResourseId + '&modid=' + modid + '&ran=' + randomnumber + '&isGlobal=' + isGlobal;

    var result = window.showModalDialog(url, 'ResourceTextEdit', 'dialogWidth:900px;dialogHeight:600px;dialogTop:50px;dialogLeft:50px');
    if (result == true)
        window.document.forms(0).submit();
    return false;
}
function OpenEditModuleWindow(pageid, placeholder, modtype, modid)
{
	if(pageid.valueOf() > 0 && placeholder.valueOf() > 0 && modtype.toString().length > 0 && modid.valueOf() > 0)
	{
	    // added the random number as one more query string to render page every time from server.
	    var randomnumber=Math.floor(Math.random()*1111)
		var url = '/NewAdmin/Pages/AddEditModule.aspx?pgid=' + pageid  + '&modid=' + modid + '&modtype=' + modtype + '&phid=' + placeholder + '&ran=' + randomnumber;
		if(modtype.toString().toUpperCase() == 'HTML')
		{
		    var result = window.showModalDialog(url,'AddEditModule','dialogWidth:710px;dialogHeight:580px;dialogTop:50px;dialogLeft:150px');
        }
        if(modtype.toString().toUpperCase() == 'FEATURCOLL')
		{
		    var result = window.showModalDialog(url,'AddEditModule','dialogWidth:600px;dialogHeight:400px;dialogTop:100px;dialogLeft:200px');
        }
        if(modtype.toString().toUpperCase() == 'ATOMRSSFEED')
		{        
		    var result = window.showModalDialog(url,'AddEditModule','dialogWidth:450px;dialogHeight:400px;dialogTop:100px;dialogLeft:200px');
        }
        if(modtype.toString().toUpperCase() == 'PREFSELECTOR')
		{        
		    var result = window.showModalDialog(url,'AddEditModule','dialogWidth:660px;dialogHeight:530px;dialogTop:75px;dialogLeft:150px');
        }
		if(result == true)
	       window.document.forms(0).submit();
		return false;
	}
}

function CloseWindow()
{	
    window.returnValue = false;
	window.close();
}

function ResizeOpenEditModuleWindow(isShowColl)
{	
    var dropdownIndex = document.getElementById('userModuleTypeSelection_drpModuleTypes').selectedIndex;
    var dropdownValue = document.getElementById('userModuleTypeSelection_drpModuleTypes')[dropdownIndex].value;
    if(dropdownValue.toString().toLowerCase() == 'rssfeed')
    {    
        if(navigator.appName.toUpperCase() == 'NETSCAPE')
        {
            window.resizeTo(480,420);
            window.moveTo(200,100);
        }
        else
        {
            window.dialogHeight =   '400px';
            window.dialogWidth  =   '450px';
            window.dialogTop    =   '100px';
            window.dialogLeft   =   '200px';         
        }
    }
    else if (dropdownValue.toString().toLowerCase() == 'userrating')
    {
        if (isShowColl==1)
        {
            windowResize();
        }
        else
        {
            if(navigator.appName.toUpperCase() == 'NETSCAPE')
            {
                window.resizeTo(480,420);
                window.moveTo(200,100);
            }
            else
            {
                window.dialogHeight =   '200px';
                window.dialogWidth  =   '600px';
                window.dialogTop    =   '100px';
                window.dialogLeft   =   '200px';         
            }
        }
    }
    else if (dropdownValue.toString().toLowerCase() == 'usercomments')
    {
        if (isShowColl==1)
        {
            windowResize();
        }
        else
        {
            if(navigator.appName.toUpperCase() == 'NETSCAPE')
            {
                window.resizeTo(480,420);
                window.moveTo(200,100);
            }
            else
            {
                window.dialogHeight =   '200px';
                window.dialogWidth  =   '600px';
                window.dialogTop    =   '100px';
                window.dialogLeft   =   '200px';         
            }
        }
    }
    else if (dropdownValue.toString().toLowerCase() == 'featuredcollateral')
    {
         if(navigator.appName.toUpperCase() == 'NETSCAPE')
        {
            window.resizeTo(480,420);
            window.moveTo(200,100);
        }
        else
        {
            window.dialogHeight =   '400px';
            window.dialogWidth  =   '600px';
            window.dialogTop    =   '100px';
            window.dialogLeft   =   '200px';         
        }
    }
    else
    {    
        windowResize();
    }

    return true;
}
function windowResize()
{
        if(navigator.appName.toUpperCase() == 'NETSCAPE')
        {
            window.resizeTo(730,620);
            window.moveTo(150,0);
        }
        else
        {
            window.dialogHeight =   '580px';
            window.dialogWidth  =   '710px';
            window.dialogTop    =   '50px';
            window.dialogLeft   =   '150px'; 
        }
}
function RefreshPage()
{
    window.document.forms(0).submit();
}
function SaveAndContinue()
{	
    if(document.getElementById('userPageAreaUpdate_h_PageAreaUpdateSaveAndContinue'))
    {
        document.getElementById('userPageAreaUpdate_h_PageAreaUpdateSaveAndContinue').value = '1';
    }
    return true;
}
function CloseSaveAndContinue()
{	
    var saveAndContinue = document.getElementById('userPageAreaUpdate_h_PageAreaUpdateSaveAndContinue');
    if(saveAndContinue)
    {
        if(saveAndContinue.value == '1')
        {
            return true;
        }
    }
    window.returnValue = false;
	window.close();
	return false;
}
//Added for F_731
function OpenUserRatingSelectionWindow(pageID,omnibusID)
{
	var url = '/Main/pages/AddRatingsSelection.aspx?pgid='+ pageID + '&oid=' + omnibusID;
	var result = window.showModalDialog(url,'OpenUserRatingModule','dialogWidth:630px;dialogHeight:330px;dialogTop:400px;dialogLeft:300px');
	if ( result == true )
	    window.document.forms[0].submit();
    //return false;	    
}
//Added for F_870
function OpenPreviewPrefSelectorWindow()
{
    var randomnumber=Math.floor(Math.random()*1111)
	var url = '/NewAdmin/Pages/ShowPreviewPrefSelector.aspx?rnd='+ randomnumber;
	var result = window.showModalDialog(url,'Preview Site Section Selector','dialogWidth:430px;dialogHeight:340px;dialogTop:75px;dialogLeft:150px');
    return false;	    
}
function IsUserRatingSelected()
{
    var myOption = 0;
    for (i=0; i < 5 ; i++) 
    {
        var radioButton = document.getElementById('UserRatingsSelection1_rbRating_'+i)
        if ( radioButton )
        {
            if (radioButton.checked) 
            {
                myOption = 1; 
                break;
            }
        }
    }
    if (myOption == 0) 
    {
        alert('You must select a rating before clicking the \"Submit Rating\" button');
        return false;
    }
}
function IsSelectAllCollTypes()
{
    var chkBoxSelectAll= document.getElementById('userModuleUserRatingPage_chkBoxSelectAll');
    if (chkBoxSelectAll != null)
    {
        var i =0;
        var flag = true; 
        var chkBoxListColl = 'userModuleUserRatingPage_chkBoxListCollaterals';
        if (chkBoxSelectAll.checked)
        {
            while (flag)
            { 
                var id = chkBoxListColl + "_" + i; 
                var childElem= document.getElementById(id);
                if (childElem != null)
                    childElem.checked = true;
                else
                    flag = false;
                i++;
            }
        }
        else
        {
            while (flag)
            { 
                var id = chkBoxListColl + "_" + i; 
                var childElem= document.getElementById(id);
                if (childElem != null)
                    childElem.checked = false;
                else
                    flag = false;
                i++;
            }
        }
    }
}
function selectSwitch(listId, currentid) 
{ 
    for (index = 0; index < document.forms[0].length; index++) 
    { 
        if (document.forms[0].elements[index].type=='checkbox') 
        { 
            var currentCheckBox = document.forms[0].elements[index]; 

            if (currentCheckBox != null) 
            { 
                var currentCheckBoxId = currentCheckBox.id;
               
                if(currentCheckBoxId.lastIndexOf('_0') > 1)
                {
                    var isChecked = currentCheckBox.checked;
                }
                var lastUnderscoreIndex = currentCheckBoxId.lastIndexOf ('_'); 

                var currentCheckBoxIdBaseId = currentCheckBoxId.substring (0, lastUnderscoreIndex); 

                if (currentCheckBoxIdBaseId.lastIndexOf(listId) > 1) 
                { 
                    if(currentid.lastIndexOf('_0') > 1)
                    {
                        currentCheckBox.checked = isChecked; 
                    }
                    else
                    {
                        if(currentCheckBoxId.lastIndexOf('_0') > 1)
                        {
                            if(currentCheckBox.checked)
                            {
                                currentCheckBox.checked = false;
                            }
                        }
                     }
                } 
          }
     }
   }
}
//end
