		//To get the slideshow the form should contain
		//one hidden field with id=hdnImages ,
		//containing image urls with semi colon separated.
		
		var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);

		if (! isIE) {
		HTMLElement.prototype.__defineGetter__("innerText", 
              function () { return(this.textContent); });
		HTMLElement.prototype.__defineSetter__("innerText", 
              function (txt) { this.textContent = txt; });
		}
		var img = new Array(5);
		var imgArray = new Array(5); //array to hold the images
		var idArray = new Array(5);
		var prArray = new Array(5);		
		var start = null; //start pointer
		var counter = 0; //counts the image sequences
		var delayTime = null; //user defined
		var intTotal=0;
		var urls = "";
		var ids = "";		
		var priority = "";
		var strCategogyList = "";
		
		function checkSession(objSession)
		{
			if(objSession.value == "true")
			{
				return true;
			}
			else
			{
				return false;
			}
		}
  
		function PrintCoupon(id,priority,strclick,strOption,objSession,objOption,objFormCustomerHome)
		{
		    var Session = document.getElementById(objSession); 
		    var Option = document.getElementById(objOption);
		    var FormCutomerHome = document.getElementById(objFormCustomerHome);
		    var SiteUrl = document.getElementById('hdnSiteUrl');
		     
		    if(checkSession(Session))
		    {	
				Option.value = "";
				if(strOption == "Print")
	    		{
	    			if(window.confirm("Offers are printed in accordance with the Terms & Conditions.") == true )
					{
						var url;
						if(priority != "50")
						{
							url= SiteUrl.value + 'Customer/PrintCoupon.aspx?option=' + strOption + '&id=' + id + '&click=' + strclick ;
							window.open(url,'PrintOffer','width=500,height=300,top=1,scrollbars=1,resizable=yes');						
						}
						else if(priority == "50")
						{
							url= SiteUrl.value + 'Customer/AlertView.aspx?id=' + id + '&click=' + strclick;
							window.open(url,'AlertView','width=500,height=600,top=1,resizable=yes,scrollbars=1,status=1');						
						}
					}
				}
				else
				{
					var url;
					if(priority != "50")
					{
						url= SiteUrl.value + 'Customer/PrintCoupon.aspx?option=' + strOption + '&id=' + id + '&click=' + strclick ;
						window.open(url,'PrintOffer','width=500,height=300,top=1,scrollbars=1,resizable=yes');						
					}
					else if(priority == "50")
					{
						url= SiteUrl.value + 'Customer/AlertView.aspx?id=' + id + '&click=' + strclick;
						window.open(url,'AlertView','width=500,height=600,top=1,resizable=yes,scrollbars=1,status=1');						
					}
				}
			}
			else
			{
				if(window.confirm("To view promotional items you must first register and then log in.\n Proceed to registration/login page?") == true )
				{
					Option.value = strOption + ";" + id + ";" + strclick;
					FormCutomerHome.submit();
				}
			}
			 	
		}
		
		//Function to redirect to advertisers website through SAA
		function GoToUrl(id, objSession, objOption, objFormCustomerHome)
		{			
			var Session = document.getElementById(objSession); 
		    var Option = document.getElementById(objOption);
		    var FormCutomerHome = document.getElementById(objFormCustomerHome);
		    var SiteUrl = document.getElementById('hdnSiteUrl');
		    
		     
		    if(checkSession(Session))
		    {	
			  url= SiteUrl.value + 'Customer/BluRouteClickThrough.aspx?id=' + id;			
			  window.open(url);
			}
			else
			{
				if(window.confirm("To view promotional items you must first register and then log in.\n Proceed to registration/login page?") == true )
				{
					Option.value = "Click;" + id + ";" + "True";
					FormCutomerHome.submit();
				}
			}
		}
				
		function checkExceed(objCount,objNext,objMaxItems)
		{
			var Next = document.getElementById(objNext);
			var MaxItems = document.getElementById(objMaxItems);
			var Count = document.getElementById(objCount);
			var blnEnd = false;
			
			if(Count.value < 10)
			{
			    alert(Check_Exceed_Alert);
			    blnEnd = true;			     
			}
			else if((Next.value )*10 >= (MaxItems.value))
			{
			    alert(Check_Exceed_Alert);
			    blnEnd = true;
			}
			return blnEnd ;			
		}
		
		function checkPrev(objNext)
		{
		    var Next = document.getElementById(objNext);  
			if(Next.value > 1)
			{
			return false;
			}
			else
			{
			alert(Check_First_Alert); 
			return true; 
			} 
		}
			
		 function showLabel(objMessage,objMessage1,objStatus,objStatus1,objCount, objNext, objMaxItems)
		 {
			var end=0;
			var start=0;
			var total=0;
			var end11=0;			
			
			var Message = document.getElementById(objMessage);
			var Message1 = document.getElementById(objMessage1); 
			var Status = document.getElementById(objStatus);
			var Status1 = document.getElementById(objStatus1);
			var Count = document.getElementById(objCount);
			var Next = document.getElementById(objNext);
			var MaxItems = document.getElementById(objMaxItems);
			
			
		  	//alert(document.getElementById("hdnCount").value);
			if(Message.innerText != "" )
			{
				Status.innerText = "";
			}
		    
			if(Count.value > 0)
			{
			
				if(Count.value == 10)
				{
					end = Next.value * 10;
					start =  end - 9;
					total = MaxItems.value;
					Status.innerHTML = "showing " + start + " to " + end + " of total " + total + " item(s)";
					//Status1.innerHTML = "showing " + start + " to " + end + " of total " + total + " item(s)";
				}
				else if(Count.value < 10)
				{
					total = MaxItems.value;
					if(total > 10)
					{
						end = total;
						start = parseInt(total) - parseInt(Count.value) + 1 ;
						total = MaxItems.value;
						Status.innerHTML = "showing " + start + " to " + end + " of total " + total + " item(s)";
						//Status1.innerHTML = "showing " + start + " to " + end + " of total " + total + " item(s)";
					}
					else
					{
						end11 = Next.value * 10;
						start =  end11 - 9;				
						end =  Count.value;
						Status.innerHTML = "showing " + start + " to " + end + " of total " + end + " item(s)<br />"; 
						//Status1.innerHTML = "showing " + start + " to " + end + " of total " + end + " item(s)"; 
					}
				}
			}		
		}
		
		function checkfirst(objMessage,objMessage1,objStatus,objStatus1,objCount, objNext, objMaxItems)
		{		
			var endF=0;
			var startF=0;
			var totalF=0;
			var end11F=0;			
			
			var Message = document.getElementById(objMessage);
			var Message1 = document.getElementById(objMessage1); 
			var Status = document.getElementById(objStatus);
			var Status1 = document.getElementById(objStatus1);
			var Count = document.getElementById(objCount);
			var Next = document.getElementById(objNext);
			var MaxItems = document.getElementById(objMaxItems);
		  	
			if(Message.innerText != "" )
			{
				Status.innerText = "";				
			}
		
			else if(Count.value > 0)
			{
				if(Count.value == 10)
				{
					endF = Next.value * 10;
					startF =  endF - 9;										
				}
				else if(Count.value < 10)
				{
					totalF = MaxItems.value;
					if(totalF > 10)
					{
						endF = totalF;
						startF = parseInt(totalF) - parseInt(Count.value) + 1 ;												
					}
					else
					{
						end11F = Next.value * 10;
						startF =  end11F - 9;				
					}
				}
			}
			
			
			if(startF > 1)
			{
				return false;
			}
			else
			{
				alert(Check_AlreadyInFirst_Alert); 
				return true; 
			} 
		}
		
		function checklast(objMessage,objMessage1,objStatus,objStatus1,objCount, objNext, objMaxItems)
		{
			var endL=0;
			var startL=0;
			var totalL=0;
			var end11L=0;			
			
			var Message = document.getElementById(objMessage);
			var Message1 = document.getElementById(objMessage1); 
			var Status = document.getElementById(objStatus);
			var Status1 = document.getElementById(objStatus1);
			var Count = document.getElementById(objCount);
			var Next = document.getElementById(objNext);
			var MaxItems = document.getElementById(objMaxItems);
			
			if(Message.innerText != "" )
			{
				Status.innerText = "";
			}
			else if(Count.value > 0)
			{
				if(Count.value == 10)
				{
					endL = Next.value * 10;
					startL =  endL - 9;
					totalL = MaxItems.value;					
				}
				else if(Count.value < 10)
				{
					totalL = MaxItems.value;
					if(totalL > 10)
					{
						endL = totalL;
						startL = parseInt(totalL) - parseInt(Count.value) + 1 ;
						totalL = MaxItems.value;						
					}
					else
					{
						end11L = Next.value * 10;
						startL =  end11L - 9;					
						endL =  Count.value;						
					}
				}
			}
			
			if(endL != totalL)
			{
				return false;
			}
			else
			{
				alert(Check_AlreadyInLast_Alert); 
				return true; 
			} 
		}
		
		function Fixfocus(event) 
		{
			if (event.keyCode==13)
			{
			//document.getElementById("btnSearch").focus();
			}
		}
		
		

			//FUNCTION FOR TREE VIEW			
			//-->
			function setFocus(objSearch)
			{
			  var Search =  document.getElementById(objSearch);
			  Search.focus(); 
			}
			
			function changeBg(obj,arg)
				{				    
				    if(imgB[arg] != null)
						obj.style.backgroundImage ="url(" + imgB[arg].src + ")"; 	
					
				}
				
			function ClearFields(objAllLocation, objLocation)
			{
			    var AllLocation = document.getElementById(objAllLocation);
			    var Location = document.getElementById(objLocation);
				if(AllLocation.checked)
				{
					Location.value="  ...in Zip/City/State";
					Location.disabled=true;				
					Location.style.backgroundColor="#d3d3d3";  
				}
				else
				{
					Location.value="  ...in Zip/City/State";
					Location.disabled=false;				
					Location.style.backgroundColor="#ffffff";  
				}	
			}	
				
			function checkLocation(objLocation)
			{
			
			   var Location = document.getElementById(objLocation);	   
			   if(Location.disabled == false && (Location.value == "" || Trim(Location.value) == "...in Zip/City/State"))
			   {
			       alert(StrSearch_alert);
			       return false;
			   }
			   else
			       return true; 	    
			}
			
			function CheckAllLoc(objAllLocation, objLocation)
			{
			    var AllLocation = document.getElementById(objAllLocation);
			    var Location = document.getElementById(objLocation);
				if(AllLocation.checked)
				{
					Location.disabled=true;
					Location.value = "  ...in Zip/City/State";				
					Location="#d3d3d3";  
				}
			}
			
			//Hidden campaign id to make the PrintCoupon page stay on front. - C010 - Mini viewer pop up ads
			function CouponOnLoad(objSession, objOption, objCampaignId, objClick)
			{	
				var Session = document.getElementById(objSession);
				var OptionOnLoad = document.getElementById(objOption);
				var Campaignid=document.getElementById(objCampaignId);
				var Click = document.getElementById(objClick);
				var SiteUrl = document.getElementById('hdnSiteUrl');
			  if(checkSession(Session))
		      {
				if(OptionOnLoad.value != null && OptionOnLoad.value != "")
				{
				    var strTitle = OptionOnLoad.value + "Offer";
					if(OptionOnLoad.value != 'Click')
					{
						//Added SiteUrl.value as a part of C035 Tweeks.
						url= SiteUrl.value + '/Customer/PrintCoupon.aspx?option=' + OptionOnLoad.value + '&id=' + Campaignid.value + '&click=' + Click.value ;
						window.open(url,strTitle,'width=500,height=600,top=1,resizable=yes,scrollbars=1');				
					}
					else if(OptionOnLoad.value == 'Click')
					{
						url= SiteUrl.value + '/Customer/BluRouteClickThrough.aspx?id=' + Campaignid.value;			
						window.open(url);
					}
					OptionOnLoad.value = "";
					Campaignid.value = "";
				}
				else if (Campaignid.value !=null && Campaignid.value !="")
				{
					window.open(SiteUrl.value+'/Customer/PrintCoupon.aspx?id='+Campaignid.value,'printoffer','width=500,height=600,top=1,resizable=yes,scrollbars=1');				
					Campaignid.value = "";
				}
		      }
			}
			
			function searchoffer(objSearch,objFormCustomerHome,strOption)
			{
				var chk = false;
				if (strOption == "search")
				{
					chk = checkLocation('txtLocation');
					if(!chk)
					{
					  return;
					}
				}
				else if (strOption == "first")
				{
					chk = checkfirst('lblMessage','lblMessage1','lblStatus','lblStatus1','hdnCount','hdnNext','hdnMaxItems');
					if(chk)
					{
					  return;
					}
				}
				else if (strOption == "last")
				{
					chk = checklast('lblMessage','lblMessage1','lblStatus','lblStatus1','hdnCount','hdnNext','hdnMaxItems');
					if(chk)
					{
					  return;
					}
				}
				else if (strOption == "next")
				{
					chk = checkExceed('hdnCount','hdnNext','hdnMaxItems');
					if(chk)
					{
					  return;
					}
				}
				else if (strOption == "back")
				{
					chk = checkPrev('hdnNext');
					if(chk)
					{
					  return;
					}
				}
				var Search = document.getElementById(objSearch);
				var FormCustomerHome = document.getElementById(objFormCustomerHome);
				Search.value = strOption;
				FormCustomerHome.submit();
			} 
			
			function Validate(LoginOption,objHdnLoginOption,objEmail,objPassword,objFormCustomerHome,objSaver,objAdvertiser,objAffiliate,objAffAgent,objRoleChosen,objSiteUrl,applicationName,applicationVersion,useragent)
			{
				
				//alert(useragent);
				//alert(applicationVersion);
				//alert(applicationName);
				if(!applicationVersion==null)				
				temp=applicationVersion.split("MSIE")
				if(!version==null)
				var version=parseFloat(temp[1])
				//alert(version);
				var strUrl = "../customerhomepage.aspx";
				var Email = document.getElementById(objEmail);
				var Password = document.getElementById(objPassword);
				var FormCustomerHome = document.getElementById(objFormCustomerHome);
				var HdnLoginOption = document.getElementById(objHdnLoginOption);				
				var Saver = document.getElementById(objSaver);
				var Adveriser = document.getElementById(objAdvertiser);
				var Affiliate = document.getElementById(objAffiliate);
				var AffAgent = document.getElementById(objAffAgent);
				var RoleChosen = document.getElementById(objRoleChosen);
				var SiteUrl = document.getElementById(objSiteUrl);
				
				if(Saver.checked)
				{
					RoleChosen.value = "CUSTOMER";
					strUrl = SiteUrl.value + "login/customerlogin.aspx";
				}
				if(Adveriser.checked)
				{
					//alert(applicationVersion +"inside"+ applicationName);
					
					/*if (applicationName !="Microsoft Internet Explorer" || version < 5.5)
					{
						alert("We are sorry but to register as an advertiser or an affiliate and to use all the features you must use a PC and Internet Explorer version 5.5 or newer.Click OK to Continue");
						return;
					}
					else if(useragent.indexOf('Opera')!=-1)
					{
						alert("We are sorry but to register as an advertiser or an affiliate and to use all the features you must use a PC and Internet Explorer version 5.5 or newer.Click OK to Continue");
						return;
					
					}*/
								
					RoleChosen.value = "ADVERTISER"
					strUrl = SiteUrl.value + "login/advertiserlogin.aspx";
				}
				if(Affiliate.checked)
				{
				   /* if ((applicationName!="Microsoft Internet Explorer") || (version < 5.5))
					{
						alert("We are sorry but to register as an advertiser or an affiliate and to use all the features you must use a PC and Internet Explorer version 5.5 or newer.Click OK to Continue");
						return;
					}
					else if(useragent.indexOf('Opera')!=-1)
					{
						alert("We are sorry but to register as an advertiser or an affiliate and to use all the features you must use a PC and Internet Explorer version 5.5 or newer.Click OK to Continue");
						return;
					
					}*/

					RoleChosen.value = "AFFILIATE"
					strUrl = SiteUrl.value + "login/affiliatelogin.aspx";
				}
			
			    HdnLoginOption.value = LoginOption;
				
				
				if( Email.value != "--Email address--" )
				{
					if(LoginOption == "Login")
					{	
						if(RoleChosen.value!= "AFFILIATE" && checkAll(objEmail,objPassword))
						{
							FormCustomerHome.submit();
						}
						else if(RoleChosen.value == "AFFILIATE" && checkAll(objEmail,objPassword))
						{
						       
								if(document.getElementById('rolepanel') != null )
									document.getElementById('rolepanel').className = 'rolepanel';
				
						}
						else 
						{
							HdnLoginOption.value = "";
						}
					}
					else //Login option Register
					{
						if(checkAll(objEmail,objPassword))
						{
						   //----------------------AKP START---------------------------------
						   //check here login option=register and  if(Saver.checked)
						   if((LoginOption == "Register")&& (Saver.checked))
						   {
						    
						     if(document.getElementById('confirmPasswordpanel') != null )
									document.getElementById('confirmPasswordpanel').className = 'confirmPasswordpanel';
									document.getElementById('txtConfirmPassword').focus();
									
						     
						   }
						   else
						   {
							FormCustomerHome.submit();
						   }
						  //----------------------AKP END---------------------------------	
						}
						else
						{
							HdnLoginOption.value = "";
						}
					}
				}
				else
				{	
					HdnLoginOption.value = "";
					self.location.href=strUrl;
				}
			}
			function CloseForm(result,objFrm,val)
			{
				if(document.getElementById('hdnRoleChosen').value != "LOST")
				{
			   
			   if(val == 1)
			   {
			     if( document.getElementById('hdnRoleChosen') != null)
			     {
			        document.getElementById('hdnRoleChosen').value="AFFAGENT";
			        document.getElementById(objFrm).submit(); 
			        return true;
			       } 

			   }  
			   if(val == 2)
			   {
			     if( document.getElementById('hdnRoleChosen') != null)
			      {
			        document.getElementById('hdnRoleChosen').value="AFFILIATE";		     			   
			        document.getElementById(objFrm).submit();
			        return true;
			       } 
			   }
			   if(val == 3)
			   {
			    document.getElementById('rolepanel').className = 'hide';
			    return false;
			   }
			   }
			   else
			   {
			     if(result == 'AFFILIATE')
				 {
					LostPassword('aff','hdnSiteUrl');	
			     }
				 else if(result == 'AFFAGENT')
				 {
					LostPassword('agt','hdnSiteUrl');	
			     }
			     document.getElementById('rolepanel').className = 'hide';
			     document.getElementById('hdnRoleChosen').value = null;
			   }
			     			
			}
			
			function CheckClick(objCheckCategory, objValue)
			{
				var CheckCategory = document.getElementById(objCheckCategory);
				CheckCategory.checked = false;
				Set_Cookie('CategoryLocation',objValue,'1','/');
			}


