
	document.title="Disney Media Distribution"	
	window.status = "DMD";

// JavaScript Document
function Highlight(Hobj)
	{
		try
		{
			var obj1=document.getElementById(Hobj);
			obj1.style.background="#07ADE9";
			obj1.style.color="#000000";
		}
		catch(e)
		{
			alert(Hobj +" Showing Error!");
		}
	}
function normal(Hobj)
	{
		try
		{ 
			var obj1=document.getElementById(Hobj);
			obj1.style.background="";
			obj1.style.color="";
		}
		catch(e)
		{
			alert(Hobj +" Showing Error!");
		}
	}
	
//Check Login status
function checkForm()
{
	if((document.login.userName.value=="")&&(document.login.password.value==""))
	{
		alert("Please enter the UserName and Password")
		document.login.userName.focus();
		return false;
	}
	else
	{
		if((document.login.userName.value=="client")&&(document.login.password.value=="client"))
		{
			document.login.action="../CLIENT/login/PPandTOS.htm"
		}
		else
		{
			if((document.login.userName.value=="admin")&&(document.login.password.value=="admin"))
			{
				document.login.action="../ADMIN/homePage/admin_homepg.htm"
			}
			else
			{
				alert("Please enter correct User Name/Password")
				document.login.userName.value=""
				document.login.password.value=""
				document.login.userName.focus();
				return false;
			}
		}
	}
}
function title()
{	
	document.title="Disney Media Distribution";
	window.status = "DMD";
}

function linkTo(urlName)
{
	location.replace(urlName);
}
function openWin(theURL,winName,features)
{
	tmpWindow = window.open(theURL,winName,features)
    if ( !window.tmpWindow && tmpWindow.closed )
    {
          tmpWindow;
    }
    else
    {
          tmpWindow.focus();
    }
}



function cancelOperation(paramName , paramValue)
{ window.location.href = '/WebModule/admin/title/assetDetails.jsp'; }
/* End Of Asset Related Scripts */


function getDate(date) 
{
		window.dateField = eval('document.forms[0].'+date);
		calendar = window.open('common/calendar.html','cal','WIDTH=250,HEIGHT=230,left=200,top=100');
}
function getDateID(date) 
{
						window.dateField = document.getElementById(date);
                        calendar = window.open('common/calendar.html','cal','WIDTH=250,HEIGHT=230,left=200,top=100');
                        if (window.focus)
                        {
                                    calendar.focus();
                        }

}


function addToAssetCart(assetId,assetCategoryId,res,dimDpi) {
   
	var getImgID 	= document.getElementById("addToCartImg"+assetId+res);
	var getTextID 	= document.getElementById("addToCartText"+assetId+res);
	var getItemID   = document.getElementById("items");
	var itemNumber  = parseInt(getItemID.innerHTML)+1;
	var getImgSrc 	= getImgID.src;
	var lastIndOfSlash = getImgSrc.lastIndexOf("/");
	var imgPath = getImgSrc.substr(0,(lastIndOfSlash+1)); 
	var imgName = getImgSrc.substr(lastIndOfSlash+1); 

	if (document.images) {
		if(imgName=="cart.gif"){
			document.images['img' + assetId + res + 'x'].src = 'addToAssetCart.do?AssetId=' + assetId +  '&AssetCategoryId=' + assetCategoryId + '&ImageResInd=' + res + '&par=' + Math.random();				
	     	getImgID.width="32";
	     	getImgID.height="32";
	     	getImgID.src= imgPath+"cart-added.gif";
	     	getTextID.className = 'addedToCart';
			 if(dimDpi != null){
			 dimDpi=dimDpi.replace('Q','\"');
    		dimDpi=dimDpi.replace('Q','\"');
			getTextID.innerHTML = "<b>Added " + dimDpi + " to cart</b>";
			 }else{
			 getTextID.innerHTML = "<b>Added to Asset cart</b>"; 
			 }
			 
			getItemID.innerHTML = itemNumber;
		} 
	}
}

     
function check_uncheck_all()       
{         
	var getEleCnt = document.assetCartForm.elements;
    if(document.assetCartForm.checkboxAll.checked == true)
    {
		for(i=0;i<getEleCnt.length;i++)
		{
			if(getEleCnt[i].type == "checkbox")
			{
				getEleCnt[i].checked = true;
			}  
		}
	}
    if(document.assetCartForm.checkboxAll.checked == false)  
    {
		for(i=0;i<getEleCnt.length;i++)
		{
			if(getEleCnt[i].type == "checkbox")
			{
				getEleCnt[i].checked = false;
			}
		}
	}
}

