//manoj
//Prasad - Start

//For XML 

  function goToTermsPrivacyHelpFromXML(strName)
  {	
  
		var strQueryString;
    	if (strName == 1)
    	{
    		strQueryString = 'http://' + strServerNameDyn + strPortDyn + strServerPathDyn + '/br/Help/TermsAndConditionsPage.aspx?Content=Help'
    	}
    	else
    	if (strName == 2)
    	{	
    		strQueryString = 'http://' + strServerNameDyn + strPortDyn + strServerPathDyn + '/br/Help/TermsAndConditionsPage.aspx?Content=Terms'
    	}
    	else
    	if (strName == 3)
    	{
    		strQueryString = 'http://' + strServerNameDyn + strPortDyn + strServerPathDyn + '/br/Help/TermsAndConditionsPage.aspx?Content=Privacy'
    	}
    	
		submitPageFE(strQueryString);
   }

function setComboAssetType(strValue)
{		
		var objAssetType = getObj("cbAssetTypeList")
		if(typeof(objAssetType) =='object'){
		for(var i=0; i<objAssetType.length;i++){
			if(objAssetType.options[i].value == strValue){
				objAssetType.selectedIndex = i;
			}
		}
	}
}
function TitleGoToIntermediate(strLink,ApplicationName)
{	
	strDefaultLink = ApplicationName + '/br/CommonPages/IntermediateCookieHandlingPage.aspx?hidURL=' + escape(strLink) ;
	submitPageFE(strDefaultLink);	
	return false;			
}
//Prasad - Start
function winclose()
{
	window.close();
	// Mac change added return false;
	return false;
}
	
	
function validatePopupContact()
{			    
	var txtNameType = getObj("txtName",1);
	var txtNumberType = getObj("txtNumber",1);
	
	if(isBlank(txtNameType, 'Name')) return false;
	if(isBlank(txtNumberType, 'Number')) return false; 
}
	
function goPopUpPage(pageNum,strpopuppage)
{
			if (pageNum == 2)
			{ 
				popUpPage = '../Preferences/TechDetail.aspx'
				popupWin(popUpPage ,'455','330','no');
			}
			if (pageNum == 1)
			{
				//popUpPage = '../HelpDesk/FEListFAQ.aspx'
				//popupWin(popUpPage ,'510','550','yes');
				//strQueryString ='../HelpCenter/HelpCenter.aspx?type=1&pageval=HelpCenterIncludes/FAQ.inc';
				strQueryString = '../Help/TermsAndConditionsPage.aspx?Content=Help';
				submitPageFE(strQueryString);
				return false;
			}
			if (pageNum == 3)
			{	
				
				popUpPage = strpopuppage
				window.open(popUpPage,'','scrollbars=yes,width=500,height=250,status=yes,menubar=yes,toolbar=yes,location=yes');
			}
			if (pageNum == 4)
			{
				//popUpPage = '../HelpDesk/FEListFAQ.aspx'
				//popupWin(popUpPage ,'510','550','yes');
				strQueryString ='../Help/TermsAndConditionsPage.aspx?Content=Help';
				submitPageFE(strQueryString);
				return false;
			}
}

function setSaveClicked()
{
	window.document.forms[0].hidSave.value = "1";
}
function setValForTeleStream()
{
	
	if (window.document.forms[0].chkTelestream.checked == 'false')
	{
		window.document.forms[0].chkTelestream.value = "false"
	}
	else
	{
		window.document.forms[0].chkTelestream.value = "true"
	}
	window.document.forms[0].submit();
	
}
function SetDeliveryOption(strDelivery)
{
	window.document.forms[0].hidDeliveryType.value = strDelivery;
	window.document.forms[0].submit();
}
function goToOrderHistoryPage(strServer,strPort)
{
	var sLink = "";
	var strQueryString = "";
	strQueryString ='/br/ShoppingCart/OrderHistory.aspx';
	sLink = 'Http://'+ strServer + strPort + strQueryString 
	window.location.href = sLink
	return false;
}
function goPreferencePage(sidemode,strServer,strPort,strUserType)
{
	var strQueryString = '';
	var iUserType = parseInt(strUserType);
	
	if (sidemode == "1")
	{
	
		strQueryString ='/br/preferences/MyAccount.aspx?sidemode='+sidemode;
	}
	else if (sidemode == "2")
	{	
		switch (iUserType)
		{
		    /* these r the different userTypes they r directed to the same
		       page i.e the userProfile.aspx.
		      
		    */
		    case 6:
		      strQueryString='/br/preferences/UserProfile.aspx?userType='+iUserType+'&sidemode='+sidemode;
			  break;
		    case 1:
		      strQueryString='/br/preferences/UserProfile.aspx?userType='+iUserType+'&sidemode='+sidemode;
		      break;
			case 2:
			  strQueryString='/br/preferences/UserProfile.aspx?userType='+iUserType+'&sidemode='+sidemode;
			  break;
			case 3:
			  strQueryString='/br/preferences/UserProfile.aspx?userType='+iUserType+'&sidemode='+sidemode;
			  break;
			case 7:
			case 11:
			  strQueryString='/br/preferences/UserProfile.aspx?userType='+iUserType+'&sidemode='+sidemode;
			  break;
			case 9:
			    strQueryString='/br/preferences/UserProfile.aspx?userType='+iUserType+'&sidemode='+sidemode;
			    break;
			case 4:
			case 8:
			case 10:
				strQueryString ='/br/preferences/UserProfileCompany.aspx?sidemode='+sidemode;
				break;
		}
	}
	else if (sidemode == "3")
	{
		strQueryString ='/br/preferences/ContentPreferences.aspx?sidemode='+sidemode;
	}
	else if (sidemode == "4")
	{
		strQueryString ='/br/preferences/OrderHistory.aspx?sidemode='+sidemode;
	}
	else if (sidemode == "5")
	{
		strQueryString ='/br/preferences/VideoDeliveryOption.aspx?sidemode='+sidemode+'&option='+'delivery';
	}
	else if (sidemode == "6")
	{
		strQueryString ='/br/preferences/StreamingMediaOptions.aspx?sidemode='+sidemode;
	}
	else if (sidemode == "10")
	{
		strQueryString ='/br/Clippings/myclippings.aspx';
	}
	
	
	if (sidemode == "2")
	{
		var sLink = 'Https://'+ strServer + strQueryString 
	}
	else
	{
		var sLink
		sLink = 'Http://'+ strServer + strPort + strQueryString 
	}
	//submitPageFE(sLink);
	
	window.location.href = sLink
	//window.document.forms[0].action = sLink;
	//window.document.forms[0].submit();
	return false;
}

function setFolderOption()
{
	var cmbFolderListType = getObj("cboFolderList","2")
	if 	(cmbFolderListType == '[object]')
	{
		for(i = 0; i < cmbFolderListType.options.length; i++)
		{
			if (cmbFolderListType.options[i].text == window.document.forms[0].hidOldFolderName.value)
			{
				cmbFolderListType.options[i].selected=true;
			}
			else
			{
				cmbFolderListType.options[i].selected=false;
			}
		}
	}	
}

function SwitchStateCart(iUserType,iTopSpace,iAdjust,iJavascriptAdValue)
{
	var objStateDiv;
	var explorer=false;
	var netscape = false;
	var mac=false;
	var iUSid = 1;  
	var browser=navigator.userAgent;
	var cmbCountryType = getObj("cmbCountry","2")
	iUSid = cmbCountryType[1].value;
	strMoveDiv = iJavascriptAdValue + iTopSpace + iAdjust ;
	
	if(browser.indexOf('Mac')>0)
		mac=true;
		
	if(browser.indexOf('MSIE')>0)
		explorer = true;
	else
		netscape = true;
		if (cmbCountryType.value == iUSid){
		
				showElement(getElement('spanSelState'));
				showElement(getElement('spanStateLabel'));
				hideElement(getElement('spanTxtState'));
			}
		else {
				var strMoveDiv ;
				objStateDiv = getElement('spanTxtState');
				showElement(getElement('spanTxtState'));
				hideElement(getElement('spanStateLabel'));
				hideElement(getElement('spanSelState'));
				if (mac && netscape)
				{
					if (iUserType == 1)
					{
						objStateDiv.style.top = "600px";
					}
					else if (iUserType == 2)
					{
						objStateDiv.style.top = "610px";
					}
					else if (iUserType == 11)
					{
						objStateDiv.style.top = "540px";
					}
					else
					{
						objStateDiv.style.top = "540px";
					}
				}
				else
				if (mac && explorer)
				{
					if (iUserType == 1)
					{
						objStateDiv.style.top = "580px";
					}
					else if (iUserType == 2)
					{
						objStateDiv.style.top = "590px";
					}
					else if (iUserType == 11)
					{
						objStateDiv.style.top = "520px";
					}
					else
					{
						objStateDiv.style.top = "520px";
					}
				}
				else								
				if (netscape)
				{	

					if (iUserType = 1)
					{
						objStateDiv.style.top = strMoveDiv;
					}	
					else if (iUserType = 2)
					{
						objStateDiv.style.top = strMoveDiv;
					}	
					else if (iUserType = 11)
					{
						objStateDiv.style.top = strMoveDiv;
					}	
					else
					{
						objStateDiv.style.top = strMoveDiv;
					}
				}
			}
		return false;
}		

function SwitchUsers(iType)
{		
		var objStateDiv;
		var explorer=false;
		var netscape = false;
		var mac=false;
		var browser=navigator.userAgent;
		
		
		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
			
		var obj11 = document.getElementById("spanOtherUsers");
		var obj12 = document.getElementById("spanTVFormat");
	
		if (iType==1 || iType==2)
		{
			if(explorer)
			{
				obj11.style.display ='';				
				obj12.style.display ='';
			}
			if(netscape)
			{
				showElement(getElement('spanOtherUsers'));
				showElement(getElement('spanTVFormat'));
			}
		}
		else 
		{			
			if(explorer)
			{			
				obj11.style.display ='none';
				obj12.style.display ='none';			
			}
			if(netscape)
			{
				hideElement(getElement('spanOtherUsers'));
				hideElement(getElement('spanTVFormat'));
			}
		}		
		document.forms[0].hidUserType.value = iType;
		document.forms[0].submit();
}
	
function validateLoginMain(mode,normal)
{		
		/* Login Validations*/
		var txtLoginEmailType = getObj("txtLoginEmail","1");
		var txtLoginPasswordType = getObj("txtLoginPassword","1");
		
		
		if (isBlank(txtLoginEmailType,'Email Address','Email Address is required.\nPlease enter an Email Address.'))
		{	
			txtLoginEmailType.focus();
			return false;
		}
		
		if (!isEmail(txtLoginEmailType,'Email Address')) return false;
		
		if(mode==1)
		{
			if (isBlank(txtLoginPasswordType,'Password'))
			{	
				txtLoginPasswordType.focus();				
				return false;
			}
			if (txtLoginPasswordType.value.length<4)
			{
					alert('Please enter password more than 3 characters');					
					txtLoginPasswordType.focus();
					return false;
			}
		}				
		window.document.forms[0].LoginClick.value=mode;
		//window.document.forms[0].submit();
		if (normal != '0')
		{	
			window.document.forms[0].submit();
			return false;
		}	
		return true;
}

function SendToClipping()   
{
  	//window.opener.winReload();
	window.close();
}
function SetHiddenValue()  
{
	window.document.forms[0].hidSave.value = "S";
}
function resize()  
{
	window.resizeTo('600','306')
}
function DecreaseFolderCount()
  {  
	 if(parseInt(window.document.forms[0].hidEmpty.value) > 0)
	 {
		if(confirm("There are stories and/or media assets content in this folder. Do you still want to delete it?"))
        {
			window.document.forms[0].hidDelete.value = 1; 
			window.document.forms[0].action = "MyClippings.aspx"
			return true;
		}
		else
		   return false;
	 }
	 else
	 {
   	   if(confirm("Are you sure,you want to delete the Clipping Folder?"))
	   {
		 window.document.forms[0].hidDelete.value = 1; 
		 window.document.forms[0].action = "MyClippings.aspx"
		 return true;
	   }
	   else
	     return false;
	 }
  }

var totalcheckboxcount,checkboxcount,selectedClippingId = 0;

function selectedindexchanged(obj)
{
  //window.document.forms[0].hidSelectedClippingId.value = obj.options[obj.selectedIndex].value;
  selectedClippingId = obj.selectedIndex;
}

function SetAction(Id,varType,operationType)
{
	if ((operationType == '2') || (operationType == '3'))	
	{
		window.document.forms[0].hidRemoveMoveSelected.value = "S";
	}
	if(Id==0)
	{
		alert('This functionality is only available to registered users.\nTo register click the "Register" link.\nIf you have already registered, then please login.')
		return false;
	}
    else
    {
		if(mstrUserStatus == 4)
 		{
 			if (operationType == 1)
 			{
 				alert('Your registration is still in progress.\nYou will receive a notification when your registration is approved after which you will be allowed to order media.')
				return false;
			}
 		}
 		if(iUserType==8 || iUserType==4)
 		{
 			//Bizdev user
 			if (operationType == 1)
 			{
 				alert("We're sorry, but this feature is only available to registered media journalists.\nYou are currently on a demonstration account and do not have rights to order any media assets.\nPlease send an email to mediarelations@thenewsmarket.com if you do need to order assets. Thank you.");
				return false;
			} 			
 		}

 		/*
 		else if(<%=mstrUserStatus%> != 5 && <%=mstrUserStatus%> != 1) 
 		{
 			alert('This functionality is only available to registered users.\nTo register click the "Register" link.\nIf you have already registered, then please login.')
			return false;
 		}
 		*/
 		
 		GetCheckedCount();
 		if(checkboxcount == 0)
		{
		  switch(operationType)
		  {
		    case 1:
				alert("To add Stories to the Cart, please check at least one Story.");		       
				break;

		    case 2:
				alert("To remove Stories, please check at least one Story.");		       
				break;

		    case 3:
				alert("To move Stories, please check at least one Story.");		       
				break;
		  }
		  return false;
		  
		}
		else
		{
		   if(operationType == 3)
		   {
						    
                if(selectedClippingId == 0)
                {
					alert("Please select a clipping folder to move the story into.");
					return false; 
				}
		   }
 		   //window.document.forms[0].hidAction.value=varType;
		   return true;
		}
    }	
}

function SetAssetAction(Id,varType,operationType)
{
	if ((operationType == 2) || (operationType == 3))	
	{
		window.document.forms[0].hidRemoveMoveSelected.value = "A";
	}
	
	if(Id==0)
	{
		alert('This functionality is only available to registered users.\nTo register click the "Register" link.\nIf you have already registered, then please login.')
		return false;
	}
    else
    {
		if(mstrUserStatus == 4)
 		{
 			if (operationType == 1)
 			{
 				alert('Your registration is still in progress.\nYou will receive a notification when your registration is approved after which you will be allowed to order media.')
				return false;
			}
 		}
 		if(iUserType==8 || iUserType==4)
 		{
 			//Bizdev user
 			if (operationType == 1)
 			{
 				alert("We're sorry, but this feature is only available to registered media journalists.\nYou are currently on a demonstration account and do not have rights to order any media assets.\nPlease send an email to mediarelations@thenewsmarket.com if you do need to order assets. Thank you.");
				return false;
			} 			
 		}

 		/*
 		else if(<%=mstrUserStatus%> != 5 && <%=mstrUserStatus%> != 1) 
 		{
 			alert('This functionality is only available to registered users.\nTo register click the "Register" link.\nIf you have already registered, then please login.')
			return false;
 		}
 		*/
 		
 		GetCheckedCount();
 		if(checkboxcount == 0)
		{
		  switch(operationType)
		  {
		    case 1:
				alert("To add Media Assets to the Cart,please check atleast one Media Asset.");		       
				break;

		    case 2:
				alert("To remove Media Assets, please check at least one Media Asset.");		       
				break;

		    case 3:
				alert("To move Media Assets,please check atleast one Media Asset.");		       
				break;
		  }
		  return false;
		  
		}
		else
		{
		   if(operationType == 3)
		   {
						    
                if(selectedClippingId == 0)
                {
					alert("Please select a clipping folder to move the media assets into.");
					return false; 
				}
		   }
 		   //window.document.forms[0].hidAction.value=varType;
		   return true;
		}
    }	
}

function GetCheckedCount()
{
    totalcheckboxcount = 0;
    checkboxcount = 0;
    
	for(i=0;i < window.document.forms[0].elements.length; i++)
	{
		if(window.document.forms[0].elements[i].type == "checkbox")
		{
		totalcheckboxcount = totalcheckboxcount + 1;
		if(window.document.forms[0].elements[i].checked == true)
			checkboxcount = checkboxcount + 1;
		}
	}
}

function ValidateClearAll()
{
	UnCheckAll();
	return false;
	/*GetCheckedCount();
	if(checkboxcount == 0)
	{
		alert("All the Stories are already unchecked");
		return false;
	}*/
}
function UnCheckAll()
{    
	for(i=0;i<window.document.forms[0].elements.length; i++)
	{
		if(window.document.forms[0].elements[i].type == "checkbox")
		{				
			window.document.forms[0].elements[i].checked = false;		
		}
	}		
	return false;
}

function ValidateCheckAll()
{
	CheckAll();
	return false;
	/*GetCheckedCount();
	if(totalcheckboxcount == checkboxcount)
	{
		alert("All the Stories are already checked");
		return false;
	}*/
}

function CheckAll()
{   	
	for(i=0;i<window.document.forms[0].elements.length; i++)
	{
		if(window.document.forms[0].elements[i].type == "checkbox")
		{				
			window.document.forms[0].elements[i].checked = true;		
		}
	}		
	return false;
}