function CheckLostPassword(objSaver,objAdvertiser,objAffiliate,objResult,objSiteUrl)
{
	var Saver = document.getElementById(objSaver);
	var Advertiser = document.getElementById(objAdvertiser);
	var Affiliate = document.getElementById(objAffiliate);
	
	if(Saver.checked)
	{
		LostPassword('cust',objSiteUrl);		
	}
	if(Advertiser.checked)
	{
		LostPassword('adv',objSiteUrl);
	}
	if(Affiliate.checked)
	{
		if(document.getElementById('rolepanel') != null )
		  document.getElementById('rolepanel').className = 'rolepanel';
		  
		document.getElementById('hdnRoleChosen').value="LOST";
	}
}

function CheckTVCat(objAllCategory, objLocalCategory)
{
	var AllCategory = document.getElementById(objAllCategory);
	var LocalCategory = document.getElementById(objLocalCategory);
	
	if(AllCategory != null && LocalCategory != null)
	{
	  if(Get_Cookie ( 'CategoryLocation' ) != null && Get_Cookie ( 'CategoryLocation' ) == "Local")
	  {
		AllCategory.checked = false;
	    LocalCategory.checked = true;
	  }
	  else
	  {
		AllCategory.checked = true;
		LocalCategory.checked = false;
	  }
	}
}


function Set_Cookie( name, value, expires, path ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" )
 
}


function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function FillPassword(objPassword)
{
	var Password = document.getElementById(objPassword);
	Password.value = "Password";
}