function toggleChkAll()
{
	var getEleCnt = document.assetCartForm.categoryList;
	var chkdCnt= 0;
	for(i=0; i<getEleCnt.length; i++)
	{
		if(getEleCnt[i].checked == true)
		{
			chkdCnt++ 
		}
	}
	if(chkdCnt == 9)
	{
		document.assetCartForm.checkboxAll.checked = true;
	}
	else
	{
		document.assetCartForm.checkboxAll.checked = false;
	}
}

function showHideAsset(assetCategoryId) {	
document.assetCartForm.action="viewAssetCart.do?AssetCategoryId=" + assetCategoryId;
document.assetCartForm.submit();
}

function removeAssetsFromCart(assetCategoryId){
	if(chkForSelected())
	{
		document.assetCartForm.action="removeFromAssetCart.do?AssetCategoryId=" + assetCategoryId + "&par=" + Math.random();				
		document.assetCartForm.submit();
	}
	else
	{
		return false;
	}
}

function placeOrder(assetCategoryId){
	if(chkForSelected())
	{
		document.assetCartForm.action="placeOrder.do?AssetCategoryId=" + assetCategoryId + "&par=" + Math.random();
		document.assetCartForm.submit();
	}
	else
	{
		return false;
	}
}

function downloadAssets(assetCategoryId){
	if(chkForSelected())
	{
		document.assetCartForm.action="viewAgree.do?AssetCategoryId="+ assetCategoryId +"&par=" + Math.random();		
		document.assetCartForm.submit();
	}
	else
	{
		return false;
	}
}
function addNewRow()
{
	var tbl = document.getElementById('seasontbl');
	var lastRow = tbl.rows.length;
	var iteration = lastRow
	
	if(iteration >= 15){
	
		document.getElementById("btnNew").disabled = true;
		
	}
	
	var seasonNewTxt = document.createElement('input');
	seasonNewTxt.type = 'hidden';
	seasonNewTxt.name = 'txtNewSeason' + iteration
	seasonNewTxt.id = 'txtNewSeason' + iteration
	//seasonNewTxt.value = iteration
	document.titleDetailsForm.count.value = iteration;
	if(iteration <= 15){	
	var row = tbl.insertRow(lastRow)
	
	
	//cell Number one
	var cellOne = row.insertCell(0)
	cellOne.className = 'leftPadding';
	var seasonTxt = document.createElement('input');
	seasonTxt.type = 'text';
	seasonTxt.className = 'txtField';
	seasonTxt.name = 'txtSeason' + iteration
	seasonTxt.id = 'txtSeason' + iteration
	seasonTxt.maxLength = '10';
	cellOne.appendChild(seasonTxt)
	
	//cell Number two
	var cellTwo = row.insertCell(1);
	cellTwo.align= 'center'
	var chkBtn= document.createElement('input');
	chkBtn.type = 'checkbox';
	chkBtn.name = 'status' + iteration
	chkBtn.id = 'status' + iteration
	cellTwo.appendChild(chkBtn);
	//start Asset modification-M1007875
	
	//cell Number Three-added for # of episodes
	var cellThree = row.insertCell(2)
	cellThree.align = 'center'
	var episodeTxt = document.createElement('input');
	episodeTxt.type = 'text';
	episodeTxt.className = 'txtField';
	episodeTxt.name = 'txtEpisode' + iteration
	episodeTxt.id = 'txtEpisode' + iteration
	episodeTxt.maxLength = '3';
	episodeTxt.width='30';
	episodeTxt.size = '1';
	cellThree.appendChild(episodeTxt)
	
	//cell Number four
	var cellFour = row.insertCell(3)
	cellFour.className = 'leftPadding'
	cellFour.innerHTML = '&nbsp;'
	cellFour.appendChild(seasonNewTxt);
	//cell Number five
	var cellFive = row.insertCell(4);
	cellFive.className = 'leftPadding';
	cellFive.innerHTML = '&nbsp;'
	//var txtupdtOn = document.createTextNode("06 Dec 2005 12:30PM PST");
	//cellFour.appendChild(txtupdtOn);
	//End Asset modification-M1007875	
	}
	
}