function Test(strPage)
{
	if (strPage == '1')
	{
			window.document.forms[0].action = "MyClippings.aspx?pId=1";
			window.document.forms[0].hidPageNum.value = "1";
  	  		return true;
	}
	else
	{
			window.document.forms[0].action = "MyClippings.aspx?pId=2";
			window.document.forms[0].hidPageNum.value = "1";
  	  		return true;
	}
}
function ValidateFolderName(mstrActionMode)
{
	var regexp = "/'/g";
   	var strFolderName;
 	var txtCreateFolderNameType;
 	var txtNewFolderNameType;
 	var hidSaveClickedType = getObj("hidSaveClicked","1")
 	 	
	if (mstrActionMode == '1')
	{
		txtCreateFolderNameType = getObj("txtCreateFolderName","1")
   		if (isBlank(txtCreateFolderNameType,"Folder Name"))
   		{
  			   return false;
  		}	   
  	}	
   	else
   	{
   		txtNewFolderNameType = getObj("txtNewFolderName","1")
   		if (isBlank(txtNewFolderNameType,"Folder Name"))
  		{
  			return false;
  		} 
   	}		
  	if (mstrActionMode == '1')
  	{
		strFolderName = txtCreateFolderNameType.value;
		strFolderName = strFolderName.replace(/'/g,"''");
		window.document.forms[0].hidFolderName.value = strFolderName;
	}			
	else
	{
		foldername = txtNewFolderNameType.value;
		foldername = foldername.replace(/'/g,"''")
		window.document.forms[0].hidFolderName.value = foldername;
	}
}

function setTextBoxFocus(mstrActionMode)
{
		
 	if (mstrActionMode == '1')
 	{
 	
 		var txtCreateFolderNameType = getObj("txtCreateFolderName","1")
 		txtCreateFolderNameType.focus();
 	 	window.resizeTo(604,326);
 	 }
 	 else
 	 {
 		var txtNewFolderNameType = getObj("txtNewFolderName","1")
 		txtNewFolderNameType.focus();
 	 }
} 

function RefreshOpenerPage(mstrItemId,mstrItemType,mstrCurrentPage,miAddedFolderId)
{
	if ((mstrItemId != '') && (mstrItemType != ''))
	{
		window.opener.winReload();
	}
  	else
  	{
  	  	if (mstrCurrentPage != '')
  	  	{
  	  		//window.opener.document.forms[0].hidId.value = 1;
  	  		window.opener.document.forms[0].action = mstrCurrentPage + ".aspx?Id=" + document.forms[0].hidAddedFolderId.value; 
  	  		//window.opener.document.forms[0].action = "MyClippings.aspx?Id=" + miAddedFolderId
  	  		window.opener.document.forms[0].submit();
  	  	}	
  	}		
	window.close();
}

function FolderChanged()
{
	var cboFolderListType = getObj("cboFolderList","2")
    window.document.forms[0].hidClippingId.value = cboFolderListType.options[cboFolderListType.selectedIndex].value;
    window.document.forms[0].hidFolderName.value = cboFolderListType.options[cboFolderListType.selectedIndex].text;
    window.document.forms[0].hidOldFolderName.value = cboFolderListType.options[cboFolderListType.selectedIndex].text;
    /*window.document.forms[0].hidSelectedTab.value = 2 ;
    window.document.forms[0].hidAssetType.value = '' ;*/
    window.document.forms[0].action = "MyClippings.aspx"
    window.document.forms[0].submit();
}
  function FirstOpenPopUp(iCurrentClippingFolderCount,iMaxClippingFolderCount,strCurrentPageName)
  {
            if (iCurrentClippingFolderCount >= iMaxClippingFolderCount)
            {
                 alert("A Clipping Folder cannot be created.\nYou have reached the maximum limit of the Clipping Folders you can have.");
                 return false;
            }     
            else
            {
  				var str = "CreateFolder.aspx?ActionMode=1&ClippingId=0&CurrentPage=" + strCurrentPageName
  				 popupWin(str,'604','326','yes','yes');
  				 return true;
	 		}
	return false;
  }


function OpenPopUp(ActionType,iCurrentClippingFolderCount,iMaxClippingFolderCount,strCurrentPageName)
  {
	var cboFolderListType = getObj("cboFolderList","2");
    switch(ActionType)
    {
      case 1:
            if (iCurrentClippingFolderCount >= iMaxClippingFolderCount)
            {
                 alert("A Clipping Folder cannot be created.\nYou have reached the maximum limit of the Clipping Folders you can have.");
                 return false;
            }     
            else
            {
  				var str = "CreateFolder.aspx?ActionMode=1&ClippingId=0&CurrentPage=" + strCurrentPageName
  				 popupWin(str,'604','326','yes','yes');
  				 break;
	 		}
      case 2:
			var strSelectedClipping = cboFolderListType.options[cboFolderListType.selectedIndex].value;
			var str1 = "CreateFolder.aspx?ActionMode=2&ClippingId=" + strSelectedClipping  + "&CurrentPage=" + strCurrentPageName
       	    pop = popupWin(str1,'604','326','yes','yes'); 
    		break;
    }
	return false;
  }
  function OpenPopUp1(ActionType,iCurrentClippingFolderCount,iMaxClippingFolderCount,strCurrentPageName,strItemId,strItemType)
  {
	var cboFolderListType = getObj("cboFolderList","2");
    switch(ActionType)
    {
      case 1:
            if (iCurrentClippingFolderCount >= iMaxClippingFolderCount)
            {
                 alert("A Clipping Folder cannot be created.\nYou have reached the maximum limit of the Clipping Folders you can have.");
                 return false;
            }     
            else
            {
  				var str = "CreateFolder.aspx?ActionMode=1&ClippingId=0&CurrentPage=" + strCurrentPageName + "&ItemId=" + strItemId + "&ItemType=" + strItemType
  				 popupWin(str,'604','326','yes','yes');
  				 break;
	 		}
      case 2:
			var strSelectedClipping = cboFolderListType.options[cboFolderListType.selectedIndex].value;
			var str1 = "CreateFolder.aspx?ActionMode=2&ClippingId=" + strSelectedClipping  + "&CurrentPage=" + strCurrentPageName + "&ItemId=" + strItemId + "&ItemType=" + strItemType
       	    pop = popupWin(str1,'604','326','yes','yes'); 
    		break;
    }
	return false;
  }
//Prasad - end
//Pre_registration Page
function LoginGoClick() 
{
	window.document.forms[0].hidFormType.value = '1';
	return false;
}

function resetFormType()
{
	window.document.forms[0].hidFormType.value = '';
	return false;
}

function PasswordHelp(ApplicationPath)
{
	var sLink = ApplicationPath + '/br/Login/PasswordHelp.aspx?isPopup=1';
	popupWin(sLink ,'430','333','no');		
}

// For Pre-Registraion Page
function validateLogin(ServerPath,ApplicationPath,PageName)
{
	var objTxtLogin, objTxtLogin, objRememberMe;

	/* Login Validations*/
	objTxtLogin = getObj("txtUserName");
	objTxtPwd = getObj("txtPassword");
	objRememberMe = getObj("chkRemeberMe");

	if (isBlank(objTxtLogin,"Email Address","Email Address is required.\nPlease enter an Email Address."))
	{	
		objTxtLogin.focus();
		return false;
	}
	if (!isEmail(objTxtLogin,"Email Address")) return false;
	if (isBlank(objTxtPwd,"Password"))
	{	
		objTxtPwd.focus();
		return false;
	}
	if (objTxtPwd.value.length<4)
	{
		alert("Please enter password more than 3 characters.");
		objTxtPwd.focus();
		return false;
	}
	/*if(objRememberMe.checked==false) 			
	{
		delCookie('MediaRoomLogin',ApplicationPath);
	delCookie('MediaRoomPassword',ApplicationPath);
	}*/
	// delete the cookie.
//	alert() 
	//delCookie('stories_visited',ApplicationPath);
	//delCookie('media_visited',ApplicationPath);
	sLink = 'Https://'+ServerPath+PageName;
	
	var isQuestPresent = sLink.indexOf("hidTargetSessionRequired=TRUE");
	var firstPartUrl ='';
	var middlePartUrl = '';
	if(isQuestPresent!=-1)
	{
		sLink = sLink.replace("hidTargetSessionRequired=TRUE","hidTargetSessionRequired=FALSE")
	}
	if(navigator.userAgent.indexOf('Netscape')>0)
	{
		document.forms[0].hidForNetscape.value="1";
		document.forms[0].hidTxtUserName.value=objTxtLogin.value;
		document.forms[0].hidPassord.value=objTxtPwd.value;
	}
	submitPageFE(sLink);
	return true;
}

function getObj(txtName,mode)
{
	var elm, a, b, c;
	for (a = 0; a < document.forms.length; a++)
	{
		form = document.forms[a];
		for (b = 0; b < form.elements.length; b++)
		{
			elm = form.elements[b];
			if(mode=='1')
			  {
				if (elm.name.indexOf(txtName) > 0)
				{
					return elm;
				}
			  }
		  else
			{
				if (elm.id.indexOf(txtName) > 0)
				{
					return elm;
				}
			}
		}
	}
	//alert(txtName + ": Element Not Found!!!");
}

// For Pre-Registraion Page

function validateRegister(){
		objFirstName = getObj("txtFirstName",1);
		objLastName = getObj("txtLastName",1);
		objEmail = getObj("txtEmail",1);
		
		

objbtnGoRegister =
document.getElementById("objContainerControl_objTemplateContainerControl_objContentControl_btnGoRegister");



		
		objrdo1 = getObj("rdo1",2);
		objrdo2 = getObj("rdo2",2);
		objrdo11 = getObj("rdo11",2);
		objrdo12 = getObj("rdo12",2);
		objrdo7 = getObj("rdo7",2);
		
			
		/*First Name Validation*/
		if (isBlank(objFirstName,'First Name'))return false;
		if (!isAlpha(objFirstName,'First Name')) return false;


		/*Last Name Validation*/
		if (isBlank(objLastName,'Last Name')) return false;
		if (!isAlpha(objLastName,'Last Name')) return false;

		/*Email Validation*/
		if (isBlank(objEmail,'Email Address','Email Address is required.\nPlease enter an Email Address.')) return false;
		if (!isEmail(objEmail,'Email Address')) return false;
			
		if(typeof(objrdo1)=='object'){
			if (objrdo1.checked)
				{
					/* Media User */
					window.document.forms[0].hidCurrentPageKeys.value='1~0~0~ADD';
				}
		}else if(typeof(objrdo2)=='object'){
			if (objrdo2.checked)
			{
				/* Freelancer */				
				window.document.forms[0].hidCurrentPageKeys.value='2~0~0~ADD';
			}
		}else if(typeof(objrdo11)=='object'){
			if (objrdo11.checked)
			{
				/* c. Marketing or Public Relations User */
				window.document.forms[0].hidCurrentPageKeys.value='11~0~0~ADD';
			}
		}else if(typeof(objrdo7)=='object'){
			if (objrdo7.checked)
			{
				/* Other */
				window.document.forms[0].hidCurrentPageKeys.value='7~0~0~ADD';
			}
		}else if(typeof(objrdo12)=='object'){
			if (objrdo12.checked)
			{
				/* Other */
				window.document.forms[0].hidCurrentPageKeys.value='4~0~0~ADD';
			}
		}
		objbtnGoRegister.focus();
		return true;
}

//For Intermediate Page
function SubmitSSLPage(strUserName,strUserPassword,strLogin,strApplicationPath){
	var strURLValue = document.forms[0].hidCurrentURL.value;
	if(strLogin=='1')					
	{		
		//setCookie('MediaRoomLogin',strUserName, 365,strApplicationPath) 
		//setCookie('MediaRoomPassword',strUserPassword, 365,strApplicationPath) 	
	}
		document.forms[0].action=strURLValue;
		document.forms[0].submit();
}


//For Registration Page
function SwitchPosition(){
var cmbPositionType = getObj("cmbPosition","2")
var txtOtherPositionType = getObj("txtOtherPosition","1")
		if (cmbPositionType.value == '0'){
				txtOtherPositionType.disabled = false;
			}
		else {
			txtOtherPositionType.value ='';
			txtOtherPositionType.disabled = true;
		}
		return false;
	}
/*function SwitchState(iUserType){
	var objStateDiv;
	var explorer=false;
	var netscape = false;
	var mac=false;
	var iUSid = 1;  
	var browser=navigator.userAgent;
	var cmbCountryType = getObj("cmbCountry","2")
	iUSid = cmbCountryType[1].value;
	if(browser.indexOf('Mac')>0)
		mac=true;
		
	if(browser.indexOf('MSIE')>0)
		explorer = true;
	else
		netscape = true;
		if (cmbCountryType.value == iUSid){
				showElement(getElement('spanSelState'));
				showElement(getElement('spanStateLabel'));
				hideElement(getElement('spanTxtState'));
			}
		else {
				objStateDiv = getElement('spanTxtState');
				showElement(getElement('spanTxtState'));
				hideElement(getElement('spanStateLabel'));
				hideElement(getElement('spanSelState'));
				if (mac && netscape)
				{
					if (iUserType == 1)
					{
						objStateDiv.style.top = "600px";
					}
					else if (iUserType == 2)
					{
						objStateDiv.style.top = "610px";
					}
					else if (iUserType == 11)
					{
						objStateDiv.style.top = "540px";
					}
					else
					{
						objStateDiv.style.top = "540px";
					}
				}
				else
				if (mac && explorer)
				{
					if (iUserType == 1)
					{
						objStateDiv.style.top = "580px";
					}
					else if (iUserType == 2)
					{
						objStateDiv.style.top = "590px";
					}
					else if (iUserType == 11)
					{
						objStateDiv.style.top = "520px";
					}
					else
					{
						objStateDiv.style.top = "520px";
					}
				}
				else								
				if (netscape)
				{
					if (iUserType == 1)
					{
						objStateDiv.style.top = "642px";
					}	
					else if (iUserType == 2)
					{
						objStateDiv.style.top = "642px";
					}	
					else if (iUserType == 11)
					{
						objStateDiv.style.top = "617px";
					}	
					else
					{
						objStateDiv.style.top = "617px";
					}
				}
			}
		return false;
	}		
*/
	function showElementMac(e)
	{ 
		e.style.display='block';
	}

	function hideElementMac(e)
	{
		e.style.display='none';
	}
	// Added For Compatiblity with mac	

	function SwitchState(){
		var mac=false;
		var browser=navigator.userAgent;
		var explorer=false;
		var netscape=false;		
		var iUSid = 1;  
		var cmbCountryType = getObj("cmbCountry","2")
		iUSid = cmbCountryType[1].value;
	
		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
		
		
		var objtxtState = getObj("txtState","2");				
		var objSelState = getObj("cmbSelState","2");				
		var objSelCountry = getObj("cmbCountry","2");				
		
		if (netscape)
		{
			objtxtState.style.width="159px";
			objSelState.style.width="159px";
			objSelCountry.style.width="159px";
		}
				
		
		var e1 =  document.getElementById("div1");				
		var e = document.getElementById("div2");				

		if (cmbCountryType.value == -1 || cmbCountryType.value == iUSid){
			if(mac && explorer){
				hideElementMac(e1);
				showElementMac(e);
			}
			else					
			{
				e1.style.display ='none';																	
				e.style.display ='';
			}					
		}
		else
		{
			if(mac && explorer){
				hideElementMac(e);
				showElementMac(e1);						
			}
			else
			{				
				e.style.display ='none';									
				e1.style.display ='';
			}										
		}
			
	}


function SwitchStateRegistration(){
		var mac=false;
		var browser=navigator.userAgent;
		var explorer=false;
		var netscape=false;		
		var iUSid = 1;  
		var cmbCountryType = getObj("cmbCountry","2")
		iUSid = cmbCountryType[1].value;
	
		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
		
		
		var objtxtState = getObj("txtState","2");				
		var objSelState = getObj("cmbSelState","2");				
		var objSelCountry = getObj("cmbCountry","2");				
		
		if (netscape)
		{
			objtxtState.style.width="159px";
			objSelState.style.width="127px";
			objSelCountry.style.width="127px";
		}
				
		
		var e1 =  document.getElementById("div1");				
		var e = document.getElementById("div2");				

		if (cmbCountryType.value == -1 || cmbCountryType.value == iUSid){
			if(mac && explorer){
				hideElementMac(e1);
				showElementMac(e);
			}
			else					
			{
				e1.style.display ='none';																	
				e.style.display ='block';
			}					
		}
		else
		{
			if(mac && explorer){
				hideElementMac(e);
				showElementMac(e1);						
			}
			else
			{				
				e.style.display ='none';									
				e1.style.display ='block';
			}										
		}
		hideElementMac(e1);
		//showElementMac(e);			
	}
		
function CheckTab(event,mode){
	//var objFrm = window.document.frmAddFreelancerRegistration;
	var txtFirstNameType = getObj("txtFirstName","1")
	var txtOtherOrgnizationNameType = getObj("txtOtherOrgnizationName","1")
	var txtYourdepartmentType = getObj("txtYourdepartment","1")
	var cmbCountryType = getObj("cmbCountry","2")
	var cmbSelStateType = getObj("cmbSelState","2")
	var txtPostalCodeType = getObj("txtPostalCode","1")
	var txtStateType = getObj("txtState","1")
	var cmbMediaTypeType = getObj("cmbMediaType","2")
		if (NS4)
			code = event.which;
		else
			code = event.keyCode;
		if(code==9)
			{
				if(mode==1){
						txtFirstNameType.focus();
						return false;
				}else if(mode==2){
						txtOtherOrgnizationNameType.focus();
						return false;			
				}else if(mode==4){
//						objFrm.btnReset.focus();
						return false;
				}else if(mode==5){
						txtYourdepartmentType.focus();
						return false;
				}else if(mode==6){
					iCountry = cmbCountry[cmbCountry.selectedIndex].value
					if (iCountry == iUSid)
					{
						if (cmbSelStateType.selectedIndex==0)
							{
								cmbSelStateType.focus();
								return false;
							}
						else
							{
								txtPostalCodeType.focus();
								return false;
							}
					}
					else
					{
						txtStateType.focus();
						return false;
					}
				}else if(mode==7){
					txtPostalCodeType.focus();
					return false;
				}else if(mode==8){
					cmbMediaTypeType.focus();
					return false;
					//objFrm.txtUrlWebAddress.focus();
					//return false;
				}
		}else
		{
			return true;
		}
	}
	
function validateForm(strMode,iUserType)
	{		
		var iUSid = 1;  
		var txtEmailType = getObj("txtEmail","1")
		var txtPasswordType = getObj("txtPassword","1")
		var txtVerifyPasswordType = getObj("txtVerifyPassword","1")
		var txtFirstNameType = getObj("txtFirstName","1")
		var txtLastNameType = getObj("txtLastName","1")
		var cmbPositionType = getObj("cmbPosition","2")
		var txtOtherPositionType1 = getObj("txtOtherPosition1","1")
		var txtOtherPositionType = getObj("txtOtherPosition","1")
		var txtTelephoneType = getObj("txtTelephone","1")
		var txtTelephoneType1 = getObj("txtTelephone1","1")
		var txtFaxType = getObj("txtFax","1")
		var txtAddress1Type = getObj("txtAddress1","1")
		var txtAddress2Type = getObj("txtAddress2","1")
		var txtAddress3Type = getObj("txtAddress3","1")
		var cmbCountryType = getObj("cmbCountry","2")
		var cmbSelStateType = getObj("cmbSelState","2")
		var txtStateType = getObj("txtState","1")
		var txtCityType = getObj("txtCity","1")
		var txtPostalCodeType = getObj("txtPostalCode","1")
		var txtOtherOrgnizationNameType = getObj("txtOtherOrgnizationName","1")
		var cmbMediaTypeType = getObj("cmbMediaType","2")
		var cmbTVFormatType = getObj("cmbTVFormat","2")
		var txtYourdepartmentType = getObj("txtYourdepartment","1")
		var txtUrlWebAddressType = getObj("txtUrlWebAddress","1")
		var cmbHearAboutUsType = getObj("cmbHearAboutUs","2")
		var txtHearAboutUsType = getObj("txtHearAboutUs","1")
		var txtRemarksType = getObj("txtRemarks","1")
		//alert(txtRemarksType)
		//if (isBlank(txtRemarksType,'Remarks')) return false;
		
		iUSid = cmbCountryType[1].value;
		//skip validations if already validated
		
		//if (window.document.forms[0].hidValidate.value == '1') return true;
		//var objFrm;
		//objFrm = eval('window.document.'+FormName)
		//objFrm = window.document.forms[0]
		
		if (strMode == 'ADD')
		{
			if (!isEmail(txtEmailType,'Email Address'))return false;
			if (isBlank(txtPasswordType,'Password')) return false;
			if (txtPasswordType.value.length<4)
			{
				alert('Please enter password more than 3 characters');
				txtPasswordType.focus();
				return false;
			}
		
			if (isBlank(txtVerifyPasswordType,'Verify Password')) return false;
			if(trimtxt(txtVerifyPasswordType) == '')
			{
				alert("Please verify your password.");
				txtVerifyPasswordType.focus();
				return false;
			}
    		if (txtPasswordType.value !== txtVerifyPasswordType.value)
			{
				alert('Verify Password and Password should be same');
				txtPasswordType.focus();
				return false;
			}
		}
		
		if (isBlank(txtFirstNameType,'First Name'))return false;
		if (!isAlpha(txtFirstNameType,'First Name')) return false;
		if (isQuotes(txtFirstNameType,/*b*/'First Name'/*e*/,'1')) return false;
		
		if (isBlank(txtLastNameType,'Last Name')) return false;
		if (!isAlpha(txtLastNameType,'Last Name')) return false;
		if (isQuotes(txtLastNameType,/*b*/'Last Name'/*e*/,'1')) return false;
		
		
		/*Check For Position*/
		if(typeof cmbPositionType == 'object')
		{
			if (cmbPositionType.selectedIndex==0)
			{
				alert('Please Select Position');
				cmbPositionType.focus();
				return false;
			}else
			{
				if(cmbPositionType.selectedIndex==1)
				{
					if (isBlank(txtOtherPositionType,'Other Position')) return false;
					if (isQuotes(txtOtherPositionType,/*b*/'Other Position'/*e*/,'1')) return false;
				}
			}
		}
		else
		{
			if (isBlank(txtOtherPositionType1,'Position')) return false;
		}
		
		if(typeof(txtTelephoneType) == 'object')
		{
			if(isBlank(txtTelephoneType,'Telephone number')) return false;
			if(!isTelePhone(txtTelephoneType,'Telephone number')) return false;
		}
		else
		{
			if(isBlank(txtTelephoneType1,'Telephone number')) return false;
			if(!isTelePhone(txtTelephoneType1,'Telephone number')) return false;
		}
		
		
		/*if(isBlank(objFrm.txtFax,'Fax')) return false;*/
		
		
		if(trimtxt(txtAddress1Type) == '')
		{
			alert("Address is required. \nPlease enter an Address.");
			txtAddress1Type.focus();
			return false;
		}
		if (isQuotes(txtAddress1Type,/*b*/'Address'/*e*/,1)) return false;
		
		if (isQuotes(txtAddress2Type,/*b*/'Address'/*e*/,1)) return false;
		//if (isQuotes(txtAddress3Type,/*b*/'Address'/*e*/,1)) return false;
				if (cmbCountryType.selectedIndex==0)
		{
			alert('Please Select Country');
			cmbCountryType.focus();
			return false;
		}
		
		iCountry = cmbCountryType[cmbCountryType.selectedIndex].value
		if (iCountry == iUSid)
		{
			if (cmbSelStateType.selectedIndex==0)
			{
				alert('Please Select State');
				cmbSelStateType.focus();
				return false;
			}	
		}
		else
		{				
			/*if (isBlank(objFrm.txtState,'State')) return false;
			if (isQuotes(txtStateType,'State',1)) return false;
			if (trimtxt(txtStateType.value) != '') 
			{
				if (!isAlpha(txtStateType,'State')) return false;
			}*/
		}
		
		
		if (isQuotes(txtStateType,'State',1)) return false;
		if (trimtxt(txtStateType.value) != '') 
		{
			if (!isAlpha(txtStateType,'State')) return false;
		}
		
					
		if (isBlank(txtCityType,'City')) return false;
		if (isQuotes(txtCityType,'City',1)) return false;
		/*if (trimtxt(objFrm.txtCity.value) != '') 
		{
			if (!isAlpha(objFrm.txtCity,'City')) return false;
		}*/
		
		
				/*if(isBlank(objFrm.txtPostalCode,'Postal Code'))	return false;*/
		if(trimtxt(txtPostalCodeType) != '') 
		{
			if(isQuotes(txtPostalCodeType,'Postal Code',1))	return false;
			else if(!isName(txtPostalCodeType,'PostalCode',0,10,0)) return false;			
		}				
		
				//Changed for Organization Name - Start
		//if (isBlank(objFrm.txtOtherOrgnizationName,'Organization Name')) return false;
		if(trimtxt(txtOtherOrgnizationNameType) == ''){
			alert("Please enter an Organization Name.");
			txtOtherOrgnizationNameType.focus();
			return false;
		}
		if (isQuotes(txtOtherOrgnizationNameType,'Organization Name','1')) return false;
		//Changed for Organization Name - Stop
		
		if ((iUserType == 1) || (iUserType == 2))
		{
			if (cmbMediaTypeType.selectedIndex == 0)
			{
				alert('Please Select Media Type');
				cmbMediaTypeType.focus();
				return false;
			}
			
			//Added : 31/01/2003 : Start
			//Enforce selection of Video Standard if media type is 'TV'
			var MediaType = cmbMediaTypeType[cmbMediaTypeType.selectedIndex].text;
			if (MediaType.toUpperCase() == 'TV')
			{	
				if(typeof(cmbTVFormatType) =='object')
				{
					if (cmbTVFormatType.selectedIndex==0)
					{
						alert('Please Select Video Standard');
						cmbTVFormatType.focus();
						return false;
					}
				}
			}
		}
		/*if ((iUserType == 1) || (iUserType == 2) || (iUserType == 6))
		{
			if (trimtxt(txtYourdepartmentType) != '') 
			{
				if (!isAlpha(txtYourdepartmentType,'Your department')) return false;
				if (isQuotes(txtYourdepartmentType,'Your department','1')) return false;
			}
		}*/
		
		//if ((iUserType == 1) || (iUserType == 2) || (iUserType == 7 ) || (iUserType == 11))
		//{
			/*if (isBlank(objFrm.txtUrlWebAddress,'Web Address')) return false;*/
			if (isQuotes(txtUrlWebAddressType,/*b*/'Web Address'/*e*/,1)) return false;
		//}
		
		if(typeof(cmbHearAboutUsType) =='object')
		{
			if (cmbHearAboutUsType[cmbHearAboutUsType.selectedIndex].value== 7)
				if (isBlank(txtHearAboutUsType,'How did you find about us?')) return false;
			if (isQuotes(txtHearAboutUsType,/*b*/'How did you find about us?'/*e*/,1)) return false;
			if (!checkLength(txtHearAboutUsType,60,/*b*/'How did you find about us?'/*e*/)) return false;	
		}
		
		//if (isBlank(objFrm.flUpload,'Distribution File')) return false;
		if (isBlank(txtRemarksType,'Remarks')) return false;
		if (iUserType != 6)
		{
			if (isQuotes(txtRemarksType,/*b*/'Remarks'/*e*/,1)) return false;
			if (!checkLength(txtRemarksType,500,/*b*/'Remarks'/*e*/)) return false;	
		}
		//alert("done");
		/*alert('Your registration with The NewsMarket is now in progress.  \nWe will be in touch with you to either verify some information, or will directly approve you for full usage rights on the site. \nIn the meantime, your membership with the site is temporary.  \nYou can start ordering media materials from us now, but these orders will be on hold for fulfillment/delivery when your approval is complete.') ;*/
		//window.document.forms[0].hidValidate.value = '1';
		//submitThisPage();
}

function save_search_check(iUserType)
{
	var iUSid = 1;  
	var txtEmailType = getObj("txtEmail","1")
	var txtCurrentPasswordType = getObj("txtCurrentPassword","1")
	var txtPasswordType = getObj("txtPassword","1")
	var txtVerifyPasswordType = getObj("txtVerifyPassword","1")
	var txtFirstNameType = getObj("txtFirstName","1")
	var txtLastNameType = getObj("txtLastName","1")
	var cmbPositionType = getObj("cmbPosition","2")
	var txtOtherPositionType = getObj("txtOtherPosition","1")
	var txtTelephoneType = getObj("txtTelephone","1")
	var txtFaxType = getObj("txtFax","1")
	var txtAddress1Type = getObj("txtAddress1","1")
	var txtAddress2Type = getObj("txtAddress2","1")
	var txtAddress3Type = getObj("txtAddress3","1")
	var cmbCountryType = getObj("cmbCountry","2")
	var cmbSelStateType = getObj("cmbSelState","2")
	var txtStateType = getObj("txtState","1")
	var txtCityType = getObj("txtCity","1")
	var txtPostalCodeType = getObj("txtPostalCode","1")
	var txtOtherOrgnizationNameType = getObj("txtOtherOrgnizationName","1")
	var cmbMediaTypeType = getObj("cmbMediaType","2")
	var cmbTVFormatType = getObj("cmbTVFormat","2")
	var txtYourdepartmentType = getObj("txtYourdepartment","1")
	var txtUrlWebAddressType = getObj("txtUrlWebAddress","1")
	var cmbHearAboutUsType = getObj("cmbHearAboutUs","2")
	var txtHearAboutUsType = getObj("txtHearAboutUs","1")
	var txtRemarksType = getObj("txtRemarks","1")
	

	if(isBlank(txtEmailType,"Email Id")) return false;
	if(!isEmail(txtEmailType, "Email Id"))return false;
	if(isBlank(txtAddress1Type,'Address')) return false;
	if(isQuotes(txtAddress1Type,'Address',1)) return false;
	
	if(txtCurrentPasswordType.value.length>0)
	{
   		if(txtCurrentPasswordType.value.length < 4)
 		{
 			alert("Please enter password more than 3 characters");
 			txtCurrentPasswordType.focus();
 			return false;
 		}
 					
 		if(isBlank(txtPasswordType,'New Password')) return false;
 		 if(txtPasswordType.value.length < 4)
 		{
 			alert("Please enter new password with more than 3 characters");
 			txtPasswordType.focus();
 			return false;
 		
 		}
 		if(isBlank(txtVerifyPasswordType,'Verify Password')) return false;
		if(txtPasswordType.value!= txtVerifyPasswordType.value)
		{	
			alert('Verify Password and Password should be same');
			txtVerifyPasswordType.focus();
			return false;
		}
	}

	if(txtVerifyPasswordType.value.length>0)
	{
   		if(isBlank(txtCurrentPasswordType,'Current Password')) return false;
   		if(isBlank(txtPasswordType,'New Password')) return false;
	}
	
	
	if(iUserType!=6)
	{
		var selValue = cmbPositionType.options[cmbPositionType.selectedIndex].value;		     
		if(selValue=="0")
		{
			if (isBlank(txtOtherPositionType,"Position"))return false;
 			if (!isAlpha(txtOtherPositionType,"Position"))return false;
		}
		else if(selValue=="--Select--")
		{
			alert("Position is required.Please select a postion.");
			return false;
		}
	}
	else
	{
		
		if (isBlank(txtOtherPositionType,'Title')) return false;
		if (isQuotes(txtOtherPositionType,'Title',1)) return false;
		if(!isAlpha(txtOtherPositionType,'Title'))return false;
	}
	 			
	if(isBlank(txtTelephoneType,'Telephone number')) return false;
	if(!isTelePhone(txtTelephoneType,'Telephone number')) return false;
	if(isQuotes(txtFaxType,'Fax Number',1)) return false;	
 	if(isQuotes(txtAddress2Type,'Address',1)) return false;
 	if(isQuotes(txtAddress3Type,'Address',1)) return false;
 				
 	if(txtPostalCodeType.value.length>0)
 	{
		if(isQuotes(txtPostalCodeType,'Postal Code',1))	return false;
		else if(!isName(txtPostalCodeType,'PostalCode',0,10,0)) return false;
	}
	 			
	if(isQuotes(txtCityType,'City',1)) return false;
    if(typeof txtStateType == 'object')
	{
		if(txtStateType.visible)
		if(!isAlpha(txtStateType,"State/Province"))return false;
	}
				
	if(cmbCountryType[cmbCountryType.selectedIndex].value ==200) 
	{
		if(cmbSelStateType.selectedIndex == 0)
		{
			alert("Please select a State/Province")
			cmbSelStateType.selectedIndex=0;
			return false;
		} 
	}

	if(cmbCountryType.selectedIndex == 0)
	{
		alert("Please select a Country")
		return false;
	}
	return true;      
}
function EnableLstTVFormat()
{
	var MediaType = getObj("cmbMediaType","2") 
	var TvFormat = getObj("cmbTVFormat","2")
	
	if (MediaType[MediaType.selectedIndex].text.toUpperCase() == 'TV')
	{	
		showElement(getElement('spanTVFormat'));
	}
	else 
	{
		TvFormat[0].selected = true;
		hideElement(getElement('spanTVFormat'));
	}
	return false;
}

//For StoryListing Page.
function ValidateUserForCart(AssetCount,storyAssetId,Id,iUserType,mstrUserStatus,PreApproved,IsTNMCartAllowed,CallingPage,FromWhere,ApplicationName,StoryAssetGUID,strServername)
{
	if(IsTNMCartAllowed.toUpperCase()=='TRUE'){
		IsTNMCartAllowed = '1';
	}else{
		IsTNMCartAllowed = '0';
	}
	var objFrm = window.document.forms[0];
	
	if(FromWhere == 'remove')
	{
		if(objFrm.hidRemovedAssetIDs.value.length > 0)
		{
			objFrm.hidRemovedAssetIDs.value = objFrm.hidRemovedAssetIDs.value + ',' + storyAssetId;
		}
		else
		{
			objFrm.hidRemovedAssetIDs.value = storyAssetId;
		}
		objFrm.hidRemoveClicked.value = "REMOVE";
		setPageNumberForRemoveCart();
	}

	if(Id=='0')
	{
		if(IsTNMCartAllowed=='0')
			{
				//document.forms[0].storyid.value=storyid;
				var strLink;
				
				if(CallingPage=='Story')
					strDefaultLink = "https://" + strServername + "/" + ApplicationName + '/br/Sample/SampleWrapperPage.aspx?hidIsCart=Y&hidStoryGUID='+StoryAssetGUID;
				else
					strDefaultLink = "https://" + strServername + "/" + ApplicationName + '/br/Sample/SampleWrapperPage.aspx?hidIsCart=Y&hidAssetGUID='+StoryAssetGUID;
				submitPageFE(strDefaultLink);					
				return false;
			}
			else 
			{
				if(CallingPage=='Story'){
					if(AssetCount=='0')
						{
							alert('There are no media assets associated with this story.'); 
							return false;	
						}
				}
			}
	}	
	else
	{
		if(mstrUserStatus == '4' && PreApproved =='0') //For New User
 		{
 			alert('Your registration is still in progress.\nYou will receive a notification when your registration is approved after which you will be allowed to order media.')
			return false;
 		}
 		if(iUserType=='8' || iUserType=='4')
		{
			alert("We're sorry, but this feature is only available to registered media journalists.\nYou are currently on a demonstration account and do not have rights to order any media assets.\nPlease send an email to mediarelations@thenewsmarket.com if you do need to order assets. Thank you.");
			return false;
		} 		
		if(CallingPage=='Story'){
			if(AssetCount==0)
			{
				alert('There are no media assets associated with this story.'); 
				return false;	
			}	
		}
	}
	return true;
}

function AddToClipping(Type,ItemId,UserId,ApplicationPath,StoryAssetGUID,strLink,strServername)
{
	strLink = escape(strLink+"&Clip=Y");
	if(UserId=='0')
	{
		if(Type=='1'){
			strDefaultLink = "https://" + strServername + "/" + ApplicationPath + '/br/Sample/SampleWrapperPage.aspx?hidURL='+strLink;
		}else{
			strDefaultLink = "https://" + strServername + "/" + ApplicationPath + '/br/Sample/SampleWrapperPage.aspx?hidURL='+strLink;
		}
		//"https://" + strServername + "/br/Sample/SampleWrapperPage.aspx?hidURL=" + strUrl +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		submitPageFE(strDefaultLink);
		return false;
	}
    else
    {
 		popupWin(ApplicationPath + '/br/Clippings/SelectClippingFolder.aspx?type='+Type+'&Id=' + ItemId,'600','310','yes');
 		return false;
	}
}

function TitleRedirect(strLink,Id,UserId,maxAssetsStoriesSearchValue,AccessRestriction,ApplicationName,CallingPage)
{	
	var isExceed;
	if (UserId == '0' && AccessRestriction=='True')
	{			
		if(CallingPage=='Story')
			isExceed=DoCookieStuff('stories_visited',maxAssetsStoriesSearchValue,ApplicationName);
		else
		{
			isExceed=DoCookieStuff('media_visited',maxAssetsStoriesSearchValue,ApplicationName); 
		}
//		alert(isExceed)
		if(isExceed==1)
		{
			/*if(CallingPage=='Story')
				strDefaultLink = ApplicationName + '/br/Sample/SampleStoryDetailPage.aspx';
			else
				strDefaultLink = ApplicationName + '/br/Sample/SampleAssetDetailPage.aspx';*/
				strDefaultLink = ApplicationName + '/br/Sample/SampleWrapperPage.aspx?hidURL='+strLink;
			submitPageFE(strDefaultLink);	
		}
		else
		{		
			submitPageFE(strLink);
		}				
		
	}
	else
	{			
		//document.forms[0].storyid.value=Id;												
		submitPageFE(strLink);
	}	
	return false;			
}
	
function GoToIntermediate(strLink,Id,UserId,maxAssetsStoriesSearchValue,AccessRestriction,ApplicationName,CallingPage)
{	
	strDefaultLink = ApplicationName + '/br/CommonPages/IntermediateCookieHandlingPage.aspx?hidURL=' + escape(strLink);
	submitPageFE(strDefaultLink);	
	return false;			
}

function AssetPopup(imgPath,type,AssetId,StoryId,sCurrentPage,iUserId,isBackEndUser,isN,ApplicationPath,IsPreviewEnabled,strLink,strServerName)
{	
	//'',1,209,'','',8449,false,'/MRBase'

	/*imgPath='';
	type=2;
	AssetId=8;
	StoryId=30;
	sCurrentPage=0;*/
	
	isBackEndUser=false;
	
	var BackEndUser=0;
			
	if(iUserId!=0 || BackEndUser == 1 || IsPreviewEnabled==1)
	{
		if(iUserId!=0)
			IsPreviewEnabled=0; 
			
		var file=imgPath;					
		var firstparam = '';
		
		if(file!='undefined')
		{
			if(type==3 || type==4)
			{
				//stills or docs					
				if(BackEndUser=='1')
				{
					firstparam=file;
				}
				else
				{
					firstparam = ApplicationPath + "/br/CommonPages/Intermediate.aspx?objBackTo:hidFromModule=FRONTEND&hdnPopup=yes&File=" + file + "&AssetId=" + AssetId + "&StoryId=" + StoryId + "&Caller=" + sCurrentPage+'&Type='+type + '&NonLoggedPreview=' + IsPreviewEnabled;
				}		
				
				if(type==3)
				{	
					if(!isBackEndUser) {
						//popup = window.open(firstparam,'','width=340,height=437,resizable=yes,scrollbars=no,menubar=yes','yes');
						popup = window.open(firstparam,'','width=540,height=520,resizable=yes,scrollbars=no,menubar=no','yes');
												popup.window.moveTo(342,164);
					}	
					else	{
						window.open(firstparam,'','width=340,height=440,resizable=yes','yes')
					}
				}
				else
				{	
					if(!isBackEndUser) {					
						if(isN) {
							if(imgPath !='')
								location.href = firstparam
							else
								popupWin(firstparam,'FULL','FULL','yes');
						}		
						else {
							pop = window.open(firstparam,'','resizable=yes,width='+screen.availWidth+',height='+screen.availHeight+',scrollbars=yes,menubar=yes','yes')
							pop.window.moveTo(0,0);														
						}
					}	
					else {
						window.open(firstparam,'','width=800,height=600','')
					}
				}			
			}
			else
			{
				//media
				var ext=file.substring(file.lastIndexOf(".")+1);									
				
				if(BackEndUser=='1')
				{
					
					//firstparam="../FrontEndCommonPages/MediaPreview.aspx?objBackTo:hidFromModule=FRONTEND&isBackEndUser=1&AssetId=" + AssetId + "~" +type+"&Id=" + file + "," + ext + ",270,290";
					firstparam = ApplicationPath + "/br/CommonPages/MediaPreview.aspx?objBackTo:hidFromModule=FRONTEND&isBackEndUser=1&AssetId=" + AssetId + "~" +type+"&Id=" + file + "," + ext + ",270,290";					
				}
				else
				{
					var secondparam="MediaPreview.aspx?Id=" + file + "," + ext + ",270,290";					
					//firstparam="../FrontEndCommonPages/Intermediate.aspx?objBackTo:hidFromModule=FRONTEND&isBackEndUser=0&hdnPopup=yes&Type=" + type + "&File=" + secondparam + "&AssetId=" + AssetId + "&StoryId=" + StoryId + "&Caller=" + sCurrentPage + '&NonLoggedPreview=' + IsPreviewEnabled;
					firstparam = ApplicationPath + "/br/CommonPages/Intermediate.aspx?objBackTo:hidFromModule=FRONTEND&isBackEndUser=0&hdnPopup=yes&Type=" + type + "&File=" + secondparam + "&AssetId=" + AssetId + "&StoryId=" + StoryId + "&Caller=" + sCurrentPage + '&NonLoggedPreview=' + IsPreviewEnabled;
				}				
				//popupWin(firstparam,'340','475','no');		
				
				if(!isBackEndUser) {
					popupWin(firstparam,'340','440','no','yes');		
				}	
				else {
					window.open(firstparam,'','width=340,height=440','yes')
				}	
			}				
		}
	}
	else
	{
		strLink = escape(strLink+"&Preview=Y");
		strLink= "https://" + strServerName + "/" + ApplicationPath +"/br/Sample/SampleWrapperPage.aspx?hidURL="+strLink;
		submitPageFE(strLink);
		return false;
	}
}

/*function windowResizeForImage(imageHeight,imageWidth)
{
	var windowHeight;
	var windowWidth;
	var hMargin = 55;
	var vMargin = 185;
	var vScreenMargin = 20;
	var currentWindowHeight = 440;
	var currentWindowWidth = 340;

	windowHeight = imageHeight + vMargin;
	windowWidth = imageWidth + hMargin;
	
	if (windowHeight >= screen.height)
		windowHeight = screen.height-vScreenMargin;
	if (windowWidth >= screen.width)
		windowWidth = screen.width;

	if (windowWidth < currentWindowWidth)
		windowWidth = currentWindowWidth;

	window.resizeTo(windowWidth,windowHeight);
	window.moveTo(screenLeft(windowWidth),screenTop(windowHeight));
			
}*/

function windowResizeForPreviewImage()
{
	var windowHeight;
	var windowWidth;
	var hMargin = 55;
	var vMargin = 207;
	var vScreenMargin = 20;
	var currentWindowHeight = 440;
	var currentWindowWidth = 340;
	if(typeof(window.document.forms[0].imgPreview) == 'undefined') 
	{
		windowHeight = 35 + vMargin;
		windowWidth = 295 + hMargin;
	}
	else
	{
		windowHeight = window.document.forms[0].imgPreview.height + vMargin;
		windowWidth = window.document.forms[0].imgPreview.width + hMargin;
	}
	
	if (windowHeight >= screen.height)
		windowHeight = screen.height-vScreenMargin;
	if (windowWidth >= screen.width)
		windowWidth = screen.width;

	if (windowWidth < currentWindowWidth)
		windowWidth = currentWindowWidth;

	window.resizeTo(windowWidth,windowHeight);
	window.moveTo(screenLeft(windowWidth),screenTop(windowHeight));
			
}

function screenLeft(width)
{
	return (screen.width - width)/2 ;
}
function screenTop(height)
{
	return ((screen.height - height)/2) - 10 ;
}
function fSave()
{
	var objFrm = window.document.forms[0];
	objFrm.hidSaveClicked.value='1';
	return true;
}

function fYes()
{
	var objFrm = window.document.forms[0];
	objFrm.hidYesClick.value='yes';
	return true;
}

function fClose(miDispError,strMRserverPath,strAssetId,strAssetType,IdValue,fromwhere,iUserid)
{
	var objFrm = window.document.forms[0];	
	//miDispError = 5 --->preference is null
	if(iUserid != 0)
	{
		if(miDispError == 5)
		{
			if(objFrm.hidSaveClicked.value=='')
			{
				var iPreview;
				/*if (objFrm.radWMPOption.checked)
				{
					iPreview = 9;
				}
				if (objFrm.radQTOption.checked)
				{
					iPreview = 10;
				}*/
				var strAssetIdType = strAssetId +'~' + strAssetType;
				iPreview=9;
				var firstparam = strMRserverPath + '/br/CommonPages/MediaPreview.aspx?NonLoggedPreview=0&AssetId=' + strAssetIdType + '&id='+ IdValue + ',,270,290' +'&preference=' + iPreview + '&FromClose=1';					
				pop=window.open(firstparam,'preview','width=340,height=440'); 
				pop.window.moveTo(342,164);
			}
			else
			{
				return true;
			}
		}
		else
		{
			if(fromwhere=="Yes")
			{
				window.close();
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
		window.close();	
	}
}

function goRegistration()
{
	if(!window.opener.closed)
	{
		window.opener.document.forms[0].action=  "../../br/Login/LoginPreRegistration.aspx";
		window.opener.document.forms[0].submit();
		window.close();	
	}
	else
	{
		window.open(strMRserverPath + '../../br/Login/LoginPreRegistration.aspx','','');
		window.close();	
	}
}


function ValidateEmail()
{
	var objFrm = window.document.forms[0];
	var objUserEmailId = getObj("txtUserEmailId",1);
	
	objFrm.hidSubmitAction.value = "true";
	strTextString = trimtxt(objUserEmailId.value);
			
	if (strTextString == "")
	{
		alert ('Email is required.\nPlease enter an Email-address');
		return false;
	}
	
	if(!isEmail(objUserEmailId,"Email address"))
		return false;
}
function goToSite()
{			
	window.opener.document.forms[0].action= "../../br/Login/LoginPreRegistration.aspx";
	window.opener.document.forms[0].submit();
	window.close();
}

function StartTimer()
{
	setTimeout("window.close()", 5000);
}

function TransferToSamplePage(type,strhttphost,strservername,strPortNumber,strMRserverPath,strURL,strCart,strStoryGUID,strAssetGUID)
{
	strURL = escape(strURL);
	var strLink;		
	if(type==1)
	{
		if(strhttphost = strservername)
		{
			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleSearchResultPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
		else
		{
			strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleSearchResultPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
	}
	if(type==2)
	{
		if(strhttphost = strservername)
		{
			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleNonLoggedUserClipDefaultPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}			
		else
		{	
			strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleNonLoggedUserClipDefaultPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
	}
	if(type==3)
	{
		if(strhttphost = strservername)
		{
			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleAssetDetailPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
		else
		{
			strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleAssetDetailPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
	}
	if(type==4)
	{
		if(strhttphost = strservername)
		{
			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleStoryDetailPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
		else
		{
			strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleStoryDetailPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
	}
	if(type==5)
	{
		if(strhttphost = strservername)
		{
			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleNonLoggedCartControlPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
//			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleNonLoggedCartControlPage.aspx?hidIsCart=Y&hidURL=" + strURL;
		}
		else
		{
			//strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleNonLoggedCartControlPage.aspx?hidURL=" + strURL;
			strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleNonLoggedCartControlPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
	}
	if(type==6)
	{
		if(strhttphost = strservername)
		{
			strLink = "http://" + strhttphost + strPortNumber + strMRserverPath + "/br/Sample/SampleDefaultPreviewPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
		else
		{
			strLink = "http://" + strhttphost + strMRserverPath + "/br/Sample/SampleDefaultPreviewPage.aspx?hidURL=" + strURL +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
		}
	}
	submitPageFE(strLink);
	return false;
}

function LoginFromSample(mode,strServername,strUrl,strCart,strStoryGUID,strAssetGUID)
{	
	strUrl = escape(strUrl);
	var sLink = "https://" + strServername + "/br/Sample/SampleWrapperPage.aspx?hidSamplemode=" + mode + "&hidURL=" + strUrl +"&hidIsCart="+ strCart +"&hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID;
//	var sLink = "https://" + strServername + "/br/Sample/SampleWrapperPage.aspx" + strQueryString + "&hidFromMastHead=1&mode=" + mode +"&hidURL=" +strUrl;
	submitPageFE(sLink);
	return false;
}

function submitSamplePage(strLink)
{			
	//submitPageFE(strLink + strQueryString);
	var strStoryGUID,strAssetGUID,strIsCart,strURL;
	strStoryGUID = document.forms[0].hidStoryGUID.value;
	strAssetGUID = document.forms[0].hidAssetGUID.value;
	strIsCart = document.forms[0].hidIsCart.value;
	strURL = document.forms[0].hidURL.value;
	
	strLink= strLink + "?hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID + "&hidIsCart="+strIsCart + "&hidURL=" +escape(strURL);
	//strLink=escape(strLink);
	submitPageFE(strLink);
	return false;
}
//For Back TO
function SubmitPageBackTo(pagename,params,serverName,server,port , isHttps)
{	
	if (typeof document.forms[0].hidRemovedAssetIDs == 'object')	// tejas - to reset removedassetids
		{
			document.forms[0].hidRemovedAssetIDs.value = 0;
		}
	if (typeof document.forms[0].hidRemoveClicked == 'object') 
		{
			document.forms[0].hidRemoveClicked.value = '';
		}
	if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
	var sLink = '';
	var strlocation= window.location.href;
	strlocation = strlocation.toUpperCase();
	var ipPattern = 'HTTPS:';
	var ipArray = strlocation.match(ipPattern); 
	
	if(ipArray=='HTTPS')
		sLink = "https://" + server;
	else
	{
		if (serverName == server)
		{
			sLink = "http://" + serverName + port;
		}
		else
		{
			sLink = "http://" + serverName;
		}
	}
	var isSamplePage  = -1

	if (params != '')
	{
		isSamplePage = params.indexOf("hidURL");
	}
	
	
	
	if(isSamplePage!=-1)
	{
		params = escape(params);
	}
	
	window.document.forms[0].action = sLink + pagename + '?Link=1' + '&' + params;	
	window.document.forms[0].hidReturnTo.value = '1';
	window.document.forms[0].submit();
	return true;		
}

//For Asset Details
function setTabAssetDetail(iSelectedIndex,iTabIndex)
{
	var objForm=eval(document.forms[0]); 
	objForm.hidSelectedTab.value = iSelectedIndex; //Actuall Tab Selected
	objForm.hidTabIndex.value = iTabIndex; //TAb Position.
	//objForm.hidPageNum.value = '1'; // Page Number
	//objForm.hidAssetTypeChanged.value = "true"; //For Asset Control	
	//objForm.hidAssetTypeSelected.value = iSelectedIndex;
	if(typeof objForm.hidAddCart == 'object')
	{
		objForm.hidAddCart.value = '0';
	}
	
	objForm.submit();
}

function DefaultPreviewAssetDetail(strLink,strHost,strServerPath)
{	
	strLink = escape(strLink+"&Preview=Y");
	var sLink = "https://" + strHost + strServerPath + "/br/Sample/SampleWrapperPage.aspx?hidURL="+strLink;
	submitPageFE(sLink);
	return false;
}

function openDocAssetDetail(path)
{
	window.open(path,'','resizable=yes,width='+screen.availWidth+',height='+screen.availHeight+',scrollbars=yes,menubar=yes','yes');
}

function openDocStillAssetDetail(path){
	//location.href=path;
	window.open(path,'','resizable=yes,width='+screen.availWidth+',height='+screen.availHeight+',scrollbars=yes,menubar=yes','yes');
	return false;
}

function AddToClippingsAssetDetail(strAssetId , strUserId , strServerAbsolute , strServer ,strAssetGUID,strLink)
{	
	var AssetId = strAssetId ;
	strLink = escape(strLink+"&Clip=Y");
	if (strUserId == '0')
	{
		//var sLink = "https://" + strServerAbsolute + strServer + "/br/Sample/SampleWrapperPage.aspx?Clip=Y&hidAssetGUID=" + strAssetGUID;	
		var strType;
		var sLink = "https://" + strServerAbsolute + strServer + "/br/Sample/SampleWrapperPage.aspx?hidURL="+strLink +"&type=2&Id=" + strAssetId;
		submitPageFE(sLink);							
		return false;
	}
	popupWin(strServer + '/br/Clippings/SelectClippingFolder.aspx?type=2&Id=' + strAssetId,'600','310','yes');
	return false;
	
}

function AddToCartAssetDetail(strAssetId , strUserID , strServerAbsolutePath, strServer, IsTNMCartAllowed , strUserStatus , iUserType , strAssetGUID)
{	
	var strLink;
	if (strUserID == '0')
	{
		if(IsTNMCartAllowed == 0)
		{
			//strLink = "https://" + strServerAbsolutePath + strServer + "/br/Sample/SampleWrapperPage.aspx?Cart=Y&hidAssetGUID=" + strAssetGUID;
			strLink = "https://" + strServerAbsolutePath + strServer + "/br/Sample/SampleWrapperPage.aspx?hidIsCart=Y&hidAssetGUID=" + strAssetGUID;
			submitPageFE(strLink);
			return false;
		}
		else
		{	
			//non - logged add to cart functionality
		}
	}
	else
	{
		if(IsTNMCartAllowed!=1)
		{
			if(strUserStatus == 4) //For New User
			{
				alert('Your registration is still in progress.\nYou will receive a notification when your registration is approved after which you will be allowed to order media.')
				return false;
			}
		}
		if(iUserType==8 || iUserType==4)
		{
			//Bizdev user		 			
			alert("We're sorry, but this feature is only available to registered media journalists.\nYou are currently on a demonstration account and do not have rights to order any media assets.\nPlease send an email to mediarelations@thenewsmarket.com if you do need to order assets. Thank you.");
			return false;				
		} 				
	}
	window.document.forms[0].hidAddCart.value = '1';
}

//For Asset Detail
//For Asset Detail
function MoveRestrictionImage()
{
	var netscape = false;
	var mac=false;
	var browser=navigator.userAgent;
	var os = navigator.platform;

	if(browser.indexOf('Mac')>0)
		mac=true;
	if(browser.indexOf('MSIE')>0)
		explorer = true;
	else
		netscape = true;
		
	var aLyrs = document.getElementsByTagName("DIV")
	if (typeof aLyrs == 'object')
	{
		for (var i=0; i<aLyrs.length; i++)
		{
			if (aLyrs[i].id.toUpperCase()== 'IMGRESTRICTIONDIV')
			{
				aLyrs[i].style.top = "151px" ;
				if (mac && netscape) 
					aLyrs[i].style.left = "0px" ; 
				else if(explorer)
					aLyrs[i].style.left = "3px"	;			
			}
		}
	}
}


//For Asset Listing Move Div as well as Image
function MoveRestrictionImageAssetListing()
{
		var netscape = false;
		var mac=false;
		var browser=navigator.userAgent;
		var os = navigator.platform;

		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
		
		var aLyrs = document.getElementsByTagName("DIV")
		
		if (typeof aLyrs == 'object')
		{
			for (var i=0; i<aLyrs.length; i++)
			{
				if (aLyrs[i].id.toUpperCase()== 'IMGRESTRICTIONDIV' || aLyrs[i].id.toUpperCase()=='TITLEDESCDIV')
				{
					aLyrs[i].style.top = "-17px"
					if (mac && netscape) aLyrs[i].style.left = "-2px"
				}
			}
		}
}	

function LoadClipAssetDetail(strAssetId, serverpath , strAssetGUID)
{
	var ItemId;
	ItemId=strAssetId
	popupWin(serverpath + '/br/Clippings/SelectClippingFolder.aspx?type=2&Id=' + ItemId,'600','310','yes');
 	return false;				
}

function LoadPreviewAssetDetail(strAssetId , strAssetTypeId , strStoryId ,strUserId , strFilePath , isN , serverpath, strAssetGUID)
{							
	var type=strAssetTypeId;
	var AssetId=strAssetId;
	var StoryId=strStoryId;				
	var sCurrentPage='SamplePage';
	var iUserId= strUserId;	 
	var IsPreviewEnabled=0; 			
	var file= strFilePath;					
	var firstparam;
	var imgPath;						
	if(file!='undefined')
	{
		if(type==3 || type==4)
		{						
			firstparam = serverpath + "/br/CommonPages/Intermediate.aspx?hidFromModule=FRONTEND&hdnPopup=yes&File=" + file + "&AssetId=" + AssetId + "&StoryId=" + StoryId + "&Caller=" + sCurrentPage+'&Type='+type + '&NonLoggedPreview=' + IsPreviewEnabled;
			if(type==3)
			{	
				popup = window.open(firstparam,'','width=340,height=440,resizable=yes,scrollbars=yes,menubar=yes','yes');
				popup.window.moveTo(342,164);					
			}
			else
			{				
				if (isN = 'true')
				{
					//if(imgPath !='')
					//	location.href = firstparam
					//else
						popupWin(firstparam,'FULL','FULL','yes');
				}		
				else
				{
					pop = window.open(firstparam,'','resizable=yes,width='+screen.availWidth+',height='+screen.availHeight+',scrollbars=yes,menubar=yes','yes')
					pop.window.moveTo(0,0);																					
				}
			}			
		}
		else
		{	
			var ext=file.substring(file.lastIndexOf(".")+1);													
			var secondparam=serverpath + "/br/CommonPages/Intermediate.aspx?Id=" + file + "," + ext + ",270,290";					
			firstparam= serverpath + "/br/CommonPages/Intermediate.aspx?hidFromModule=FRONTEND&isBackEndUser=0&hdnPopup=yes&Type=" + type + "&File=" + secondparam + "&AssetId=" + AssetId + "&StoryId==" + strStoryId + "&Caller=" + sCurrentPage + '&NonLoggedPreview=' + IsPreviewEnabled;
			popupWin(firstparam,'340','440','no');		
		}
	}				
}

//For Story Details
function AddToCartStoryDetail(strStoryId,strUserId,strUserType,strUserStatus,strAssetCount, isTNMCartAllowed,strServerAbsolute, strServer,strStoryGUID)
{	
	if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
	var storyid=strStoryId;
	var usertype;
	var strLink;
	if (strUserId == '0') 
		usertype='1';
	else
		usertype='2';
			
		if (usertype == '2') 
		{
			if(strUserStatus == 4) //For New User
 			{
 				alert('Your registration is still in progress.\nYou will receive a notification when your registration is approved after which you will be allowed to order media.')
				return false;
 			}
 			if(strUserType==8 || strUserType==4)
			{
 				//Bizdev user		
 				alert("We're sorry, but this feature is only available to registered media journalists.\nYou are currently on a demonstration account and do not have rights to order any media assets.\nPlease send an email to mediarelations@thenewsmarket.com if you do need to order assets. Thank you.");
				return false;				
 			} 				
			if (strAssetCount == 0) 
			{
				alert('There are no media assets associated with this story.'); 
				return false;
			}
			window.document.forms[0].hidAddToCartStory.value = "1"
		}
		else
		{					
			if (strAssetCount == 0) 
			{
				alert('There are no media assets associated with this story.'); 
				return false;
			}
			if(isTNMCartAllowed == 0 )
			{
				//strLink = "https://" + strServerAbsolute + strServer + "/br/Sample/SampleWrapperPage.aspx?Cart=Y&hidStoryGUID=" + strStoryGUID;
				strLink = "https://" + strServerAbsolute + strServer +  "/br/Sample/SampleWrapperPage.aspx?hidIsCart=Y&hidStoryGUID=" + strStoryGUID;
				//strLink="../FrontEndCommonPages/DefaultSampleLogin.aspx?Cart=Y&storyid=" + storyid;
				submitPageFE(strLink);
				return false;
			}
			else
			{
				window.document.forms[0].hidAddToCartStory.value = "1"
			}
		}
}

function AddToClippingsStoryDetail(strStoryId,strUserId,strServerAbsolutePath,strServerPath,strStoryGUID,strLink)
{	
	var storyid=strStoryId;
	strLink = escape(strLink+"&Clip=Y");
	if (strUserId == 0)
	{	
		var sLink = "https://" + strServerAbsolutePath + strServerPath + "/br/Sample/SampleWrapperPage.aspx?hidURL="+strLink;
		//strLink = "https://" + strServerAbsolutePath + strServerPath + "/br/Sample/SampleWrapperPage.aspx?Clip=Y&hidStoryGUID=" + strStoryGUID;
		submitPageFE(sLink);
		return false;
	}
	popupWin(strServerPath + '/br/Clippings/SelectClippingFolder.aspx?type=1&Id=' + storyid ,'600','310','yes');
	return false;
}

function LoadClipStoryDetail(strStoryId , strServer,strStoryGUID)
{
	var ItemId;
	ItemId=strStoryId			
	popupWin(strServer + '/br/Clippings/SelectClippingFolder.aspx?type=1&Id=' + ItemId,'600','310','yes');
 	return false;				
}
//For Story Details
//Media Delivery Control
function openpopupMediaDelivery()
{
	var strQueryString;
	strQueryString = 'http://' + strServerNameDyn + strPortDyn + strServerPathDyn + '/br/Help/TermsAndConditionsPage.aspx?Content=Help'
	submitPageFE(strQueryString);
}
  
 //Media Delivery Control
 // For Verify Delivery Info
 function fSaveContinue(strMode,iUserID,strUSId)
 {	
	if (strMode != 'STREAMING')
	{
	var objtxtCCEmailAddress = getObj("txtEmailCCAddress");
	if (typeof(objtxtCCEmailAddress)== 'object')
	{
		var strEmails=objtxtCCEmailAddress.value
		if (strEmails!='')
		{
			var arrayEmails=strEmails.split(";")
			for(i=0; i<arrayEmails.length;i++)
			{
				var strTemp  = trimtxt(arrayEmails[i]);
				var strTemp1=strTemp.toString();
				if (strTemp1!=''){if (!isEmail(strTemp1,"CC email address")) return false;}
			}
		}
	}
	}
	if (iUserID == 0)
	{
		if (!validateFormVerifyDel('ADD' , 1))
		{
			return false;
		}
	}
	
	if (strMode == 'PULL')
	{
		var objSPInst = getObj("taInstructions");
			if(typeof objSPInst == 'object')
			{	
				if (objSPInst.value.length>=201)
				{
					alert('Special Instructions can\'t be more than 200 characters.');
					return false;
				}
			}
		
	}
	else
	if (strMode == 'PUSH')
	{
		var objtxtFTPAddress = getObj("txtFTPAddress");
		var objtxtStationCallLetters = getObj("txtStationCallLetters");
		var objchkTelestream = getObj("chkTelestream");
		var objtxtUserName = getObj("txtUserNamePush");
		var objtxtPassword = getObj("txtPasswordPush");
		
		objDelivery = getObj("TnmPushDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		
		if(objChecked==true)				
		{	
			if(isBlank(objtxtFTPAddress,'FTP Server IP')) return false;				
			if(isBlank(objtxtUserName,'User Name')) return false;				
			if(isBlank(objtxtPassword,'Password')) return false;				
			
 		}
 		
 		objDelivery = getObj("TnmTelestreamDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if(objChecked==true)				
		{	
			if(isBlank(objtxtFTPAddress,'Telestream ClipMail IP')) return false;				
		}													
 		
 		objDelivery = getObj("TnmPathFireDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if(objChecked==true)				
		{	
			//if(isBlank(objtxtStationCallLetters,'Station Call Letter')) return false;
			if (typeof objtxtStationCallLetters == 'object'){
				strTextString  = trimtxt(objtxtStationCallLetters.value)
				iValLength = strTextString.length
				if (iValLength == 0)
				{
					alert('Please check your information on this field, it is necessary for this delivery method.')
					setFocus(objtxtStationCallLetters);
					return false;
				}

		}

			
			if (objtxtStationCallLetters.value.length>10)
			{
				alert ('Station Call Letter cannot be greated than 10');
				return false;
			}
	 }													
		
		var objSPInst = getObj("taInstructions");
			if(typeof objSPInst == 'object')
			{	
				if (objSPInst.value.length>=201)
				{
					alert('Special Instructions can\'t be more than 200 characters.');
					return false;
				}
			}
		}
	else
	if (strMode == 'APTN')
	{
			var objSPInst = getObj("taInstructions");
			if(typeof objSPInst == 'object')
			{	
				if (objSPInst.value.length>=201)
				{
					alert('Special Instructions can\'t be more than 200 characters.');
					return false;
				}
			}
	}
	else
	if (strMode == 'TAPE')
	{
		
		var iUSId = strUSId ;
		var objtxtAddress1 = getObj("txtAddress1Tape");
		var objtxtAddress2 = getObj("txtAddress2Tape");
		var objtxtAddress3 = getObj("txtAddress3Tape");
		var objcboCountry = getObj ("cboCountryTape");
		var objcboState = getObj ("cboStateTape");
		var objtxtState = getObj ("txtStateTape");
		var objtxtCity = getObj ("txtCityTape");
		var objtxtZip = getObj("txtZipTape")
		var objtxtTelephone = getObj("txtTelephoneTape");
		var objSPInst = getObj("txtInstruction");
		if (isBlank(objtxtAddress1,'Address')) return false;
		if (isQuotes(objtxtAddress1,/*b*/'Address'/*e*/,1)) return false;
		if(objtxtAddress2.value.length > 0)
				{
					if (isQuotes(objtxtAddress2,/*b*/'Address'/*e*/,1))
					return false;
				}

				if(objtxtAddress3.value.length > 0)
				{
					if (isQuotes(objtxtAddress3,/*b*/'Address'/*e*/,1))
					return false;
				}

				if (objcboCountry.selectedIndex==0)
				{
					alert('Please Select Country');
					return false;
				}			
				
				iCountry = objcboCountry[objcboCountry.selectedIndex].value;
				
				if (iCountry == iUSId)
				{
					if (objcboState.selectedIndex==0)
					{
						alert('Please Select State');
						return false;
					}	
				}
				else
				{				
					if(objtxtState.value.length > 0)
					{
						if (isQuotes(objtxtState,/*b*/'State'/*e*/,1))
						return false;
					}
 				}
				
				if(objtxtCity.value.length > 0)
				{
					if (isQuotes(objtxtCity,/*b*/'City'/*e*/,1))
					return false;
				}

				if(objtxtZip.value.length > 0)
				{
					if(isQuotes(objtxtZip,'Postal Code',1))	
					return false;
					else 
					if(!isName(objtxtZip,'PostalCode',0,10,0)) 
						return false;				
 				}
	 				
				if(isBlank(objtxtTelephone,'Telephone number')) return false;
				if(!isTelePhone(objtxtTelephone,'Telephone number')) return false;		
				
				if(objSPInst.value.length>=201){
						alert('Special Instructions can\'t be more than 200 characters.');
						return false;
				}
		
	}
	else
	if (strMode == 'DVD')
	{
		//alert("DVD")
		var iUSId = strUSId ;
		var objtxtAddress1 = getObj("txtAddress1DVD");
		var objtxtAddress2 = getObj("txtAddress2DVD");
		var objtxtAddress3 = getObj("txtAddress3DVD");
		var objcboCountry = getObj ("cboCountryDVD");
		var objcboState = getObj ("cboStateDVD");
		var objtxtState = getObj ("txtStateDVD");
		var objtxtCity = getObj ("txtCityDVD");
		var objtxtZip = getObj("txtZipDVD")
		var objtxtTelephone = getObj("txtTelephoneDVD");
		var objSPInst = getObj("txtInstruction");
		if (isBlank(objtxtAddress1,'Address')) return false;
		if (isQuotes(objtxtAddress1,/*b*/'Address'/*e*/,1)) return false;
		if(objtxtAddress2.value.length > 0)
				{
					if (isQuotes(objtxtAddress2,/*b*/'Address'/*e*/,1))
					return false;
				}

				if(objtxtAddress3.value.length > 0)
				{
					if (isQuotes(objtxtAddress3,/*b*/'Address'/*e*/,1))
					return false;
				}

				if (objcboCountry.selectedIndex==0)
				{
					alert('Please Select Country');
					return false;
				}			
				
				iCountry = objcboCountry[objcboCountry.selectedIndex].value;
				
				if (iCountry == iUSId)
				{
					if (objcboState.selectedIndex==0)
					{
						alert('Please Select State');
						return false;
					}	
				}
				else
				{				
					if(objtxtState.value.length > 0)
					{
						if (isQuotes(objtxtState,/*b*/'State'/*e*/,1))
						return false;
					}
 				}
				
				if(objtxtCity.value.length > 0)
				{
					if (isQuotes(objtxtCity,/*b*/'City'/*e*/,1))
					return false;
				}

				if(objtxtZip.value.length > 0)
				{
					if(isQuotes(objtxtZip,'Postal Code',1))	
					return false;
					else 
					if(!isName(objtxtZip,'PostalCode',0,10,0)) 
						return false;				
 				}
	 				
				if(isBlank(objtxtTelephone,'Telephone number')) return false;
				if(!isTelePhone(objtxtTelephone,'Telephone number')) return false;		
				
				if(objSPInst.value.length>=201)
				{
						alert('Special Instructions can\'t be more than 200 characters.');
						return false;
				}
		
	}
	else
	/*if (strMode == 'STREAMING' )
	{
		alert(strMode);
	}*/
		if (typeof document.forms[0].hidDeliverySet == 'object')
			{
				document.forms[0].hidDeliverySet.value = strMode;
			}
				
	if( document.getElementById("hidDeliveryFormat"))
	{	//debugger
		var cboVDOption,rdoWindowVideoFormat;
		hidDelPref = document.getElementById("hidDeliveryFormat");
		if (strMode == 'STREAMING' )
		{///For Streaming Sending the Medium Delivery ID
			rdoWindowVideoFormat = getObj("rdoWindowVideoFormat",2);
			if (rdoWindowVideoFormat)	
			{
				if (rdoWindowVideoFormat.checked==true)
				{
					hidDelPref.value="1";   ///Windows Media Video Download option selected
				}
				else
				{
					hidDelPref.value="2";   ///QuickTime Video Download Option selected
				}
			}
		}
		else
		{			
			cboVDOption = getObj("cboVDOption",2);
			if (cboVDOption)	
			{
				hidDelPref.value=cboVDOption.value;
			}
			else
			{
				hidDelPref.value="";
			}	
		}
	}				
 }
 		
 	function SwitchStateMailingAddress(strUserId,strUSId)
 	{				
		var objStateDiv;
		var explorer=false;
		var netscape = false;
		var mac=false;
		var browser=navigator.userAgent;
		
		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
			
		var iUSid = strUSId;
		var objCboCountry = getObj("cboCountry");

		if (typeof objCboCountry == 'object')
		{	
			if (objCboCountry.value == iUSid){
					// showElement(getElement('spanSelState'));
					// hideElement(getElement('spanTxtState'));
					
					var e=window.document.getElementById("spanSelStateTape") ;
					var e1=window.document.getElementById("spanTxtStateTape") ;
					var e2=window.document.getElementById("spanStateLabelTape") ;
					e.style.visibility='visible';
					e1.style.visibility='hidden';
					e2.style.visibility='visible';
				//	window.document.forms[0].cboState.focus();
			}
			else {
					// showElement(getElement('spanTxtState'));
					// hideElement(getElement('spanSelState'));
						
				var e=window.document.getElementById("spanSelStateTape") ;
				var e1=window.document.getElementById("spanTxtStateTape") ;
				var e2=window.document.getElementById("spanStateLabelTape") ;
				e.style.visibility ='hidden';
				e1.style.visibility ='visible';
				e2.style.visibility ='hidden';
				
				objStateDiv = getElement('spanTxtStateTape');
					
				var browser=navigator.userAgent;
				var strFirefox = browser.match("Firefox");
				var strNetscape = browser.match("Netscape");
								
				if (netscape)
				{							
					if ( strUserId == 0 )
					{  
						if(mac)
						{
							objStateDiv.style.top = "1825px";
							//1625 - normal	
						}
						else
						{
							objStateDiv.style.top = "1700px";
						}
					}
					else
					{											
						if(mac)
						{
							objStateDiv.style.top = "684px";
						}
						else if (strFirefox!=null)
						{
							objStateDiv.style.top = "718px";
						}
						else if (strNetscape!=null)
						{
							objStateDiv.style.top = "718px";
							//objStateDiv.style.top = "683px";
							//objStateDiv.style.left = "694px";      
						}
						else 
						{
							objStateDiv.style.top = "747px";
						}
					}
							
				}

			}
		}
		return false;
	}
	function SwitchStateMailingAddressDVD(strUserId,strUSId)
 	{				
		var objStateDiv;
		var explorer=false;
		var netscape = false;
		var mac=false;
		var browser=navigator.userAgent;
		
		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
			
		var iUSid = strUSId;
		var objCboCountry = getObj("cboCountry");

		if (typeof objCboCountry == 'object')
		{	
			if (objCboCountry.value == iUSid){
					// showElement(getElement('spanSelState'));
					// hideElement(getElement('spanTxtState'));
					
					var e=window.document.getElementById("spanSelStateDVD") ;
					var e1=window.document.getElementById("spanTxtStateDVD") ;
					var e2=window.document.getElementById("spanStateLabelDVD") ;
					e.style.visibility='visible';
					e1.style.visibility='hidden';
					e2.style.visibility='visible';
				//	window.document.forms[0].cboState.focus();
			}
			else {
					// showElement(getElement('spanTxtState'));
					// hideElement(getElement('spanSelState'));
						
				var e=window.document.getElementById("spanSelStateDVD") ;
				var e1=window.document.getElementById("spanTxtStateDVD") ;
				var e2=window.document.getElementById("spanStateLabelDVD") ;
				e.style.visibility ='hidden';
				e1.style.visibility ='visible';
				e2.style.visibility ='hidden';
				
				objStateDiv = getElement('spanTxtStateDVD');	
				
				var browser=navigator.userAgent;
				var strFirefox = browser.match("Firefox");
				var strNetscape = browser.match("Netscape");
								
				if (netscape)
				{							
					if ( strUserId == 0 )
					{  
						if(mac)
						{
							objStateDiv.style.top = "1825px";
							//1625 - normal	
						}
						else
						{
							objStateDiv.style.top = "1700px";
						}
					}
					else
					{											
						if(mac)
						{
							objStateDiv.style.top = "684px";
						}
						else if (strFirefox!=null)
						{
							objStateDiv.style.top = "718px";
						}
						else if (strNetscape!=null)
						{
							objStateDiv.style.top = "718px";
							//objStateDiv.style.top = "683px";
							//objStateDiv.style.left = "694px";      
						}
						else
						{
							objStateDiv.style.top = "747px";
						}
					}
							
				}

			}
		}
		return false;
	}
// For Verify Delivery Info

function TelestreamChange()
{	
	if (typeof document.forms[0].hidTeleStreamChecked == 'object')
	{
		var objChkTelestream = getObj("chkTelestream")
		
		if (typeof objChkTelestream == 'object')
		{
			if (objChkTelestream.checked) 
			{	
				document.forms[0].hidTeleStreamChecked.value = '1'
				document.forms[0].hidTeleStreamChanged.value = '1'
			}
			else
			{
				document.forms[0].hidTeleStreamChecked.value = '0'
				document.forms[0].hidTeleStreamChanged.value = '1'
			}	
			
		}
	}
	
	document.forms[0].submit();	
}
	
	function catchKeyPress(code, sender) {
			if(code == '13') {
				document.forms[0].hidEnterPress.value = '1'
				document.forms[0].LoginClick.value = '1'
				validateLoginMain(1,'1');
				return false;
			}
          } 
    


function DeliveryChanged(iSessionId,strHost,strServer,strPort)
{	
	var objDelivery ;
	var objChecked;
	if (iSessionId == 0 ){ 
		//Path Fire changes
		objDelivery = getObj("TnmTelestreamDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if (objChecked) 
		{
			document.forms[0].action = 'VerifyDeliveryInfo.aspx?hidStep2Page=2&hidDeliveryChanged=0&hidSubDeliveryType=1';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}
		
		objDelivery = getObj("TnmPathFireDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if (objChecked) 
		{
			document.forms[0].action = 'VerifyDeliveryInfo.aspx?hidStep2Page=2&hidDeliveryChanged=0&hidSubDeliveryType=2';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}

		//Path Fire changes	
		objDelivery = getObj("TnmPullDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if (objChecked) 
		{
			document.forms[0].action ='VerifyDeliveryInfo.aspx?hidStep2Page=1&hidDeliveryChanged=0'
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}
		
		
		objDelivery = getObj("TnmPushDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked)
		{
			document.forms[0].action = 'VerifyDeliveryInfo.aspx?hidStep2Page=2&hidDeliveryChanged=0';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}	
		
		
		objDelivery = getObj("TnmGlobalVideoRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked) 
		{
			document.forms[0].action = 'VerifyDeliveryInfo.aspx?hidStep2Page=4&hidDeliveryChanged=0';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}		
		
		
		objDelivery = getObj("TNMTapeRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked) 
		{
			document.forms[0].action = 'VerifyDeliveryInfo.aspx?hidStep2Page=3&hidDeliveryChanged=0'
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}		
		objDelivery = getObj("TNMDVDRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked) 
		{
			document.forms[0].action = 'VerifyDeliveryInfo.aspx?hidStep2Page=6&hidDeliveryChanged=0'
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].submit();
			return false;
		}				
	 }	

	// Tejas
	 else
	 {
		//For Path Fire
		objDelivery = getObj("TnmTelestreamDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if (objChecked) 
		{
			try
			{
			document.forms[0].action = 'https://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=2&hidDeliveryChanged=0&hidSubDeliveryType=1';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TnmTelestreamDeliveryRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}
		
		objDelivery = getObj("TnmPathFireDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if (objChecked) 
		{
			try
			{
			document.forms[0].action = 'https://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=2&hidDeliveryChanged=0&hidSubDeliveryType=2';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TnmPathFireDeliveryRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}


		//For Path Fire
	 	objDelivery = getObj("TnmPullDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery)
		if (objChecked) 
		{	
			try
			{
			document.forms[0].action = 'http://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=1&hidDeliveryChanged=0'
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TnmPullDeliveryRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}
		
		
		objDelivery = getObj("TnmPushDeliveryRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked)
		{
			try
			{
			document.forms[0].action = 'https://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=2&hidDeliveryChanged=0';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TnmPushDeliveryRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}	
		
		
		objDelivery = getObj("TnmGlobalVideoRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked) 
		{
			try
			{
			document.forms[0].action = 'http://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=4&hidDeliveryChanged=0';
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TnmGlobalVideoRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}		
		
		
		objDelivery = getObj("TNMTapeRadio");
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked) 
		{
			try
			{
			document.forms[0].action = 'http://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=3&hidDeliveryChanged=0'
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TNMTapeRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}			
		objDelivery = getObj("TNMDVDRadio")
		objChecked = DeliveryChecked(objDelivery);
		if (objChecked) 
		{
			try
			{
			document.forms[0].action = 'http://' + strHost + strPort + strServer + '/br/ShoppingCart/VerifyDeliveryInfo.aspx?hidStep2Page=6&hidDeliveryChanged=0'
			document.forms[0].hidDeliveryChanged.value = '1'
			document.forms[0].hidRadioId.value = 'TNMDVDRadio'
			document.forms[0].submit();
			}
			catch(e) {}
			return false;
		}			
	 
	 }
	 //Tejas The value of the hidRadioId is set to take care of the MAC Issue for Delivery option change on Step 2.
}



function DeliveryChecked(objDel)
{
	if (typeof objDel == 'object')
	{
		if (objDel.checked)
		{
			return true; 
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
//For Verify Delivery Info Registraion
function validateFormVerifyDel(strMode,iUserType)
	{		
		var iUSid ;//= strUSId ;  
		var txtEmailType = getObj("txtEmail","1")
		var txtPasswordType = getObj("txtPassword","1")
		var txtVerifyPasswordType = getObj("txtVerifyPassword","1")
		var txtFirstNameType = getObj("txtFirstName","1")
		var txtLastNameType = getObj("txtLastName","1")
		var cmbPositionType = getObj("cmbPosition","2")
		var txtOtherPositionType = getObj("txtOtherPosition","1")
		var txtTelephoneType = getObj("txtTelephone","1")
		var txtFaxType = getObj("txtFax","1")
		var txtAddress1Type = getObj("txtAddress1","1")
		var txtAddress2Type = getObj("txtAddress2","1")
		var txtAddress3Type = getObj("txtAddress3","1")
		var cmbCountryType = getObj("cmbCountry","2")
		var cmbSelStateType = getObj("cmbSelState","2")
		var txtStateType = getObj("txtState","1")
		var txtCityType = getObj("txtCity","1")
		var txtPostalCodeType = getObj("txtPostalCode","1")
		var txtOtherOrgnizationNameType = getObj("txtOtherOrgnizationName","1")
		var cmbMediaTypeType = getObj("cmbMediaType","2")
		var cmbTVFormatType = getObj("cmbTVFormat","2")
		var txtYourdepartmentType = getObj("txtYourdepartment","1")
		var txtUrlWebAddressType = getObj("txtUrlWebAddress","1")
		var cmbHearAboutUsType = getObj("cmbHearAboutUs","2")
		var txtHearAboutUsType = getObj("txtHearAboutUs","1")
		var txtRemarksType = getObj("txtRemarks","1")
		
		var rdoRegEditorial = getObj("rdoEditTm")
		var rdoIndProducer = getObj("rdoIndPr");
		var rdoMarket = getObj("rdoMarket")
		var rdoOthers = getObj("rdoOthers");
		var rdoClient = getObj("rdoClient");
		if (typeof  rdoRegEditorial == 'object')
		{
			if (rdoRegEditorial.checked)
			{
				iUserType = 1 ;
			}
		}
		
		if (typeof  rdoIndProducer == 'object')
		{
		if (rdoIndProducer.checked)
			{
				iUserType = 2 ; 
			}
		}
		if (typeof  rdoMarket == 'object')
		{
			if (rdoMarket.checked)
			{
				iUserType = 11 ; 
			}		
		}

	if (typeof  rdoOthers == 'object')	
	{	
		if (rdoOthers.checked)
		{
			iUserType = 7 ; 
		}
	}
	
	if (typeof  rdoClient == 'object')	
	{	
		if (rdoClient.checked)
		{
			iUserType = 4 ; 
		}
	}
		

		iUSid = cmbCountryType[1].value;
		//skip validations if already validated
		
		//if (window.document.forms[0].hidValidate.value == '1') return true;
		//var objFrm;
		//objFrm = eval('window.document.'+FormName)
		//objFrm = window.document.forms[0]
		
		if (strMode == 'ADD')
		{
			if (!isEmail(txtEmailType,'Email Address'))return false;
			if (isBlank(txtPasswordType,'Password')) return false;
			if (txtPasswordType.value.length<4)
			{
				alert('Please enter password more than 3 characters');
				txtPasswordType.focus();
				return false;
			}
		
			if (isBlank(txtVerifyPasswordType,'Verify Password')) return false;
			if(trimtxt(txtVerifyPasswordType) == '')
			{
				alert("Please verify your password.");
				txtVerifyPasswordType.focus();
				return false;
			}
    		if (txtPasswordType.value !== txtVerifyPasswordType.value)
			{
				alert('Verify Password and Password should be same');
				txtPasswordType.focus();
				return false;
			}
		}
		
		if (isBlank(txtFirstNameType,'First Name'))return false;
		if (!isAlpha(txtFirstNameType,'First Name')) return false;
		if (isQuotes(txtFirstNameType,/*b*/'First Name'/*e*/,'1')) return false;
		
		if (isBlank(txtLastNameType,'Last Name')) return false;
		if (!isAlpha(txtLastNameType,'Last Name')) return false;
		if (isQuotes(txtLastNameType,/*b*/'Last Name'/*e*/,'1')) return false;
		
		
		/*Check For Position*/
		if (typeof cmbPositionType == 'object') 
		{
			if (cmbPositionType.selectedIndex==0)
			{
				alert('Please Select Position');
				cmbPositionType.focus();
				return false;
			}else
			{
				if(cmbPositionType.selectedIndex==1)
				{
					if (isBlank(txtOtherPositionType,'Other Position')) return false;
					if (isQuotes(txtOtherPositionType,/*b*/'Other Position'/*e*/,'1')) return false;
				}
			}
		}
		
		if(isBlank(txtTelephoneType,'Telephone number')) return false;
		if(!isTelePhone(txtTelephoneType,'Telephone number')) return false;
		
		/*if(isBlank(objFrm.txtFax,'Fax')) return false;*/
		if (trimtxt(txtFaxType.value) != '') 
		{
			if (isQuotes(txtFaxType,/*b*/'Fax Number'/*e*/,1)) return false;	
			if(!isTelePhone(txtFaxType,'Fax')) return false;	
		}
		
		if(trimtxt(txtAddress1Type) == '')
		{
			alert("Address is required. \nPlease enter an Address.");
			txtAddress1Type.focus();
			return false;
		}
		if (isQuotes(txtAddress1Type,/*b*/'Address'/*e*/,1)) return false;
		
		if (isQuotes(txtAddress2Type,/*b*/'Address'/*e*/,1)) return false;
		if (isQuotes(txtAddress3Type,/*b*/'Address'/*e*/,1)) return false;
			if (cmbCountryType.selectedIndex==0)
		{
			alert('Please Select Country');
			cmbCountryType.focus();
			return false;
		}
		
		iCountry = cmbCountryType[cmbCountryType.selectedIndex].value
		if (iCountry == iUSid)
		{
			if (cmbSelStateType.selectedIndex==0)
			{
				alert('Please Select State');
				cmbSelStateType.focus();
				return false;
			}	
		}
		else
		{				
			/*if (isBlank(objFrm.txtState,'State')) return false;*/
			if (isQuotes(txtStateType,'State',1)) return false;
			if (trimtxt(txtStateType.value) != '') 
			{
				if (!isAlpha(txtStateType,'State')) return false;
			}
		}
		
				/*if (isBlank(objFrm.txtCity,'City')) return false;*/
		if (isQuotes(txtCityType,'City',1)) return false;
		/*if (trimtxt(objFrm.txtCity.value) != '') 
		{
			if (!isAlpha(objFrm.txtCity,'City')) return false;
		}*/
		
		
				/*if(isBlank(objFrm.txtPostalCode,'Postal Code'))	return false;*/
		if(trimtxt(txtPostalCodeType) != '') 
		{
			if(isQuotes(txtPostalCodeType,'Postal Code',1))	return false;
			else if(!isName(txtPostalCodeType,'PostalCode',0,10,0)) return false;			
		}				
		
				//Changed for Organization Name - Start
		//if (isBlank(objFrm.txtOtherOrgnizationName,'Organization Name')) return false;
		if(trimtxt(txtOtherOrgnizationNameType) == ''){
			alert("Please enter an Organization Name.");
			txtOtherOrgnizationNameType.focus();
			return false;
		}
		if (isQuotes(txtOtherOrgnizationNameType,'Organization Name','1')) return false;
		//Changed for Organization Name - Stop

		if ((iUserType == 1) || (iUserType == 2))
		{
			if (cmbMediaTypeType.selectedIndex == 0)
			{
				alert('Please Select Media Type');
				cmbMediaTypeType.focus();
				return false;
			}
		
			//Added : 31/01/2003 : Start
			//Enforce selection of Video Standard if media type is 'TV'
			var MediaType = cmbMediaTypeType[cmbMediaTypeType.selectedIndex].text;
			
			if (MediaType.toUpperCase() == 'TV')
			{	
				if (cmbTVFormatType.selectedIndex==0)
				{
					alert('Please Select Video Standard');
					cmbTVFormatType.focus();
					return false;
				}
			}
		}
		
		if ((iUserType == 1) || (iUserType == 2) || (iUserType == 6))
		{
			if (trimtxt(txtYourdepartmentType) != '') 
			{
				if (!isAlpha(txtYourdepartmentType,'Your department')) return false;
				if (isQuotes(txtYourdepartmentType,'Your department','1')) return false;
			}
		}
		
		//if ((iUserType == 1) || (iUserType == 2) || (iUserType == 7 ) || (iUserType == 11))
		//{
			/*if (isBlank(objFrm.txtUrlWebAddress,'Web Address')) return false;*/
			if (isQuotes(txtUrlWebAddressType,/*b*/'Web Address'/*e*/,1)) return false;
		//}
		
		//if (cmbHearAboutUsType[cmbHearAboutUsType.selectedIndex].value== 7)
		//	if (isBlank(txtHearAboutUsType,'How did you find about us?')) return false;
		//if (isQuotes(txtHearAboutUsType,/*b*/'How did you find about us?'/*e*/,1)) return false;
		//if (!checkLength(txtHearAboutUsType,60,/*b*/'How did you find about us?'/*e*/)) return false;	
		
		//if (isBlank(objFrm.flUpload,'Distribution File')) return false;
		
		
		if (iUserType != 6)
		{
			if (isQuotes(txtRemarksType,/*b*/'Remarks'/*e*/,1)) return false;
			if (!checkLength(txtRemarksType,500,/*b*/'Remarks'/*e*/)) return false;	
		}
		/*alert('Your registration with The NewsMarket is now in progress.  \nWe will be in touch with you to either verify some information, or will directly approve you for full usage rights on the site. \nIn the meantime, your membership with the site is temporary.  \nYou can start ordering media materials from us now, but these orders will be on hold for fulfillment/delivery when your approval is complete.') ;*/
		//window.document.forms[0].hidValidate.value = '1';
		//submitThisPage();

	return true

}
	function SwitchUsersDeliveryInfo(iType)
	{		
		var objStateDiv;
		var explorer=false;
		var netscape = false;
		var mac=false;
		var browser=navigator.userAgent;
		
		
		if(browser.indexOf('Mac')>0)
			mac=true;
		if(browser.indexOf('MSIE')>0)
			explorer = true;
		else
			netscape = true;
			
		var obj11 = document.getElementById("spanOtherUsers");
		var obj12 = document.getElementById("spanTVFormat");
	
		if (iType==1 || iType==2)
		{
			if(explorer)
			{
				obj11.style.display ='';				
				obj12.style.display ='';
			}
			if(netscape)
			{
				showElement(getElement('spanOtherUsers'));
				showElement(getElement('spanTVFormat'));
			}
		}
		else 
		{			
			if(explorer)
			{			
				obj11.style.display ='none';
				obj12.style.display ='none';			
			}
			if(netscape)
			{
				hideElement(getElement('spanOtherUsers'));
				hideElement(getElement('spanTVFormat'));
			}
		}		
		document.forms[0].hidUserType.value = iType;
		document.forms[0].submit();
}

function LogOutComplete(txtServerName)
{		
	
	//delCookie('Login','/');			
	//delCookie('TNMPassword','/');			
	/*if(txtServerName == strServer)
		sLink = "http://" + txtServerName + portNumber + "/FrontEndCommonPages/Logout.aspx";
	else
		sLink = "http://" + txtServerName + "/FrontEndCommonPages/Logout.aspx";*/					
		
	sLink = "http://" + txtServerName + "/br/Login/LogoutPage.aspx";	
	//document.forms[0].hidSessionAlreadyExists.value='1';
	submitPageFE(sLink);
	return false;
}

function GoToOrderDetail(strLink){
	window.document.forms[0].hidPageNum.value = "1";
	submitPageFE(strLink);
}
//Test Connection 
function TestConnection(){
			var objtxtFTPAddress = getObj("txtFTPAddress");
			var objchkTelestream = getObj("chkTelestream");
			var objtxtUserName = getObj("txtUserNamePush");
			var objtxtPassword = getObj("txtPasswordPush");
		
			if(isBlank(objtxtFTPAddress,'FTP Server IP')) return false;					
			if(isBlank(objtxtUserName,'User Name')) return false;				
			if(isBlank(objtxtPassword,'Password')) return false;				
										
			fptaddress = trimtxt(objtxtFTPAddress)								
				if (fptaddress.charAt(3) == ":")
					fptaddress = fptaddress.substring(6);					
					popUpPage='TestConnection.aspx?strCallingPage=Shopping Cart&strHostName='+fptaddress+'&strUsername='+escape(objtxtUserName.value)+'&strPassword='+escape(objtxtPassword.value);
					popupWin(popUpPage ,'445','250','yes','FTP Test Connection');
					return false;		
			}		
			
			function MyAccountTestConnection(){
			var objtxtFTPAddress = getObj("txtFTPAddress",1);
			var objchkTelestream = getObj("chkTelestream",2);
			var objtxtUserName = getObj("txtUserName",1);
			var objtxtPassword = getObj("txtserverPasswrod",1);
		
			if(isBlank(objtxtFTPAddress,'FTP Server IP')) return false;					
			if(isBlank(objtxtUserName,'User Name')) return false;				
			if(isBlank(objtxtPassword,'Password')) return false;				
										
			fptaddress = trimtxt(objtxtFTPAddress)								
				if (fptaddress.charAt(3) == ":")
					fptaddress = fptaddress.substring(6);					
					popUpPage='../ShoppingCart/TestConnection.aspx?strCallingPage=Shopping Cart&strHostName='+fptaddress+'&strUsername='+escape(objtxtUserName.value)+'&strPassword='+escape(objtxtPassword.value);
					popupWin(popUpPage ,'400','300','yes','FTP Test Connection');
					return false;		
			}		
			
		function validationmyccount()
		{
			var objtxtFTPAddress = getObj("txtFTPAddress",1);
			var objtxttechtelephone = getObj("txttechtelephone",1);
			var objchkTelestream = getObj("chkTelestream",2);
			var objtxtUserName = getObj("txtUserName",1);
			var objtxtPassword = getObj("txtserverPasswrod",1);
			var objtxtverifyPassword = getObj("txtverifyPassword",1)
			
			window.document.forms[0].hidSave.value = "1";
			if(isBlank(objtxtFTPAddress, 'FTP Server IP')) return false;			
			if(trimtxt(objtxttechtelephone.value)!= '') 
			{
				if(!isTelePhone(objtxttechtelephone, 'Telephone')) return false; 
			}			
			
			if(window.document.forms[0].chkTelestream.checked == false)				
			{					
				if(isBlank(objtxtUserName,'User Name')) return false;				
				if(isBlank(objtxtPassword,'Server Password')) return false;				
				if(isBlank(objtxtverifyPassword,'Verify Password')) return false;				
				
				if ((trimtxt(objtxtPassword.value)!='') || (trimtxt(objtxtverifyPassword.value)!=''))
				{
					if(isBlank(objtxtUserName, 'User Name')) return false; 
					if(isBlank(objtxtPassword , 'Server Password')) return false ; 
					if(isBlank(objtxtverifyPassword, 'Verify Password')) return false; 
					if (objtxtPassword.value != objtxtverifyPassword.value)
					{
					alert("The passwords you typed do not match.");
					objtxtverifyPassword.focus();
					return false;
					}
				}
			}
			//document.frmVdoPush.submit();					
			return true;
		}

//Test Connection

function repeatOrderClicked()
{
	var somethingIsChecked = false;
	window.document.forms[0].hidCheckedorders.value = "";
	var ctr = 0;
	for(var i = 0; i < window.document.forms[0].elements.length; i++)
	{
		if (window.document.forms[0].elements[i].type == "checkbox")
		{
			if (window.document.forms[0].elements[i].checked == true)
			{
				ctr++;
				somethingIsChecked = true;
				window.document.forms[0].hidCheckedorders.value = window.document.forms[0].elements[i].id + "," + window.document.forms[0].hidCheckedorders.value;
			}
		}
	}
	if(somethingIsChecked == false)
	{ 
		alert("Please select an order.");
		return false;
	}
	return true;
}

var objFrmName =  'window.document.forms[0]';
var objFrm = eval(objFrmName);
var iBackTo = 0 ;

function SubmitSearch(boolButtonClick , strComboId)
{	
	var objHealthAreaControl; 
	var objBusinessControl;
	var objProductsControl;	
	
	objHealthAreaControl = eval(objFrmName + '.' + strSearchControl + '_' + 'lstHealthArea')
	objBusinessControl = eval(objFrmName + '.' + strSearchControl + '_' + 'lstBusiness')
	objProductsControl = eval(objFrmName + '.' + strSearchControl + '_' + 'lstProducts')
	
	if (boolButtonClick == false)
	{
		if(strComboId == '1')
		{	
			if(typeof objHealthAreaControl == 'object')
			{	
				if (objHealthAreaControl.options[objHealthAreaControl.selectedIndex].value != -1)
				{
					objFrm.hidFilter.value = objHealthAreaControl.options[objHealthAreaControl.selectedIndex].value;
					if(typeof objBusinessControl == 'object')
					{
						objBusinessControl.selectedIndex = 0; 
					}
					if(typeof objProductsControl == 'object')
					{
						objProductsControl.selectedIndex = 0; 		
					}	
				}
				else
				{
					return false;
				}
			}
		}
		else if(strComboId == '2')
		{	
			if(typeof objBusinessControl == 'object')
			{	if (objBusinessControl.options[objBusinessControl.selectedIndex].value != -1)
				{
					objFrm.hidFilter.value = objBusinessControl.options[objBusinessControl.selectedIndex].value	
					if(typeof objProductsControl == 'object')
					{
						objProductsControl.selectedIndex = 0; 		
					}
					if(typeof objHealthAreaControl == 'object')
					{
						objHealthAreaControl.selectedIndex = 0; 
					}														
				}
				else
				{
					return false;
				}
			}
		}
		else
		{
			if(typeof objProductsControl == 'object')
			{
				if (objProductsControl.options[objProductsControl.selectedIndex].value != -1)
				{
					objFrm.hidFilter.value = objProductsControl.options[objProductsControl.selectedIndex].value
					if(typeof objHealthAreaControl == 'object')
					{
						objHealthAreaControl.selectedIndex = 0; 
							
					}
					if(typeof objBusinessControl == 'object')
					{	
						objBusinessControl.selectedIndex = 0; 		
						
					}					
				}
				else
				{
					return false;
				}
				
			}	
		}
		objFrm.hidComboId.value = strComboId
	}
	else
	{
		objFrm.hidFilter.value  = '0'
		objFrm.hidComboId.value = '0'
		if(typeof objHealthAreaControl == 'object') 
		{
			objHealthAreaControl.selectedIndex = 0 
		}
		if(typeof objBusinessControl == 'object') 
		{
			objBusinessControl.selectedIndex = 0 
		}
		if(typeof objProductsControl == 'object') 
		{
			objProductsControl.selectedIndex = 0 
		}
	}
	objFrm.method = "post"
	if (strSubmit != '')
	{	
		if (strSubmit == 'MultimediaPressPacks.aspx')
		{
			objFrm.hidSelectedLink.value = '5';
		}
		objFrm.action = strSubmit	
	}
	objFrm.hidFromSearch.value = '1'
	objFrm.hidSearchBackTo.value = '1'
	if (typeof objFrm.hidPageNum == 'object') 
	{
		objFrm.hidPageNum.value = '1';
	}
	objFrm.submit()
}

function setPageNumberForRemoveCart(){
	var objFrm = document.forms[0];
	strHidPageNumber = objFrm.hidPageNum.value;
	strHidPageSize = objFrm.hidRecordsPerPage.value;
	strTotalRecordCount = objFrm.hidTotalRecordCount.value;
	
	if(strHidPageNumber != ""){
		strHidPageNumber = parseInt(strHidPageNumber,10)
	}
	
	if(strHidPageSize != ""){
		strHidPageSize = parseInt(strHidPageSize,10)
	}
	
	if(strTotalRecordCount != ""){
		strTotalRecordCount = parseInt(strTotalRecordCount,10)
	}
	
	if(strHidPageNumber != "" && strHidPageSize != "" && strTotalRecordCount != ""){
		intNumber = Math.ceil((strTotalRecordCount-1)/strHidPageSize)
	}
	if(intNumber < strHidPageNumber){
		objFrm.hidPageNum.value = intNumber
	}
	return true;
}

function focusOnLOginPage(mode){
	if(mode=='2'){
		objFirstName = getObj("txtFirstName",1);
		if(typeof(objFirstName)=='object'){
			objFirstName.focus();
		}
	}else{
		objTxtLogin = getObj("txtUserName");
		if(typeof(objTxtLogin)=='object'){
			objTxtLogin.focus();
		}		
	}
}

function setTabSample(obj) 
{
if (!document.getElementById){return};
for (i=1; i<5; i++) 
{	
	if(obj==1){
		objDiv1	= document.getElementById("leftBody");
		objDiv1.style.visibility='visible';
		objDiv2	= document.getElementById("MiddleBody"); 
		objDiv2.style.visibility='hidden';
		objDiv3	= document.getElementById("LastBody"); 
		objDiv3.style.visibility='hidden';
	}
	else if(obj==2){
		objDiv1	= document.getElementById("leftBody"); 
		objDiv1.style.visibility='hidden';
		objDiv2	= document.getElementById("MiddleBody"); 
		objDiv2.style.visibility='visible';
		objDiv3	= document.getElementById("LastBody"); 
		objDiv3.style.visibility='hidden';
		if ((navigator.appName=="Netscape") && (navigator.appVersion.indexOf("Macintosh")>0))
		    objDiv2.style.top ="-167px";
		else if ((navigator.appName=="Microsoft Internet Explorer") && (navigator.appVersion.indexOf("Macintosh")>0))
		    objDiv2.style.top ="-150px";		
		else
		   objDiv2.style.top ="-150px";
		}
	else if(obj==3){
		objDiv1	= document.getElementById("leftBody"); 
		objDiv1.style.visibility='hidden';
		objDiv2	= document.getElementById("MiddleBody"); 
		objDiv2.style.visibility='hidden';
		objDiv3	= document.getElementById("LastBody"); 
		objDiv3.style.visibility='visible';
		if ((navigator.appName=="Netscape") && (navigator.appVersion.indexOf("Macintosh")>0))
		    objDiv3.style.top ="-334px";
		else if ((navigator.appName=="Microsoft Internet Explorer") && (navigator.appVersion.indexOf("Macintosh")>0)){
			objDiv3.style.top ="-202px";
		    }
		else
		   objDiv3.style.top ="-300px";
	}
	if (i == obj) 
	{	
		document.getElementById("tabBorder" + i).style.backgroundColor = "#ffffff"; 
		if(i<4)		
		document.getElementById(i).style.fontWeight = "bold";			
	} 
	else 
	{
		document.getElementById("tabBorder" + i).style.backgroundColor = "#999999"; 
		if(i<4)
		document.getElementById(i).style.fontWeight = "normal";
	}
}
}

function setTabSubmit(iCount)
{	
	var strStoryGUID,strAssetGUID,strIsCart,strURL;
	strStoryGUID = document.forms[0].hidStoryGUID.value;
	strAssetGUID = document.forms[0].hidAssetGUID.value;
	strIsCart = document.forms[0].hidIsCart.value;
	strURL = document.forms[0].hidURL.value;
	
	strLink= "SampleSearchResultPage.aspx" + "?hidStoryGUID=" + strStoryGUID + "&hidAssetGUID=" + strAssetGUID + "&hidIsCart="+strIsCart + "&hidURL=" +escape(strURL);
	if(iCount==1)
	{
		window.document.forms[0].action= strLink + '&SelTab=1'
		window.document.forms[0].method="Post"
		window.document.forms[0].submit()
	}
	else
	{
		window.document.forms[0].action=strLink + '&SelTab=2'
		window.document.forms[0].method="Post"
		window.document.forms[0].submit()
	}
}

function ResetButton()
{	
	window.document.forms[0].reset();
	return false;	
}

/* For Preferences Saved */
function saveClickedPrefTape(iUSStateId)
			{	
				var txtAddress1 = getObj("txtAddress1","1");
				var txtAddress2 = getObj("txtAddress2","1");
				var txtAddress3 = getObj("txtAddress3","1");
				var txtZip = getObj("txtZip","1");
				var txtCity = getObj("txtCity","1");
				var txtPhone =  getObj("txtTelephone","1");
				var cboCountry = getObj("cmbCountry","1");
				var cboState = getObj("cmbSelState","1");
				var txtState = getObj("txtState","1");
				
				if(isBlank(txtAddress1,'Address')) return false;
				if(isQuotes(txtAddress1,/*b*/'Address'/*e*/,1)) return false;
				
				if(txtAddress2.value.length > 0)
				{
					if(isQuotes(txtAddress2,/*b*/'Address2'/*e*/,1)) return false;
				}

				if(txtAddress3.value.length > 0)
				{
					if(isQuotes(txtAddress3,/*b*/'Address3'/*e*/,1)) return false;
				}
 				
 				if(txtZip.value.length>0)
   				{
					if(isQuotes(txtZip,'Postal Code',1))	return false;
					else if(!isName(txtZip,'PostalCode',0,10,0)) return false;
				}

				if(txtCity.value.length > 0)
				{
					if(isQuotes(txtCity,/*b*/'City'/*e*/,1)) return false;
				}
				
				if(isBlank(txtPhone,'Telephone number')) return false;
				if(!isTelePhone(txtPhone,'Telephone number')) return false; 	               
		       
 				if(cboCountry[cboCountry.selectedIndex].value == iUSStateId) 
				{
					if(cboState.selectedIndex == 0)
					{
						alert("Please select a State/Province")
						cboState.selectedIndex=0;
						return false;
					} 
				}
				else
				{
					if(txtState.value.length > 0)
					{
						if(isQuotes(txtState,/*b*/'State'/*e*/,1)) return false;
					}
				}
 
				if(cboCountry.selectedIndex == 0)
				{
					alert("Please select a Country");
					return false;
				}
			  
			}  // end function saveClicked
			
			function PasswordHelpXML()
			{
				var sLink = '../Login/PasswordHelp.aspx?isPopup=1';
				popupWin(sLink ,'430','333','no');		
			}	
			
			// to catch enter key press in login registration page
			function catchKeyPressLogin(code,sender,ServerPath,ApplicationPath,PageName,iRegister) 
			{
				if( code == '13') 
				{
					if (iRegister == 1) 
					{
						return validateRegister();
					}
					else
					{	
						/*if(typeof document.forms[0].hidEnterPress == 'object')
						{
							document.forms[0].hidEnterPress.value = '1';
						}*/
						return validateLogin(ServerPath,ApplicationPath,PageName);
					
					}
				
				}
          } 
          
          // catch enter key press in login registration page For Netscape
          function catchKeyPressLoginNS(event,ServerPath,ApplicationPath,PageName,iRegister) 
          {
			var code ;
			code = event.which;
			if(code == '13') {
				if (iRegister == 1) 
				{
					
					return validateRegister();
					
				}
				else
				{	
					if(typeof document.forms[0].hidEnterPress == 'object')
					{
						document.forms[0].hidEnterPress.value = '1';
					}
					return validateLogin(ServerPath,ApplicationPath,PageName);
					
				}
				
			} 
          }
          // end catch enter key press in login registration page for IE and Netscape 
          
           // For Cart Navigation changes
          function MoveToStep(strStep)
          {	
			
			if(typeof document.forms[0].hidNavigate == 'object') 
			{
				document.forms[0].hidNavigate.value = strStep;
			}
			document.forms[0].submit();
			return false;
		}
          //For Cart Navigation changes
          
          
          /*function SaveMyAccount(strServer,strPort)
		{
			//alert(strServer + " , " + strPort);
			var txtNewPassword = getObj("txtNewPassword","1");
			var txtCurrPassword = getObj("txtCurrentPassword","1");
			var txtVerPassword = getObj("txtVerifyPassword","1");
			var rdoPush = getObj("rdoPush","2");
			var rdoPull = getObj("rdoPull","2");
			var rdoTape = getObj("rdoTape","2");
			var rdoAptn = getObj("rdoAptn","2");
			var rdoWindowsPlayer = getObj("rdoWindowsPlayer","2");
			var rdoQuickPlayer = getObj("rdoQuickPlayer","2");
			
				
			
			//validation starts
			if(trimtxt(txtNewPassword.value).length != 0 || trimtxt(txtVerPassword.value).length != 0)
			{
				if (isBlank(txtCurrPassword,'Current Password')) return false;
				if (txtCurrPassword.value.length<4)
				{
					alert('Please enter password more than 3 characters');
					txtCurrPassword.focus();
					return false;
				}	
				if (isBlank(txtNewPassword,'New Password')) return false;
				if (txtNewPassword.value.length<4)
				{
					alert('Please enter password more than 3 characters');
					txtNewPassword.focus();
					return false;
				}	
				if (isBlank(txtVerPassword,'Verify Password')) return false;
				if(trimtxt(txtVerPassword) == '')
				{
					alert("Please verify your password.");
					txtVerPassword.focus();
					return false;
				}
    			if (txtNewPassword.value !== txtVerPassword.value)
				{
					alert('Verify Password and Password should be same');
					txtNewPassword.focus();
					return false;
				}
			}
			// validation ends
			
			
			var deliveryId ;
			var videostreamId ;
			
			if(rdoPull.checked == true)
			{
				deliveryId = 1
			}
			else if(rdoPush.checked == true)
			{
				deliveryId = 2
			}
			else if(rdoTape.checked == true)
			{
				deliveryId = 4
			}
			else if(rdoAptn.checked == true)
			{
				deliveryId = 5
			}
			
			if(rdoWindowsPlayer.checked == true)
			{
				videostreamId = 9
			}
			else if(rdoQuickPlayer.checked == true)
			{
				videostreamId = 10
			}
			document.forms[0].hidPassword.value = txtNewPassword.value;
			document.forms[0].hidCurrPassword.value = txtCurrPassword.value;
			document.forms[0].hidDeliveryID.value = deliveryId;
			document.forms[0].hidVideoStreamID.value = videostreamId;
			document.forms[0].hidSave.value = "SAVE";
			document.forms[0].submit();
			return false;
		}*/
		
		  function SaveMyAccount(strServer,strPort)
		{
			//alert(strServer + " , " + strPort);
			var txtNewPassword = getObj("txtNewPassword","1");
			var txtCurrPassword = getObj("txtCurrentPassword","1");
			var txtVerPassword = getObj("txtVerifyPassword","1");
			var ObjrdoBrodcast=getObj("rdoBrodcast",2)
			var ObjrdoStreaming=getObj("rdoStreaming",2)			
			if (ObjrdoBrodcast)
			{
				if (ObjrdoBrodcast.checked==true)
				{
			var rdoPush = getObj("rdoPush","2");
			var rdoPull = getObj("rdoPull","2");
			var rdoTape = getObj("rdoTape","2");
			var rdoAptn = getObj("rdoAptn","2");
			var rdoPushTele = getObj("rdoPushTele","2");
			var rdoPushPath = getObj("rdoPushPath","2");			
			var rdoDVD = getObj("rdoDVD","2");			
				}
				else
				{
					var rdoWindowVideoFormat =getObj("rdoWindowVideoFormat","2");
					var rdoQuickTimeVideoFormat =getObj("rdoQuickTimeVideoFormat","2");
				}
			}	
			else
			{
				var rdoPush = getObj("rdoPush","2");
				var rdoPull = getObj("rdoPull","2");
				var rdoTape = getObj("rdoTape","2");
				var rdoAptn = getObj("rdoAptn","2");
				var rdoPushTele = getObj("rdoPushTele","2");
				var rdoPushPath = getObj("rdoPushPath","2");			
				var rdoDVD = getObj("rdoDVD","2");	
			}		
			var rdoWindowsPlayer = getObj("rdoWindowsPlayer","2");
			var rdoQuickPlayer = getObj("rdoQuickPlayer","2");
			var objcboVDOption = getObj("cboVDOption","1");
			//validation starts
			if(trimtxt(txtNewPassword.value).length != 0 || trimtxt(txtVerPassword.value).length != 0)
			{
				if (isBlank(txtCurrPassword,'Current Password')) return false;
				if (txtCurrPassword.value.length<4)
				{
					alert('Please enter password more than 3 characters');
					txtCurrPassword.focus();
					return false;
				}	
				if (isBlank(txtNewPassword,'New Password')) return false;
				if (txtNewPassword.value.length<4)
				{
					alert('Please enter password more than 3 characters');
					txtNewPassword.focus();
					return false;
				}	
				if (isBlank(txtVerPassword,'Verify Password')) return false;
				if(trimtxt(txtVerPassword) == '')
				{
					alert("Please verify your password.");
					txtVerPassword.focus();
					return false;
				}
    			if (txtNewPassword.value !== txtVerPassword.value)
				{
					alert('Verify Password and Password should be same');
					txtNewPassword.focus();
					return false;
				}
			}
			// validation ends
			
			
			var deliveryId ;
			var videostreamId ;
			
			if (ObjrdoBrodcast)  // For Streaming option is activated from DB
			{
				if (ObjrdoBrodcast.checked==true)
				{
			if(rdoPull.checked == true)
			{
				deliveryId = 1
			}
			else if(rdoPush.checked == true)
			{
				deliveryId = 2
			}
			else if(rdoTape.checked == true)
			{
				deliveryId = 4
			}
			else if(rdoAptn.checked == true)
			{
				deliveryId = 5
			}
			else if(rdoPushTele.checked == true)
			{
				deliveryId = 6
			}
			else if(rdoDVD.checked == true)
			{
				deliveryId = 8
			}
			else if(rdoPushPath.checked == true)
			{
				deliveryId = 7
			}
				}
				else		///Added for Streaming imp
				{	
					if(rdoWindowVideoFormat.checked == true)
					{
						deliveryId = 9
					}
					else if(rdoQuickTimeVideoFormat.checked ==true)
					{
						deliveryId = 10
					}				
				}
			}
			else  // For Streaming option is not activated from DB
			{
					if(rdoPull.checked == true)
					{
						deliveryId = 1
					}
					else if(rdoPush.checked == true)
					{
						deliveryId = 2
					}
					else if(rdoTape.checked == true)
					{
						deliveryId = 4
					}
					else if(rdoAptn.checked == true)
					{
						deliveryId = 5
					}
					else if(rdoPushTele.checked == true)
					{
						deliveryId = 6
					}
					else if(rdoDVD.checked == true)
					{
						deliveryId = 8
					}
					else if(rdoPushPath.checked == true)
					{
						deliveryId = 7
					}
			}
			
			if(rdoWindowsPlayer.checked == true)
			{
				videostreamId = 9
			}
			else if(rdoQuickPlayer.checked == true)
			{
				videostreamId = 10
			}
			document.forms[0].hidPassword.value = txtNewPassword.value;
			document.forms[0].hidCurrPassword.value = txtCurrPassword.value;
			document.forms[0].hidDeliveryID.value = deliveryId;
			document.forms[0].hidVideoStreamID.value = videostreamId;
			document.forms[0].hidSaveMyAcc.value = "SAVE";
			if (typeof objcboVDOption == 'object')
			{
				document.forms[0].hidDeliveryFormat.value = objcboVDOption.options[objcboVDOption.selectedIndex].value;
			}
			
			
			document.forms[0].submit();
			return false;
		}

		function OpenMyAccount(path,newWindow)
		{
			if(newWindow == 'TRUE')
			{
				window.open(path,'','resizable=yes,width=700,height=450,scrollbars=yes,menubar=yes,status=yes,toolbar=yes,location=yes','yes');
			}
			else if(newWindow == 'FALSE')
			{
				submitPageFE(path);
				return false;
			}
		}
		
		
	function RemoveAllAsset(Id,varType,operationType,AssetCount,iUserType,mstrUserStatus,PreApproved,IsTNMCartAllowed,CallingPage,FromWhere,ApplicationName,StoryAssetGUID,strServername)
	{
			
		if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
		if(IsTNMCartAllowed.toUpperCase()=='TRUE'){
		IsTNMCartAllowed = '1';
		}else{
			IsTNMCartAllowed = '0';
		}
			
		if(Id==0)
		{
			if(IsTNMCartAllowed=='0')
			{
				//document.forms[0].storyid.value=storyid;
				var strLink;
				
				if(CallingPage=='Story')
					strDefaultLink = "https://" + strServername + "/" + ApplicationName + '/br/Sample/SampleWrapperPage.aspx?hidIsCart=Y&hidStoryGUID='+StoryAssetGUID;
				else
					strDefaultLink = "https://" + strServername + "/" + ApplicationName + '/br/Sample/SampleWrapperPage.aspx?hidIsCart=Y&hidAssetGUID='+StoryAssetGUID;
				submitPageFE(strDefaultLink);					
				return false;
			}
			else 
			{
				if(CallingPage=='Story'){
					if(AssetCount=='0')
						{
							alert('There are no media assets associated with this story.'); 
							return false;	
						}
				}
			}
		}
		else
		{
			if(mstrUserStatus == '4' && PreApproved =='0') //For New User
			{
				alert('Your registration is still in progress.\nYou will receive a notification when your registration is approved after which you will be allowed to order media.')
				return false;
			}
			if(iUserType=='8' || iUserType=='4')
			{
				alert("We're sorry, but this feature is only available to registered media journalists.\nYou are currently on a demonstration account and do not have rights to order any media assets.\nPlease send an email to mediarelations@thenewsmarket.com if you do need to order assets. Thank you.");
				return false;
			} 		
			if(CallingPage=='Story'){
				if(AssetCount==0)
				{
					alert('There are no media assets associated with this story.'); 
					return false;	
				}	
			}
		}
		
		GetRemovedAssetCheckedCount();
 		if(checkboxcount == 0)
		{
			switch(operationType)
			{
				case 1:
					alert("To add Media Assets to the Cart,please check atleast one Media Asset.");		       
					break;

				case 2:
					alert("To remove Media Assets, please check at least one Media Asset.");		       
					break;

				case 3:
					alert("To move Media Assets,please check atleast one Media Asset.");		       
					break;
			}
			return false;
			
		}
		else
		{
			
			//set the removed flag and set the removed assets
			//alert(checkedIds);
			document.forms[0].hidRemovedAssetIDs.value = checkedIds;
			document.forms[0].hidRemoveClicked.value = "REMOVE";
			//alert(document.forms[0].hidRemovedAssetIDs.value);
			//alert(document.forms[0].hidRemoveClicked.value);
			return true;
		}	
	}
	
	function GetRemovedAssetCheckedCount()
	{
		totalcheckboxcount = 0;
		checkboxcount = 0;
	    checkedIds = "";
	    
		for(i=0;i < window.document.forms[0].elements.length; i++)
		{
			if(window.document.forms[0].elements[i].type == "checkbox")
			{
				totalcheckboxcount = totalcheckboxcount + 1;
				if(window.document.forms[0].elements[i].checked == true)
				{
					if(checkedIds == "")
					{
						checkedIds = window.document.forms[0].elements[i].value;
					}
					else
					{
						checkedIds = checkedIds + "," + window.document.forms[0].elements[i].value;
					}
					checkboxcount = checkboxcount + 1;
				}
			}
		}
	}
	
	function DisablePalRadio(intPathFire,intNumberOfFormats,iLockNTSC)
	{
		
		var iLoopCount ;
		if (intPathFire == 1) 
			{
				if ( iLockNTSC == 1) 
				{
					for (iLoopCount = 0;iLoopCount < intNumberOfFormats ;iLoopCount++)
					{
						var objTNMFormat = getObj("TnmTapeRadioList_" + iLoopCount)		
						if (typeof (objTNMFormat) == 'object')
						{
							if (iLoopCount != 0 )
							{
								objTNMFormat.disabled = true;
							}
							else
							{
								objTNMFormat.disabled = false;
								objTNMFormat.checked = true;
							}
						}
					}
				}
				
			 }
			else
			{
				for (iLoopCount = 0;iLoopCount < intNumberOfFormats ;iLoopCount++)
				{	
					var objTNMFormat = getObj("TnmTapeRadioList_" + iLoopCount)		
					if (typeof (objTNMFormat) == 'object')
					{
							
						objTNMFormat.disabled = false;
							
						
					}
				
				}
				
			}
				
		
		
	}
	
	function DeliveryRadioChangedMyAccount(intDelivery,intLockNTSC)
	{
		
		var objcboVideoOption = getObj("cboVDOption")
		if (typeof objcboVideoOption == 'object')
		{
			if (intLockNTSC == 1) 
			{
				if (intDelivery == 7)
				{
					objcboVideoOption.options[0].selected = true;
					objcboVideoOption.disabled = true;
					
				}
				else
				{
					objcboVideoOption.disabled = false;
				}
			}	
		}		
	}
	function SelectDeliveryFormat(intDeliveryFormat,intLockNTSC)
	{	
		
		var objChecked;
		var iLoopCount;
		var objrdoPathFire = getObj("rdoPushPath")
		var objcboVideoOption = getObj("cboVDOption")
		objChecked = DeliveryChecked(objrdoPathFire)
		if (typeof objcboVideoOption == 'object')
		{
			if (objChecked == true)
			{	
				if (intLockNTSC == 1) 
				{
					objcboVideoOption.options[0].selected = true;
					objcboVideoOption.disabled = true;
				}
				else
				{
					objcboVideoOption.disabled = false;
				
				for (iLoopCount=0 ;iLoopCount< objcboVideoOption.options.length;iLoopCount++)
				{
					if (objcboVideoOption.options[iLoopCount].value == intDeliveryFormat)
					{	
						objcboVideoOption.options[iLoopCount].selected = true;
					}
				}
				}	
			}
			else
			{	
				//objcboVideoOption.disabled = false;
				
				for (iLoopCount=0 ;iLoopCount< objcboVideoOption.options.length;iLoopCount++)
				{
					if (objcboVideoOption.options[iLoopCount].value == intDeliveryFormat)
					{	
						objcboVideoOption.options[iLoopCount].selected = true;
					}
				}
				
			}
		}	
	}


// Tejas - Code to handle the Mac bug  where the delivery option radio button selection goes off on change of delivery option.
function PageOnLoad()
{

	var strRadio= eval('document.forms[0].hidRadioId')
	if (strRadio.value != '')
	{
		var strRadioId = 'objContainerControl_objTemplateContainerControl_objContentControl_objMediaDeliveryControl_' + strRadio.value;
		var objRadio = document.getElementById(strRadioId)
		objRadio.checked=true;
		
	}
}
// tejas
	function DeliveryPrefChanged(ControlID)
	{	
		var hidDelPref = document.getElementById("hidDeliveryPref");
		hidDelPref.value=ControlID;		
		document.forms[0].submit();
	}
	function CartStep2DeliveryPrefChanged(ControlID,strServerName,strServerPath)
	{	
		var hidDelPref = document.getElementById("hidDeliveryPrefCheckOut");
		hidDelPref.value=ControlID;		
		document.forms[0].submit();
	}	



/* added for IBM */

function frmSubmit(strSubmitPage)
{	
	

	var objFrmName =  'window.document.forms[0]';
	var objFrm = eval(objFrmName);
	
	objCategory=getObj("cboCategory");
	objFrm.hidChildSearchId1.value = 0;
	if(typeof objCategory == 'object')
	{
		if (typeof objFrm.hidChildSearchId == 'object')
		{
			objFrm.hidChildSearchId.value	= objCategory.options[objCategory.selectedIndex].value
		}	
		
		if (typeof objFrm.hidProductType == 'object')
		{
			objFrm.hidProductType.value	= objCategory.options[objCategory.selectedIndex].text;
		}	
	}

	if (typeof(objFrm.hidPageNum) == 'object')
	{
		objFrm.hidPageNum.value="1";
	}
	
	objSubCategory=getObj("cboSubCategory");
	if(typeof objSubCategory == 'object')
	{
		if (typeof objFrm.hidChildSearchId1 == 'object')
			objFrm.hidChildSearchId1.value	= objSubCategory.options[objSubCategory.selectedIndex].value
	}

	objYearFilter=getObj("cboYearFilter");
	if(typeof objYearFilter == 'object')
	{
		if (typeof objFrm.hidChildSearchId2 == 'object')
			objFrm.hidChildSearchId2.value	= objYearFilter.options[objYearFilter.selectedIndex].value
	}
	
	if (typeof(objFrm.hidSearchChanged) == 'object') 
	{
		objFrm.hidSearchChanged.value = '0';
	}
	
	//objFrm.hidIsPostBack.value = '1';
	
	if (typeof objFrm.hidIsPostBack == 'object')
	objFrm.hidIsPostBack.value = '1';
	
	if(objFrm.hidChildSearchId1.value == 0)
	{
		//Rana - Updated
		if (typeof objFrm.hidSubCategoryType == 'object')
		{
			objFrm.hidSubCategoryType.value = "";
		}
		//Original
		//objFrm.hidSubCategoryType.value = "";	
	}
	else
	{
		if(objFrm.hidProductType.value == 'Products')
		{
			if(typeof(objSubCategory) == 'object')
			{
				objFrm.hidSubCategoryType.value = objSubCategory.options[objSubCategory.selectedIndex].text;
			}
		}
		else
		{
			objFrm.hidSubCategoryType.value = "";
		}
	}
	
	objFrm.submit();
	
	return false;
}

function setCategoryCombo(strValue)
{

	var objCategory = getObj("cboCategory")
	if(typeof(objCategory) =='object')
	{
		for(var i=0; i<objCategory.length;i++)
		{
			if(objCategory.options[i].value == strValue)
			{
				objCategory.selectedIndex = i;
			}
		}
	}
}

function setSubCategoryCombo(strValue)
{
//alert(strValue);

	var objFrm = eval(objFrmName);
	//if(hidChildSearchId1 == 'object')
	//{
		var strSubCatId = objFrm.hidChildSearchId1.value;
		var objSubCategory = getObj("cboSubCategory")
		 
		if(typeof(objSubCategory) =='object')
		{
			for(var i=0; i< objSubCategory.length;i++)
			{
				if(objSubCategory.options[i].value == strSubCatId)
				{
				objSubCategory.selectedIndex = i;
				}
			}
		}
	//}
}


function categoryComboChange()
{
	//alert("Called");
	var objsubofsubCategory = getObj("cboSubCategory")	
	var objsubofsubDiv=document.getElementById("idSearchDiv2");
		
	if(typeof(strSubCatArray) != 'object')
	{
		return false;
	}
	
	
	
	var objCategory=getObj("cboCategory");
	//alert(objCategory.options[objCategory.selectedIndex].text);
	if(typeof(objCategory) =='object')
	{
	//alert("Yes");
	
	
		var objDiv=document.getElementById("idSearchDiv1");
		var strCategory;
		var nCategory;
		if(objCategory.selectedIndex > 0)
		{
			strCategory=objCategory.options[objCategory.selectedIndex].text;
			nCategory=objCategory.options[objCategory.selectedIndex].value;
			
		}
		var objSubCategory=getObj("cboSubCategory");
		var x=0;
		var strSubCatHead="";
		
		
		
		if(typeof(objSubCategory) =='object')
		//alert("cubcat type :" + typeof(objSubCategory));
		
		objSubCategory.style.visibility='hidden';
		
		
		if(typeof(objDiv) =='object')
		objDiv.style.visibility='hidden';
		
		var x=1;
		if(typeof objSubCategory == 'object')
		{
		    //alert("sub cat=obj");
		    
			objSubCategory.options.length=0;
			objSubCategory.options[0]=new Option("--Show All--", "0");
			
			var isSubOfSub=0;
			for(var i=0; i<strSubCatArray.length ;i++)
			{	
					if(strCategory==strSubCatArray[i][3])
					{					
						isSubOfSub=1;						
						objSubCategory.options[x] = new Option(strSubCatArray[i][2],strSubCatArray[i][1]); 
						x=x+1;					
					}
			}
			
			//alert(objCategory.selectedIndex);
			if(isSubOfSub == 1 && objCategory.selectedIndex != 0)				
			{
				objDiv.style.visibility='visible';
				objSubCategory.style.visibility='visible';
			}
			else
			{
				objDiv.style.visibility='hidden';
				objSubCategory.style.visibility='hidden';
			}
		}		
	}	
}

/* Functions to chane TD colour on MouseOver and MouseOut Events */

function MenuTdMouseoverColour(obj)
{
	obj.className = "MenuOnPageBackground";
}

function MenuTdMouseoutColour(obj)
{
	obj.className = "MenuBackground";
}



/* MyAccount page OnClick */
	function CatchKeyPress(event,mode,ServerName,ServerPort)
			{
			
			
				if (NS4)
					code = event.which;
				else
					code = event.keyCode;		
				if(code==13)
				{
					return SaveMyAccount(ServerName,ServerPort);
				}
				else	
					CheckTab(event,mode)
			}
	
	/* MyAccount page OnClick */