//for testing cache
/*function moveToPrivacyPolicy()
{
		//sLink = 'Mrbase/br/Help/TermsAndConditionsPage.aspx?type=5&FromRegistration=1';
		sLink = '../br/Help/TermsAndConditionsPage.aspx?type=5&FromRegistration=1';
		submitPageFE(sLink)
		return true;
}*/

function goPage(strMRserverPath)
{
	window.document.forms[0].action= strMRserverPath + "/br/Login/Landing.aspx";
	window.document.forms[0].submit();
}
//cookie functions
function getCookie(NameOfCookie){	
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;      
        return document.cookie.substring(begin, end);
    } 
  }
  return null;
}

/*function setCookie(NameOfCookie, value, expiredays,path) {
	var ExpireDate = new Date ();	
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + value + 
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) +
    ((path) ? "; path=" + path : "" );
    
}*/

/*function delCookie (NameOfCookie,path) {	
  if (getCookie(NameOfCookie)) {	
	var Days=3*24*60*60*1000;
	var expDate=new Date()
	expDate.setTime(expDate.getTime()-Days);
    document.cookie = NameOfCookie + "=" +
    ((path) ? "; path=" + path : "" ) +
    "; expires=" + expDate.toUTCString;
  }  
}*/

/*function DoCookieStuff(cookiename,maxSearchValue)
{
	if(maxSearchValue<0)
	{
		return 0;
	}
	else
	{
		if(cookie_check()==1)
		{
			times_visited=eval(getCookie(cookiename))+1;	
			if (times_visited >maxSearchValue) 
			{	
				if(times_visited-maxSearchValue==1)
				{					
					//setCookie(cookiename,times_visited,365,"/");  
				}	
 				return 1;
			}
			else
			{	
				//setCookie(cookiename,times_visited,null,"/");  
				//setCookie(cookiename,times_visited,365,"/");  
				return 0;
			}
		}
		else
		{
			return 1;
		}	
	}
}*/

/*function cookie_check()
{
	document.cookie = "tnmcookie=set"
	if (document.cookie.indexOf("tnmcookie=set")!=-1)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}*/

function Paging_PrevNext(iFlag)
	{
	    var objFrm = window.document.forms[0];//eval('document.'+strForm)
	   	if(iFlag == 0)
		{
			objFrm.hidPageNum.value= parseInt(objFrm.hidPageNum.value,10) -1
		}
		else
		{
			objFrm.hidPageNum.value= parseInt(objFrm.hidPageNum.value,10) + 1
		}
		//Changes for hybrid starts
		if (typeof document.forms[0].hidFilterMainAttributeID  == 'object' && typeof document.forms[0].hidFilterRifineID == 'object' )
		{
			document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
		}
		if (typeof document.forms[0].hidYearMainAttributeID  == 'object' && typeof document.forms[0].hidYearRifineID == 'object' )
		{
			document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Name  == 'object' && typeof document.forms[0].Search_Values_Name == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Id  == 'object' && typeof document.forms[0].Search_Values_Id == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
		}
		//Changes for hybrid ends
	}
	
	function Paging_SelectedIndexChanged(obj)
	{
	    var objFrm = window.document.forms[0];
	   	//alert(obj[obj.selectedIndex].value)
		objFrm.hidRecordsPerPage.value = obj[obj.selectedIndex].value
//		objFrm.hidSelectedIndexChanged.value='1'
		objFrm.hidPageNum.value = '1'
		
		//Changes for hybrid starts
		if (typeof document.forms[0].hidFilterMainAttributeID  == 'object' && typeof document.forms[0].hidFilterRifineID == 'object' )
		{
			document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
		}
		if (typeof document.forms[0].hidYearMainAttributeID  == 'object' && typeof document.forms[0].hidYearRifineID == 'object' )
		{
			document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Name  == 'object' && typeof document.forms[0].Search_Values_Name == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Id  == 'object' && typeof document.forms[0].Search_Values_Id == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
		}
		//Changes for hybrid ends
		
		
		var objTopPage = getObj("objTopPagingControl_cboRecordsPerPage",2)
		var objBottomPage = getObj("objBottomPagingControl_cboRecordsPerPage",2)
		if(typeof(objTopPage) =='object'){
			for(var i=0; i<objTopPage.length;i++){
				if(objTopPage.options[i].value == obj[obj.selectedIndex].value){
					objTopPage.selectedIndex = i;
				}
			}
		}
		if(typeof(objBottomPage) == 'object'){
			for(var i=0; i<objBottomPage.length;i++){
				if(objBottomPage.options[i].value == obj[obj.selectedIndex].value){
					objBottomPage.selectedIndex = i;
				}
			}
		}
		if (typeof objFrm.hidPagesizeChanged == 'object')
		{
			objFrm.hidPagesizeChanged.value = "TRUE";
		}
		objFrm.submit()
	}
	
	function setPagingComboValue(strValue){
		var objTopPage = getObj("objTopPagingControl_cboRecordsPerPage",2)
		var objBottomPage = getObj("objBottomPagingControl_cboRecordsPerPage",2)
		if(typeof(objTopPage) =='object'){
			for(var i=0; i<objTopPage.length;i++){
				if(objTopPage.options[i].value == strValue){
					objTopPage.selectedIndex = i;
				}
			}
		}
		if(typeof(objBottomPage) == 'object'){
			for(var i=0; i<objBottomPage.length;i++){
				if(objBottomPage.options[i].value == strValue){
					objBottomPage.selectedIndex = i;
				}
			}
		}
	}