function addNewRow2(tblId)
{
	var tbl = document.getElementById(tblId);
	var lastRow = tbl.rows.length;
	var iteration = lastRow
	if(iteration == 15){
		document.getElementById("btnNew").disabled = true;
	}
	document.titleDetailsForm.count.value = iteration;
	var row = tbl.insertRow(lastRow)
	
	
	//Cell one
	var cellLeft = row.insertCell(0)
	cellLeft.className = 'leftPadding';
	var seasonTxt = document.createElement('input');
	seasonTxt.type = 'text';
	seasonTxt.className = 'txtField';
	seasonTxt.name = 'txtSeason' + iteration
	seasonTxt.id = 'txtSeason' + iteration
	seasonTxt.maxLength = '255';
	cellLeft.appendChild(seasonTxt)
	
	//Cell two
	var cellRight = row.insertCell(1);
	cellRight.align = 'center'
	var activeRadio = document.createElement('input');
	activeRadio.type = 'checkbox';
	activeRadio.name = 'status' + iteration
	cellRight.appendChild(activeRadio);
	
	//start:Asset Modification-M1007875
	
	//cell three added for number fo episodes
	var cellThree= row.insertCell(2);
	cellThree.align='center'
	var episodeTxt = document.createElement('input');
	episodeTxt.type = 'text';
	episodeTxt.className = 'txtField';
	episodeTxt.name = 'txtEpisode' + iteration
	episodeTxt.id = 'txtEpisode' + iteration
	episodeTxt.maxLength = '3';
	episodeTxt.width='30';
	episodeTxt.size = '1';
	cellThree.appendChild(episodeTxt)
	
	//cell four
	var cellFour = row.insertCell(3);
	cellFour.className = 'leftPadding';
	cellFour.innerHTML = '&nbsp;'
	
	//cell five
	var cellFive = row.insertCell(4);
	cellFive.className = 'leftPadding';
	cellFive.innerHTML = '&nbsp;'
	//End:Asset Modification-M1007875
}
function deleteAKA(selectID)
{
	
//	var selID = document.getElementById(selectID);
	var selID = eval('document.forms[0].'+selectID);
	for(i=0;i<selID.length;i++)
	{
		if(selID.options[i].selected)
		{
			selID.options[i] = null;
		}
	}

}

/***************************************************************************************************************

The below script is for adding an option to the select box from the textbox.
For titles.
Start of script id # 101
***************************************************************************************************************/

 function findOptionByValue($objSelect, $strValue) 
    { 
        // Straight pass-through 
        return findOption($objSelect, $strValue, 'value' ); 
     }
 function findOptionByText($objSelect, $strText) 
    { 
        // Straight pass-through 
        return findOption($objSelect, $strText, 'text' ); 
    }
 
 String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
  
 function addOption($objSelect, $strText, $strValue, $bolDefaultSelected, $bolSelected) 
    { 
        // Default value of found Item 
        $foundIndex = new Boolean ( false ); 
 
        // If $objSelect is a string, convert to Object Reference 
        // Then see if Object Reference exists 
        if ( ( typeof ( $objSelect ) ) == 'string' ) 
//            $objSelect = document.getElementById($objSelect); 
		 	$objSelect = eval('document.forms[0].'+$objSelect);

 
        // If we have nothing to deal with, just bale... 
        if ( ( ! $objSelect ) ||  ( ! $strText ) ) 
            return $foundIndex; 
         //Testing trim
         if('' == $strText.trim()){
         	alert("Please enter a valid AKA");
         	return $foundIndex;
         }
        // If a Value was not sent, set it from Text 
        if ( ( $strValue == '' ) || ( $strValue == null ) ) 
            $strValue = $strText.trim(); 
 
        // See if this exists or not 
        $foundTextIndex  = findOptionByText($objSelect, $strText.trim()) 
        $foundValueIndex = findOptionByValue($objSelect, $strValue.trim()) 
 
        // See if this new addition was found 
        // And if it was found in both Text AND Value 
        if ( ( typeof ( $foundTextIndex ) == 'number' ) && ( typeof( $foundValueIndex ) == 'number' ) ) 
        { 
            // If the Index for Text and Value are the same, great... 
            if ( $foundTextIndex == $foundValueIndex ) 
            { 
                // Keep index 
                $foundIndex = $foundValueIndex; 
            }   // if same 
 
            // Opps! indices don't match! Can't have that! 
            else 
            { 
                alert ( 'Sorry, but the "Text" and the "Value" for this item exists in seperate Items.' + "\n" + 'Please correct this problem.' ); 
            } 
        }   // if both Numbers 
 
        // Was it found in Text OR Value 
        else if ( ( typeof ( $foundTextIndex ) == 'number' ) || ( typeof ( $foundValueIndex ) == 'number' ) ) 
        { 
            // Keep index 
            $foundIndex = ( $foundTextIndex != false ) ? $foundTextIndex : $foundValueIndex; 
        } 
 
        // OK, we have something, so porcess it, maybe! ;) 
        if ( $foundIndex != false ) 
        { 
                alert ("This item already exists");
				return false;
            //}   // else -  if $bolOverWrite 
        } 
 
        // a FALSE $foundIndex means he new Item can be Added to SELECT List 
        if ( $foundIndex == false ) 
        { 
            if($strText.trim().length > 23){
	      	var getSubstrText = $strText.trim().substr(0,23);
    		$strText = getSubstrText+"...";

}
            
            // Use built-in Option Object Creation method 
            var $objOption = new Option($strText.trim(), $strValue, $bolDefaultSelected, $bolSelected); 
 
            // Insert new Option Object into Select Object 
            $objSelect.options[$objSelect.length] = $objOption; 
 
            // Set return value 
            $itemAdded = new Boolean ( true ); 
        } 
 
        // We can't the item 
        else 
        { 
            // Set return value 
            $itemAdded = new Boolean ( false ); 
        } 
    }; 

	function findOption($objSelect, $strNeedle, $strSearch) 
    { 
        var $_found = new Boolean( false ); 
 
        // If $objSelect is a nothing [''], convert to a NULL 
        if ( $objSelect == '' ) 
            $objSelect = null; 
 
        // If $objSelect is a string, convert to Object Reference 
        // Then see if Object Reference exists 
        else if ( ( typeof ( $objSelect ) ) == 'string' ) 
            $objSelect = document.getElementById($objSelect); 
 
        // If we have nothing to deal with, just bale... 
        if ( ( $objSelect ) && ( $strNeedle ) && ( ( $strSearch == 'text' ) || ( $strSearch == 'value' ) ) ) 
        { 
 
            for (var $i = 0; $i < $objSelect.options.length; $i++) 
            { 
                if ( $strSearch == 'value' ) 
                    $objHayStack = $objSelect[$i].value; 
 
                else if ( $strSearch == 'text' ) 
                    $objHayStack = $objSelect[$i].text; 
 
                if ( $objHayStack == $strNeedle ) 
                { 
                    $_found = parseInt ( $i ); // We found a match 
                    break; 
                } 
            } 
        } 
 
        // Send back what we have 
        return $_found; 
    }; 

	
	function deleteOption($objSelect, $intIndex) 
    { 
		
        // If $objSelect is a string, convert to Object Reference 
        // Then see if Object Reference exists 
        if ( ( typeof ( $objSelect ) ) == 'string' ) $objSelect = document.getElementById($objSelect); 
 
        // If we have nothing to deal with, just bale... 
        if ( ( ! $objSelect ) ||               // Some browsers will define this 
             ( $objSelect == 'undefined' ) ||  // othes give this 
             ( $objSelect == '' ) ||           // Konqueror gives this 
             ( ! $intIndex ) )                 // Without an index, we have nothing to do 
            return; 
 
        $objSelect.options[$intIndex] = null; 
    }; 
    