function popupWin(url, parWidth, parHeight, ch, showStatus, popName,toreSize)
{
	
	showStatus = (arguments.length==4) ? 'yes' : showStatus;
	popName = (arguments.length==5) ? 'Popup' : popName;
	
	if(arguments.length==7)
		toreSize = 'yes'
	else
		toreSize = 'no'
	popName = 'Popup';
		
	pWidth = (parWidth.toUpperCase()=='FULL') ? screen.availWidth : parWidth;
	pHeight = (parHeight.toUpperCase()=='FULL') ? screen.availHeight : parHeight;
	
	var topCal = ((screen.height  - pHeight)/2);
	var leftCal = ((screen.width - pWidth)/2);
	var popWin;
	winArgs = 'resizable='+toreSize+',toolbar=0, location=0, directories=0, status=' + showStatus + ', scrollbars=' + ch + ', width=' + pWidth + ', height=' + pHeight + ', left=' + leftCal + ', top=' + topCal;
	var strNameGUID =  genUID() + genUID() + genUID() + genUID();

	popWin = window.open("", strNameGUID, winArgs);
	 
	var isQuestPresent = url.indexOf("?");
	var firstPartUrl ='';
	var middlePartUrl = '';
	if(isQuestPresent!=-1)
	{
		firstPartUrl = url.substring(0,isQuestPresent);
		if (url.indexOf("objBackTo") != -1)
		{
			middlePartUrl = firstPartUrl+"?objBackTo:hidFromModule=FRONTEND&"
			url = middlePartUrl+url.substring(isQuestPresent+1);
		}
	}
	else
	{
		url = url + "?objBackTo:hidFromModule=FRONTEND"
	}
	
	
	url = url + "&UExisPopup=1"
	
	popWin.location.href=url;
	
	if (parWidth.toUpperCase()=='FULL' && parHeight.toUpperCase()=='FULL')
		popWin.window.moveTo(0,0);
	
	if (window.focus) 
			{
				popWin.focus();
			}

	
}
function submitPageFE(strQueryString)
{
/*alert(strQueryString);
alert(typeof document.forms[0].hidPageNum);
alert(typeof window.document.forms[0]);*/
	if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
	if ( typeof window.document.forms[0] == 'object')
	{
		window.document.forms[0].action = strQueryString;
		window.document.forms[0].submit();
	}
}

// Function by raju to enter key
NS4 = (document.layers) ? true : false;

function checkEnter(event,obj,validateFunName)
{ 	
	var code = 0;
	var objbtnlogin
	var bSubmitToValidate
	
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
		
	if (code==13)
	{
		if (typeof obj == 'object')
		{
			bSubmitToValidate = eval(validateFunName)
			
			if (bSubmitToValidate)
			{
				return true;
			}else
			{
				return false; 
			}
		}
	}
}

// addby raju
// This function called on on load of the body.
/*function onBodyLoad()
{
	objhidEnterClick = document.getElementById(objMastHeadName + '_hidEnterClick')			
		
	if (objhidEnterClick != null)
	{
		if (typeof objhidEnterClick == 'object')
			objhidEnterClick.value = 0;
	}
	
}*/

// added by raju, 
function winReload()
{
	// This code avoids the pop up of the Retry cancel Box and
	// resets the Listing page to the first Page
	window.document.forms[0].submit();
	return true;
		
}

function swapImgRestore(ctrlname,imgname) { 				
	//var e=window.document.getElementById(ctrlname) ;
	ctrlname.src=imgname;				
}

function swapImage(ctrlname,imgname) {
	//var e=window.document.getElementById(ctrlname);					
	ctrlname.src=imgname;	
}

 function setTabSelected(iSelectedIndex){
	var objForm=eval(document.forms[0]); 
	objForm.hidWhichTabSelected.value = iSelectedIndex;
	objForm.hidPageNum.value = '1'; // Page Number
	objForm.submit();
}

/*function moveToPrivacyPolicy(){
		sLink = '/HelpCenter/HelpCenter.aspx?type=5&FromRegistration=1';
		submitPageFE(sLink)
		return false;
	}*/
		
	function AssetSelectedIndexChanged(obj)
	{	
		var objFrm = window.document.forms[0];
		objFrm.hidAssetTypeChanged.value = "true";	
		objFrm.hidAssetTypeSelected.value = obj[obj.selectedIndex].value
		objFrm.submit();
	}

	function setTab(iSelectedIndex,iTabIndex)
	{
		var objForm=eval(document.forms[0]); 
		objForm.hidSelectedAssetTab.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;
		objForm.submit();
	}

	function setOrderHistoryTab(iSelectedIndex){
	var objForm=eval(document.forms[0]); 
	objForm.hidTabSelected.value = iSelectedIndex;
	objForm.hidPageNum.value = '1'; // Page Number
	objForm.submit();
	}