function viewAll(state,currentPage,iSetIndex){

	

	if(state == 'viewAll'){

		document.forms[0].state.value = state;
		
		document.forms[0].pageId.value = currentPage;
		
		document.forms[0].mode.value = "nextPageMode";
		
		document.forms[0].submit();
	}
}

function nextSetPage(state,currentPage,iSetIndex,displayPages) 
{      
		if(state == 'next'){
			if(currentPage == displayPages  && state == 'next'){
				document.forms[0].state.value = state;
				
				document.forms[0].sortOrder.value="ASC";
				
				document.forms[0].mode.value = "nextPageMode";
				
				document.forms[0].submit(); 
				
			}else{
				document.forms[0].state.value = state;
				
				document.forms[0].pageId.value = currentPage;
				
				document.forms[0].mode.value = "numberedPageMode";
				
				document.forms[0].submit();
			}
		}
		if(state == 'prev'){
			if(currentPage == 1 && state == 'prev'){  //Or Use PageId+1 instead of currentPage
				document.forms[0].state.value = state;
				
				document.forms[0].sortOrder.value="ASC";
				
				document.forms[0].mode.value = "nextPageMode";
				
				document.forms[0].submit();		
			
			}else{
				document.forms[0].state.value = state;
				
				document.forms[0].pageId.value = currentPage-2;
				
				document.forms[0].mode.value = "numberedPageMode";
				document.forms[0].submit();
			}
	    }
}

//This function is called to set the page index

function pageIndex(pageindex) 

{

	document.forms[0].pageId.value = pageindex;
	
	document.forms[0].mode.value = "numberedPageMode";
	
	document.forms[0].submit();

}//pageIndex(pageindex)

function toggle(colid) 

{ 
	document.forms[0].mode.value = "sortPageMode" ;
	
	document.forms[0].sortid.value=colid;
	
	document.forms[0].sortOrder.value="ASC";
	
	document.forms[0].submit();

}//end of function toggle(colid)

function formSubmit(surl){
//	alert(surl);
	document.forms[0].action=surl;
	document.forms[0].submit();						
}

/************************************************************************************************************************
Function for Check/Uncheck All checkboxes 
Note:

	function toggleCheckbox(chkID, parentCheckID) --------> To check/uncheck Child (to be called onclick of parent) 
	function uncheckParent(chkID, parentCheckID) --------> To check/uncheck parent (to be called onclick of all children) 
	sAdded on 21-June-2005
*************************************************************************************************************************/
function toggleCheckbox(chkID,parentCheckID)
{
 var chkIds = document.getElementsByTagName("input");
 for(var i=0; i<chkIds.length; i++)
 {
	if(eval('document.forms[0].' + parentCheckID + '.checked == true'))
	{
		if((chkIds[i].type).toUpperCase() == "CHECKBOX" && chkIds[i].name.indexOf(chkID) != -1)
		{
		   chkIds[i].checked = true;
		}
	}
	if(eval('document.forms[0].' + parentCheckID + '.checked == false'))
	{
		if((chkIds[i].type).toUpperCase() == "CHECKBOX" && chkIds[i].name.indexOf(chkID) != -1)
		{
		   chkIds[i].checked = false;
		}
	}
  }
	return true;
}
function uncheckParent(chkID, parentCheckID)
{
	var chkIds = document.getElementsByTagName("input");
	var tmpCount = 0;
	var chkChildCount = 0;
	var toggleThis = eval("document.forms[0]."+parentCheckID);
//alert("1 : chkID : " + chkID + "\nparentcheckid : " + parentCheckID);	
//alert("chkIds.length : " + chkIds.length);
	for(i=0; i<chkIds.length;i++)
	{
		if(chkIds[i].name.indexOf(chkID) != -1)
		{
			tmpCount++;
		}
		if(((chkIds[i].type).toUpperCase() == "CHECKBOX" && chkIds[i].name.indexOf(chkID) != -1) && chkIds[i].checked == true)
		{
			chkChildCount++;
		}
		if(tmpCount == chkChildCount)
		{
			toggleThis.checked = true;
		}
		else
		{
			toggleThis.checked = false;
		}
	}
	return true;
}





function ChangeOnMouseOver(Mobj)
	{
		
		Mobj.style.background="#FFCC33";
		Mobj.style.color="#FFFFFF"
	}
function ChangeOnMouseOut(Mobj)
	{
		
		Mobj.style.background="#FFFFFF";
		Mobj.style.color="#000000"
	}

/***************************************************************************************************************
End of script id # 101
/***************************************************************************************************************/



		function checkAll(frmName, parentName, childName){
			var parentChkBox = eval("document."+frmName+"."+parentName);
			var childChkBox = eval("document."+frmName+"."+childName);
			var getCnt = eval("document."+frmName+"."+childName);
			getCnt = getCnt.length;
			if (getCnt > 0){
				for(i=0;i<getCnt;i++){
					if(parentChkBox.checked == true){
						childChkBox[i].checked = true;
					}else {
						childChkBox[i].checked = false;
					}
				}
			} else{
					if(parentChkBox.checked == true){
						childChkBox.checked = true;
					}else {
						childChkBox.checked = false;
					}
			}
		}
		
		function checkUncheckParent(frmName, parentName, childName)
		{
			var parentChkBox = eval("document."+frmName+"."+parentName);
			var childChkBox = eval("document."+frmName+"."+childName);
			var getCnt = eval("document."+frmName+"."+childName);
			getCnt = getCnt.length;
			var keepCnt = 0;
			for(i=0;i<getCnt;i++){
				if(childChkBox[i].checked == true){
					keepCnt++;
				}
			}
			if(getCnt == keepCnt){
				parentChkBox.checked = true;
			}
			else{
				parentChkBox.checked = false;
			}
		}
		
		function chkForSelected()
		{
			var chkIds = document.getElementsByTagName("input");
			var chkCount = 0;
			for(var i=0; i<chkIds.length; i++)
			{
		    	if((chkIds[i].type).toUpperCase() == "CHECKBOX")
		    	{
					if(chkIds[i].checked == true)
					{
						chkCount++;
					}
				}
			}
			if(chkCount < 1)
			{
				alert("Please select at least one asset for this operation");
				return false;
			}
			else
			{
				return true;
			}
		
		}
		
		
		
/*-------------------------------------------------------------------
  Functions That Do The Scrolling Of Left Navigation And Level4 Menus
  --------------------------------------------------------------------*/
  
var isDOM  = (document.getElementById ? true : false);
var isIE   = ((document.all) ? true : false);
var divElement;
var footerDiv; 
var headerDiv;
// The Default Footer Width Used if You Cannot Retrieve The height
var defaultFooterHeight = 120;
// Padding Used To Control The Overflow
var padding = 90;
// Padding To Fine Tune The Scrolling 
var scrollPadding  = 30;

/* Does The Actual Scrolling Of The Element To the Given Offset*/
function scrollIt(pageOffset)
{ 
	if(isIE) 
	{ divElement.style.pixelTop = pageOffset;}
	else if(isDOM)
	{divElement.style.top = pageOffset;}
}

/* Checks The Scroll OverFlow Returns True If The Menu OverFlows else false */
function checkOverFlow(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight,footerPos)
{
   	if((pageOffset+elementHeight)>(scrollHeight - headerHeight))
	{return true;}
	else
	{return false;}
}
/* Checks The Scroll OverFlow Returns True If The Menu OverFlows else false */
function checkUnderFlow(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight)
{
	if(pageOffset < headerHeight)
	{return true;}
	else
	{return false;}
}

/* If The Browser Is Small Controlling The Scrolling */
function smallBrowser(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight)
{
/* Checkinf For Menu Over Flow */
if(checkOverFlow(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight))
{ pageOffset = (scrollHeight-footerHeight-elementHeight-headerHeight-padding);
 if(pageOffset<(headerHeight+scrollPadding))
  {pageOffset = 0;}
  scrollIt(pageOffset);  }
/* Checking For Menu Under Flow */  
else if(checkUnderFlow(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight))
{ scrollIt(0); }

/* Do The Manipulation For Scrolling */  
else{
	var difference =  (elementHeight-browserHeight)+50;
	var currentPos =  0;
	if(isIE) 
	{currentPos = divElement.style.pixelTop;}
	else if(isDOM)
	{	currentPos = divElement.style.top;
		var strLength = currentPos.length;
		var pixelSuffix = currentPos.substr((strLength -2),strLength);
		if(pixelSuffix.toUpperCase()=='PX' || pixelSuffix.toUpperCase()=='PT')
		{currentPos = eval(currentPos.substr(0, (strLength -2)));}
	}
	var scrollRange = ((pageOffset-headerHeight) - (currentPos+difference));
	/* Deals With Srolling FWD */
	if(scrollRange >=25)
	{ 
	scrollIt(currentPos+difference); }
	/* Deals With Scrolling BWD */
	else if( (pageOffset-headerHeight) < currentPos)
	{ scrollIt(pageOffset - headerHeight-scrollPadding); }
 }
}


/* If The Browser Is Large Enough To Accomodate the Element */
function bigBrowser(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight)
{  
    /* Checking For Menu Over Flow */
	if(checkOverFlow((pageOffset+padding),scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight))
	{ pageOffset = (scrollHeight-footerHeight-elementHeight-headerHeight-padding);
	  if(pageOffset<(headerHeight+scrollPadding))
	  {pageOffset = 0;}
	}
    /* Checking For Menu Under Flow */ 
	else if(checkUnderFlow(pageOffset,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight))
	{pageOffset = 0;}
	/* Do the Manipulation For Scrolling */
	else
	{pageOffset = pageOffset - headerHeight ;}
    scrollIt(pageOffset);  
}

/* Does The Scrolling of the Element , invoked by 'setTimeOut()'*/ 
function scrollContent() {
var scrollHeight = 0;
var elementHeight = 0;
var browserHeight = 0;
var footerHeight = 0;
var headerHeight = 0;
var doScroll = false;
if(divElement)
{
if(isIE) 
{ diffY = document.body.scrollTop; }
else if(isDOM)
{ diffY = self.pageYOffset; }

if(isIE || isDOM)
{
	headerHeight = headerDiv.offsetHeight;
	scrollHeight  = document.body.scrollHeight;
	elementHeight = divElement.offsetHeight;  
	browserHeight = document.body.clientHeight;
	
	if(footerDiv)
	{footerHeight = footerDiv.offsetHeight;}
	else
	{ footerDiv  = document.getElementById("footerDiv"); 
  	  footerHeight = defaultFooterHeight; }
	if( (elementHeight+scrollPadding) > browserHeight)
	{smallBrowser(diffY,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight);}
	else
	{bigBrowser(diffY,scrollHeight,elementHeight,browserHeight,headerHeight,footerHeight);} 
	
 } // Do The Scrolling Only For IE And FireFox
}
} 
/*----------------------------------------------------------------------------
                              End Of The Scrolling Issue
-----------------------------------------------------------------------------*/	

//Start:Added for Asset Modification - M1007875
function deleteAssets(assetCategoryId){
	if(chkForDeleteSelected()){ 
		var confirm_delete = false;
		if(checkCopyrightSelected()){
			confirm_delete = confirm("You have selected a CopyRight asset to delete.Copyright details will no longer be appended \n to any site downloads and instead, the default copyright document shall be appended. \n\nAre you sure you want to delete this CopyRight?");
		} else{		
			confirm_delete = confirm("Are you sure you want to permanently delete the selected asset(s)?");
		}
		if(confirm_delete == true){
			
			document.assetListSearchForm.action = "assetDeleteAction.do?AssetCategoryId=" + assetCategoryId + "&par=" + Math.random();				
			document.assetListSearchForm.submit();
		}
	}
}

function chkForDeleteSelected(){
	var chkIds = document.getElementsByName("deleteAsset");
	var chkCount = 0;
	for(var i=0; i<chkIds.length; i++){
		if(chkIds[i].checked == true)
		{
			chkCount++;
		}
				
	}
	if(chkCount < 1){
		alert("Please select at least one asset for this operation");
		return false;
	}else{
		return true;
	}
}

function checkCopyrightSelected(){
	var chkIds = document.getElementsByName("deleteAsset");

	for(var i=0; i<chkIds.length; i++){
	if((document.getElementById("assetTypeId" + i).value == "1216")&& (chkIds[i].checked == true))
		{	
			return true;
		}
	}
	return false;
}		

//Function to highlight the row selected for edit - M1003454
function highlightRow(rowId,numberOfRows){
	if(document.getElementById(rowId) != null){
		for(i=0;i<numberOfRows;i++){
			document.getElementById("ROW_" + i).style.backgroundColor='#ccecff';
		}
		document.getElementById(rowId).style.backgroundColor='#8ed4ef';	
	}
}
//Function to remove highlight of the row selected for edit - M1003454
function decolorizeRow(rowId){
	if(document.getElementById(rowId) != null){
		document.getElementById(rowId).style.backgroundColor='#ccecff';
	}
}
//Function to check/uncheck checkboxes when Select All checkbox is clicked
//Select all checkbox should be named 'chkAll'
function check_uncheck_all_elements(varForm)       
{         
	var getEleCnt = varForm.elements;
	var selected = false;
    if(varForm.chkAll.checked == true)
    {
		selected = true;
	}
	for(i=0;i<getEleCnt.length;i++)
	{
		if(getEleCnt[i].type == "checkbox")
		{
			getEleCnt[i].checked = selected;
		}  
	}
}
function uncheckSelectAllBox(varForm, chkID, parentCheckID)
{
	var chkIds = document.getElementsByTagName("input");
	var tmpCount = 0;
	var chkChildCount = 0;
	var toggleThis = eval(varForm.name + "." + parentCheckID);
	for(i=0; i<chkIds.length;i++)
	{
		if(chkIds[i].name.indexOf(chkID) != -1)
		{
			tmpCount++;
		}
		if(((chkIds[i].type).toUpperCase() == "CHECKBOX" && chkIds[i].name.indexOf(chkID) != -1) && chkIds[i].checked == true)
		{
			chkChildCount++;
		}
		if(tmpCount == chkChildCount)
		{
			toggleThis.checked = true;
		}
		else
		{
			toggleThis.checked = false;
		}
	}
	return true;
}
//Function to force focus on the pop up window
var window_force_focus = {
	init : function() {
	var opener = window.opener;
	var child_window = self;
	if (opener.addEventListener) {
		if (!opener || !child_window) 
			return;
		if (!opener.blur || !child_window.focus) 
			return;
		opener.addEventListener("focus", function() {
			setTimeout(function(){
				opener.blur();
				child_window.focus();
				}, 0);
			}, false)
		} else if (opener.attachEvent) {
			opener.attachEvent("onfocus", function() {
			//	opener.blur();
				child_window.focus();
			});
		}
	}
};

function deletevideoAsset(assetCategoryId){
	if(chkForSelected()){ 
		var confirm_delete = confirm("Are you sure you want to permanently delete the selected asset(s)?");
	}
	if(confirm_delete == true){	
			document.assetListSearchForm.action = "assetDeleteAction.do?AssetCategoryId=" + assetCategoryId + "&par=" + Math.random();				
			document.assetListSearchForm.submit();
	}
}

//End:Added for Asset Modification
		
	
		
		
		
