﻿// JScript File

var leftMenu, rightMenu, INRValue, PressReview, FreeDownloads, FreeFlash, SelectedProducts, SearchCategory = new Array();

function progress(req)
{
   var html='<center><img src="images/loading.gif" alt="Pages in loading please wait"></center>';
   //if(req<4)
   //$('listProducts').innerHTML = html;
}

function onPageload()
{

    // added by saraswathy on 13/03/2009
    loginStatus();
    // ended
     
        
    var leftMenuUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=top_publisher';
	handleRequest(GET, leftMenuUrl, populateLeftMenu);
	
	var freeOfferUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=freeoffer';
	handleRequest(GET, freeOfferUrl, setValue,progress,FreeDownloads);
	
//	var freeFlashUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=freeflash';
//	handleRequest(GET, freeFlashUrl, setValue,progress,FreeFlash);	

	var pressReviewUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=pressreview';
	handleRequest(GET, pressReviewUrl, setValue,progress,PressReview);
	
	var searchComboUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=searchcombo'; 
	handleRequest(GET, searchComboUrl, funPopulateGroups);
	
	var INRValueUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=getINRValue';
	handleRequest(GET, INRValueUrl, setValue,progress,INRValue);
	
//	var customerUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=customer';
//	handleRequest(GET, customerUrl, setValue,progress,Cust);

	var rightMenuUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=top_author';
	handleRequest(GET, rightMenuUrl, populateRightMenu);
	
	//code added by senthil given by bharathi on 11/09/09
	var CatalogURL='Data.aspx?mode=main&rnd='+Math.random()+'&action=Catalog';
	handleRequest(GET,CatalogURL,ShowCatalog,progress);
	
	var LogoURL='Data.aspx?mode=main&rnd='+Math.random()+'&action=LogoImage';
	handleRequest(GET,LogoURL,funShowLogo,progress);
	//end here bharathi
	

	
	//displayProductPages(0);
	// added by saraswathy on 13/03.
// added by saraswathy on 13/03/2009
	 blncheckmessage= displayMessage();

	 if (blncheckmessage==false)
	 {
	    displayProductPages(0,'displayProductPages');
	 }

}
////code added by geetha on 13/03/2009
//function checkForDisplayProducts(pageno,isMessage)
//{
//alert("PageNo" + pageno);
//alert("isMessage" + isMessage);
//    if(isMessage == false)
//	{
//	alert("enter into condition");
//	    displayProductPages(pageno);
//	}
//	else
//	{
//	    $('listProducts').innerHTML = "";
//	}
//}
////ends here
function setValue(req,variable)
{
    eval('var value='+req.responseText);
    variable = value;

}


function displayProductPages(pageno,funName)
{  

    if( PageName == "default")
     clientSideInclude('listItems', 'admin/Pages/Help.html');
     var url = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=productlist&pageno='+pageno;
	 handleRequest(GET, url, funDisplayProducts,progress,pageno,funName);
   	 $('flashContent').innerHTML = "";    	
	 
}
//Code commented and added by senthil on 19/09/2009 for added one more parameter to show back button in search option
//function funDisplaySearchedBooks(pageno,funName,Attributevalueid,attributeid,type1)
function funDisplaySearchedBooks(pageno,funName,Attributevalueid,attributeid,type1,search)
//End here
{
 displayflashContent(type1)
 $('listItems').innerHTML = "";
 var url = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=SearchMenu&pageno='+pageno+'&Attributeid='+attributeid+'&Attributevalueid='+Attributevalueid; 

	 //Code commented and added by senthil on 19/09/2009 for added one more parameter to show back button in search option
	 //handleRequest(GET, url, funDisplayProducts,progress,pageno,funName,Attributevalueid,attributeid,type1);
	 handleRequest(GET, url, funDisplayProducts,progress,pageno,funName,Attributevalueid,attributeid,type1,search);
	 //End here
    
		
}

//Code commented and added by senthil on 19/09/2009 for added one more parameter  to show back button in search option
//function funDisplayProducts(req, key1, key2, key3, key4, key5) 
function funDisplayProducts(req, key1, key2, key3, key4, key5,key6) 
//End here
{	
    eval('var Products = '+req.responseText);
  SelectedProducts = Products;

    var booklist = Products;
   	flavtmp = "Select" ;
	sizetmp = "Select";
	
	
    var html ='<form name="frmProducts">';
    html+='<table width="460" border="0" cellspacing="6" cellpadding="0">';
	var tmp="";
	var temp="";
	var tmp1="";
	var tmp2="";
	var tmp3="";
	var j=0;
	var k=0;
	var prodcategoryid="";
	var tempbooklist = new Array();	
	var visiblebooklist = new Array();
	if(booklist!=0)
    {
   //Code place change by senthil on 18/03/2009 for if booklist array have empty value it show error message 	
	var productCount =parseInt( booklist[0].RecordCount);
	var displayCount = parseInt( booklist[0].DisplayCount);
	//End here
	for(var tmpvar=0;tmpvar<booklist.length;tmpvar++)
	{
    	visiblebooklist[k] = booklist[tmpvar];
		k++;
	}
	for(var i=0,j=0;i<visiblebooklist.length;i++)
	{
		if(i==0)
		{
			tempbooklist[j] = visiblebooklist[i];
			temp = visiblebooklist[i];
			j++;
			continue;
		}
		if(temp.name != visiblebooklist[i].name){
			tempbooklist[j] = visiblebooklist[i];
			temp = visiblebooklist[i];
			j++;
		}		
	}
	//Code added by senthil on 19/09/2009 for display back button in the search option
	if(key6=="Search")
	html+= ' <input type="button" name="Back" value="Back" onclick="funGroupSelect('+ key4 +')" style="height: 30px" /> ';
	//End here
	//Code Added by Ranjith on 19/03/2009
	if( PageName == "default")
    { 
      if(key2!='displayProductPages') 
      html+= pageIndexDisplay(productCount,displayCount,key1,key2,key3,key4,key5);
    }else{
     html+= pageIndexDisplay(productCount,displayCount,key1,key2,key3,key4,key5);
     }
     //End here
    for(var i=0;i<tempbooklist.length;i++)
	{
		tmp1 +=displayItem1(tempbooklist[i]);
		tmp2 +=displayItem2(tempbooklist[i]);
		tmp3 +=displayItem3(tempbooklist[i]);
		
		if(i%3==2 ||(i==tempbooklist.length-1) ){
		tmp+='	<tr height="210">'+tmp1+'</tr>';
			tmp1="";
		}
		if(i%3==2 ||(i==tempbooklist.length-1) ){
		tmp+='	<tr>'+tmp2+'</tr>';
			tmp2="";
		}
		if(i%3==2 ||(i==tempbooklist.length-1) ){
		tmp+='	<tr>'+tmp3+'</tr>';
		tmp3="";
		}
         
		if(i%3==2 ||(i==tempbooklist.length-1) )
		{	
			html+=tmp;
			html+='<tr><td width="0%"><img src="images/spacer.gif" alt="" width="0" height="0" /></td>';
			html+='</tr>';
			html+='<tr><td colspan="3"><img src="images/spacer.gif" alt="" width="0" height="0"></td></tr>';
			tmp="";
		}
	}
	
	}
	
	else
	{
	        html+='<tr><td width="0%"><img src="images/spacer.gif" alt="" width="0" height="0" /></td>';
			html+='</tr>';
			if(key2 == "funajaxSpecificSearch")
			{
			//Code added by senthil on 19/09/2009 for display back button in the search option
			html+= ' <input type="button" name="Back" value="Back" onclick="funGroupSelect('+ key4 +')" style="height: 30px" /> ';
            html+='<br/><br/><br/><br/><br/><br/><br/><br/><br/><tr><td><center><font color="#CC6600"><b>No Match Found</b></font></center></td></tr>';
            //End here
            }
            else 
			html+='<br/><br/><br/><br/><br/><br/><br/><br/><br/><tr><td><center><font color="#CC6600"><b>விரைவில் வருகிறது....</b></font></center></td></tr>';
	}
	
	//Code Modify by ranjith on 19/03/2009
    if( PageName == "default")
    { 
      if(key2!='displayProductPages') 
      html+= pageIndexDisplay(productCount,displayCount,key1,key2,key3,key4,key5);
    }else{
     html+= pageIndexDisplay(productCount,displayCount,key1,key2,key3,key4,key5);
     }
     //End here
     html+='</table></div></form>';
   
	$('listProducts').innerHTML = html;
	}


function displayflashContent(headervalue)
{
		var header = '<table width="450" cellpadding="0" cellspacing="0">';
		header += '<tr>';
		header += '<td width="0%"><img src="gui/img/bg_title_left.gif" width="10" height="37" alt=""></td>';
		header += '<td  width="100%" background="gui/img/bg_title.gif"><h1 class="white">';
		header += headervalue;
		header +='</h1></td>'
		header +='<td width="0%"><img src="gui/img/bg_title_right.gif" width="10" height="37" alt=""></td>';
		header +='</tr>';
		header +='</table>';
		$('flashContent').innerHTML =header;
}
//End Here



//Commented and added by ranjith on 19/03/2009
//function pageIndexDisplay(productCount,displayCount,Attributevalueid,attributeid,type1)
function pageIndexDisplay(productCount,displayCount,pageno,funName,Attributevalueid,attributeid,type1)
{
     
     var html="";
     var divproductCount=0;
     var molproductCount=0;
     var stPoint=0,endPoint=0;
     var i=0;
     var sLink=10;
     if(Attributevalueid == undefined)
     Attributevalueid =0;
     if(attributeid == undefined)
     attributeid =0;
     if(type1 == undefined)
     type1="";
     if(productCount !=null || productCount != '')
     {
      divproductCount =  parseInt(productCount/displayCount);
      molproductCount = productCount%displayCount;   
      }
     var b = pageno+1;
     if(molproductCount!= 0)
     divproductCount =divproductCount+1;
     if(productCount>displayCount)
     {
        html+='<tr width="100%"><td colspan="3" align="Center">';
        //code added by Ranjith on 190309
         html+='<div id="Paging">';
        html+='<a style="text"><font color="Blue">'+b+' of '+divproductCount+'</font></a>'; 

        if(pageno >=sLink)
        {

         if(pageno%sLink ==0)
         {
         stPoint=pageno;
         }
         else
         {
            n=parseInt(pageno/sLink);
            stPoint=sLink*n;
            }
        html+='<a href="javascript:'+funName+'(0,\''+funName+'\','+Attributevalueid+','+attributeid+',\''+type1+'\');"><<</a>';
        html+='<a href="javascript:'+funName+'('+(stPoint-sLink)+',\''+funName+'\','+Attributevalueid+','+attributeid+',\''+type1+'\');"><</a>';
 

        }
    endPoint=stPoint+sLink;
    if(endPoint> divproductCount)
        endPoint=divproductCount;
    for(i=stPoint;i<endPoint;i++)
    {
       var j=i+1;
       if(i==pageno){
           html+='<span id="">'+j+'</span>';

        }
//        else if(type1 != undefined)
//       {
//        html+='<a href="javascript:funDisplaySearchedBooks('+Attributevalueid+','+attributeid+','+i+',\''+type1+'\')"title="Page'+j+'">'+j+'</a>';
//        
//        
//       }
       else 
       {
       
            html+='<a href="javascript:'+funName+'('+i+',\''+funName+'\','+Attributevalueid+','+attributeid+',\''+type1+'\')" title="Page'+j+'">'+j+'</a>';
         
       }
       
    }

    if(endPoint<divproductCount)
    {
    html+='<a href="javascript:'+funName+'('+endPoint+',\''+funName+'\','+Attributevalueid+','+attributeid+',\''+type1+'\');">></a>';
    
    html+='<a href="javascript:'+funName+'('+(divproductCount-1)+',\''+funName+'\','+Attributevalueid+','+attributeid+',\''+type1+'\');">>></a>';
    }
     html+='</div>';
//End Here
     html+='</td></tr>';
     
    }
    
  return html;
}
function funPopulateGroups(req) 
{
    var select = "";
    eval('var value5 ='+ req.responseText);
    SearchCategory = value5;
	 
	//Code commented and added by senthil on 19/09/2009 send combo value in the function
	//select += "<select name='Attributes' class='SearchCategory' onchange='funGroupSelect(this);'>";
	select += "<select name='Attributes' class='SearchCategory' onchange='funGroupSelect(this.value);'>";
	//End here
	//code comment and modified by senthil given by bharathi on 14/09/09
	//select += "<option selected>--Please select--</option>";
	select += "<option value=0 selected>--Please select--</option>";
	//end here bharathi on 14/09/09        
    for(var i=0; i< SearchCategory.length; i++)
	 {
			select += "<option value='"+ SearchCategory[i].id+"'>"+ SearchCategory[i].name+"</option>";
	 }
	    select += "</select>";  
	   
	$('SearchCategory').innerHTML = select;
}


function funGroupSelect(obj)
{
    //Code commented and added by senthil on 19/09/2009 
	//var Attributeid= obj.value;
	var Attributeid= obj;
	var srName="";
	//End here
	var Attri="";
	
	if (Attributeid==undefined)
	{
	
	Attributeid=obj;
	Attri=obj.value;
	
	}
   //Code added by senthil on 18/09/2009 to reload the combo box to select value
   window.document.getElementById("Attributes").value=0;
   //End here

	var createURL = "Data.aspx?mode=main&rnd="+Math.random();
	createURL += "&action=SearchCategory&Attributeid="+Attributeid;
		handleRequest(GET, createURL, function(req)
		 {
		     // condition added by senthil given by deepika on 24/02/09
		     if(req.responseText!="")
            {  
			  eval('var AttributeValues = '+req.responseText);
			  // added by saraswathy on 27/11/2008
			   if(AttributeValues.length!=0)
			     searchattribute=AttributeValues;
			    
			  // if condition added by deepika on 23/10/2008
			  if(Attri !=undefined)
			  {

             var html= '<form name="frmSrch" ><table width="440" cellpadding="3" cellspacing="0" border="0">';
	            html+='<tr><td colspan="5">';
                html+= '<table width="100%" cellpadding="0" cellspacing="0">';
	            html+= '<tr>';
	            html+= '<td width="0%"><img src="gui/img/bg_title_left.gif" width="10" height="37" alt=""></td>';
	            html+= '<td  width="100%"  colspan="5" align="center" background="gui/img/bg_title.gif" ><center><h1 class="white" >';
	            for(i=0; i< SearchCategory.length; i++)
	            {
			       if(SearchCategory[i].id==Attributeid)
			       //Code added by senthil on 19/09/2009 for get english name
			       {
			       srName = SearchCategory[i].name;
			       html +=SearchCategory[i].tamilname +' </center></h1></td> ';
			       }
			      //End here
	            }
	            html+= '</tr></table></br></br><font size=2>';
	              //*************
	            
	            html+=funALPHABET(Attributeid);
	            //Code commented and added by senthil on 19/09/2009 for show search name in the lable
	            //html+= '</font></br></br> <center><font size=2> Search By Title</font> <input class="searchField" type="text" name="query" value="Search By Title" onkeydown="if(event.keyCode==13) event.keyCode=9;" onclick="SetSearch()" style="width: 96px" />';
	            html+= '</font></br></br> <center><font size=2> Search By '+srName+' </font> <input class="searchField" type="text" name="query" value="Type text here" onkeydown="if(event.keyCode==13) event.keyCode=9;" onclick="SetSearch()" style="width: 96px" />';
	            //End here 
	           //Code Commented and added by senthil on 16/02/09
                //html+= ' <input type="button" name="searchbuton" value="Search" onclick="ChkSrchFlds(this.form)" style="height: 20px" />  </center>';
	            //code comment and modified by senthil given by bharathi on 16/09/09 fro pass the attribute id in funspecificsearch
                //html+= ' <input type="button" name="searchbuton" value="Search" onclick="funSpecificSearch()" style="height: 20px" />  </center>';
                html+= ' <input type="button" name="searchbuton" value="Search" onclick="funSpecificSearch('+ Attributeid+')" style="height: 20px" />  ';
	            //end here bharathi on 16/09/09
               
	           // html+= ' </form>';
	            //*************
	                        //************* added by deepika on 23/10/2008
	            }
	            else
	            {
	            var html= '<form name="frmSrch" ><table width="440" cellpadding="3" cellspacing="0" border="0">';
	            html+='<tr><td colspan="5">';
                html+= '<table width="100%" cellpadding="0" cellspacing="0">';
	            html+= '<tr>';
	            html+= '<td width="0%"><img src="gui/img/bg_title_left.gif" width="10" height="37" alt=""></td>';
	            html+= '<td  width="100%"  colspan="5" align="center" background="gui/img/bg_title.gif" ><center><h1 class="white" >';
	            // commented and modified by saraswathy on 17/11/2008
	            for(i=0; i< SearchCategory.length; i++)
	            {
			       if(SearchCategory[i].id==Attributeid)
			       html +=SearchCategory[i].tamilname +' </center></h1></td> ';
			      
	            }
	            
 		       
 		       
	            html+= '</tr></table></br></br><font size=2>';
	            html += funALPHABET(Attributeid);
	            }

                html +='</font></br></br><center><table width="100%" border="0" cellpadding="0" cellspacing="4" >';
	            html+= '';
		        
        if(AttributeValues.length==0) return;
        else
        {
           for(i=0; i< SearchCategory.length; i++)
	            {
			       if(SearchCategory[i].id==Attributeid)
			       {
			      
			            for(var j=0;j<AttributeValues.length;j++) 
		                {
		                  var attriName=AttributeValues[j].engname;
                          var aplhabet=SearchCategory[i].alpha;
                          if (attriName.substr(0,1)==aplhabet.substr(0,1))
        	              {

                        //added by deepika on 22/10/08
                            html+= '<tr><td>';
                             if(Attributeid==1||Attributeid==3)
        	                { 
        	                  //Code commented and added by senthil on 19/09/2009 for display back button in search
                              //html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+AttributeValues[j].id+','+ Attributeid+',\''+AttributeValues[j].name+'\')" class="promoProductName" onmouseover="javascript:popUp('+AttributeValues[j].id+','+ Attributeid+')" onmouseout="javascript:popUp('+AttributeValues[j].id+')" style="cursor: pointer;"><font  color="blue" size=2>'+ AttributeValues[j].name+'</font></a>';
                              html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+AttributeValues[j].id+','+ Attributeid+',\''+AttributeValues[j].name+'\',\'Search\')" class="promoProductName" onmouseover="javascript:popUp('+AttributeValues[j].id+','+ Attributeid+')" onmouseout="javascript:popUp('+AttributeValues[j].id+')" style="cursor: pointer;"><font  color="blue" size=2>'+ AttributeValues[j].name+'</font></a>';
                            //end here
                            }
		                    else
		                    //Code commented and added by senthil on 19/09/2009 for display back button in search
                            //html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+AttributeValues[j].id+','+ Attributeid+',\''+AttributeValues[j].name+'\')" class="promoProductName"><font color="blue" size=2>'+ AttributeValues[j].name+'</font></a>';
                            html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+AttributeValues[j].id+','+ Attributeid+',\''+AttributeValues[j].name+'\',\'Search\')" class="promoProductName"><font color="blue" size=2>'+ AttributeValues[j].name+'</font></a>';
		                    //End here
		                    html+= '</tr></td>';
                            
                            		                   }
		                }
		            }    
		        
		         }
        }

        html+='</table></center></td></tr></table></form>';
    
        $('flashContent').innerHTML = html;
    	// added by saraswathy on 10/11/2008
    	 $('listItems').innerHTML = "";
	    $('listProducts').innerHTML = "";
	    //Added by senthil given by deepika on 24/02/09
	    }
	else
    	{
    	alert ("Please Select the Category to Search");
    	}
        //End here
    	
	    if((Cust.length==0) ||(Cust[0].FirstName=='')||(Cust[0].FirstName=='LoginFailed')||(Cust[0].FirstName=='RegLoginFailed')||( Cust[0].FirstName=='RegSuccess')||(Cust[0].FirstName=='UnApproved')) 
        { 
	         var log =displayLogin() ;
		        $('cart').innerHTML = log;
	    }
    	
	    });
    window.scrollTo(0,0);
    window.focus();

 }
 function funALPHABET(Attributeid)
            {
               var aplha="";
               var count=0;
                for(i=0; i< SearchCategory.length; i++)
	                {
			         if(SearchCategory[i].id==Attributeid)
			         {
			         
                        for(icnt=0;icnt<26;icnt++)
                        {
                          var aplhabet=SearchCategory[i].alpha;
                        
                            if (aplhabet.indexOf(String.fromCharCode(65+icnt))==-1)  // Letter is active,\''+strOpt+'\'
                                aplha +="<FONT COLOR=gray font-size:13px> "+String.fromCharCode(65+icnt)+"</FONT><FONT COLOR=Green >|</FONT>";
                             else  
        	                    aplha +="<A HREF='#"+String.fromCharCode(65+icnt)+"' onclick='return funDisplayCharacterAttributes(\""+String.fromCharCode(65+icnt)+"\","+ Attributeid+");' style='font-size:15px'><FONT COLOR=blue> "+String.fromCharCode(65+icnt)+"</FONT></A><FONT COLOR=Green >|</FONT>";
        	               
                     }    
		        
	             }
           }

             return aplha;
            }
 

function funDisplayCharacterAttributes(character,Attributeid)
{
           //Code added by senthil on 19/09/2009
           var srName="";
           //End here
            var html= '<form name="frmSrch" ><table width="440" cellpadding="3" cellspacing="0" border="0">';
	            html+='<tr><td colspan="5">';
                html+= '<table width="100%" cellpadding="0" cellspacing="0">';
	            html+= '<tr>';
	            html+= '<td width="0%"><img src="gui/img/bg_title_left.gif" width="10" height="37" alt=""></td>';
	            html+= '<td  width="100%"  colspan="5" align="center" background="gui/img/bg_title.gif" ><center><h1 class="white" >';
	            for(i=0; i< SearchCategory.length; i++)
	            {
			       if(SearchCategory[i].id==Attributeid)
			       {
			           //Code added by senthil on 19/09/2009 for get english name
			            srName= SearchCategory[i].name;
			            html +=SearchCategory[i].tamilname +' </center></h1></td> ';
			       }
	            }
	            html+= '</tr></table></br></br><font size=2>';
	              //*************
	            
	            html+=funALPHABET(Attributeid);
	            //Code commented and added by senthil on 19/09/2009 for show english name in lable
	           // html+= '</font></br></br><center><font size=2> Search By Title</font> <input class="searchField" type="text" name="query" value="Search By Title" onkeydown="if(event.keyCode==13) event.keyCode=9;" onclick="SetSearch()" style="width: 96px" />';
	            html+= '</font></br></br><center><font size=2> Search By '+srName+'</font> <input class="searchField" type="text" name="query" value="Type text here" onkeydown="if(event.keyCode==13) event.keyCode=9;" onclick="SetSearch()" style="width: 96px" />';
	            //End here
	            //Code Commented and added by senthil on 16/02/09
                //html+= ' <input type="button" name="searchbuton" value="Search" onclick="ChkSrchFlds(this.form)" style="height: 20px" />  </center>';
	            //code comment and modified by senthil given by bharathi on 16/09/09 for add the attributeid in funSpecificSearch
	            //html+= ' <input type="button" name="searchbuton" value="Search" onclick="funSpecificSearch()" style="height: 20px" />  </center>';
                html+= ' <input type="button" name="searchbuton" value="Search" onclick="funSpecificSearch('+ Attributeid +')" style="height: 20px" />  </center>';
                //end here bharathi
	            //*************
                html +='</br></br><center><table width="100%" border="0" cellpadding="0" cellspacing="4" >';
	            html+= '';
		        
        if(searchattribute.length==0) return;
        else
        {
           for(i=0; i< SearchCategory.length; i++)
	            {
			       if(SearchCategory[i].id==Attributeid)
			       {
	                     for(var j=0;j<searchattribute.length;j++) 
		                {
		                  var attriName=searchattribute[j].engname;
		                  //code comment and modified by senthil given by bharathi on 16/09/09
		                  var attriFirstName=searchattribute[j].FirstName;
		                  var attriLastName=searchattribute[j].LastName;
		                 //end here bharathi on 16/09/09

                          var aplhabet=SearchCategory[i].alpha;
                         //code comment and modified by senthil given by bharathi on 16/09/09
        	              //if (attriName.substr(0,1)==character)
           	             if(Attributeid==1||Attributeid==3 || Attributeid==2)
        	             {
        	              //if (attriFirstName.substr(0,1)==character || attriLastName.substr(0,1)==character || attriName.substr(0,1)==character) 
        	              if (attriFirstName.substr(0,1)==character || attriLastName.substr(0,1)==character) 
        	              //end here bharathi on 16/09/09
         	              {
                            html+= '<tr><td>';
                                            //added by deepika on 22/10/08
        	                  if(Attributeid==1||Attributeid==3)
        	                { 
        	                //Code commented and added by senthil on 19/09/2009 for display back button in search
        	                // html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+searchattribute[j].id+','+ Attributeid+',\''+searchattribute[j].name+'\')" class="promoProductName" onmouseover="javascript:popUp('+searchattribute[j].id+','+ Attributeid+')" onmouseout="javascript:popUp('+searchattribute[j].id+')" style="cursor: pointer;"><font  color="blue" size=2>'+ searchattribute[j].name+'</font></a>';
        	                 html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+searchattribute[j].id+','+ Attributeid+',\''+searchattribute[j].name+'\',\'Search\')" class="promoProductName" onmouseover="javascript:popUp('+searchattribute[j].id+','+ Attributeid+')" onmouseout="javascript:popUp('+searchattribute[j].id+')" style="cursor: pointer;"><font  color="blue" size=2>'+ searchattribute[j].name+'</font></a>';
                            //End here
                            }
		                    else
		                    {
		                    //Code commented and added by senthil on 19/09/2009 for display back button in search		                    
		                    //html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+searchattribute[j].id+','+ Attributeid+',\''+searchattribute[j].name+'\')" class="promoProductName"><font  color="blue" size=2>'+ searchattribute[j].name+'</font></a>';
		                    html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+searchattribute[j].id+','+ Attributeid+',\''+searchattribute[j].name+'\',\'Search\')" class="promoProductName"><font  color="blue" size=2>'+ searchattribute[j].name+'</font></a>';
		                    //End here
		                    }                            
		                    html+= '</tr></td>';
		                   }
		                 }
		                 //Code added by senthil given by bharathi on 16/09/2009
		                  else
		                   {
		                        if(attriName.substr(0,1)==character)
		                        {
		                            html+= '<tr><td>';
		                            //Code commented and added by senthil on 19/09/2009 for display back button in search
		                            //html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+searchattribute[j].id+','+ Attributeid+',\''+searchattribute[j].name+'\')" class="promoProductName"><font  color="blue" size=2>'+ searchattribute[j].name+'</font></a>';
		                            html+= ' <a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+searchattribute[j].id+','+ Attributeid+',\''+searchattribute[j].name+'\',\'Search\')" class="promoProductName"><font  color="blue" size=2>'+ searchattribute[j].name+'</font></a>';
		                            //End here
		                            html+= '</tr></td>';
		                        }
		                    }

		                }    
		              // End here bharathi on 16/09/2009
		            }
                }
              }

        html+='</table></center></td></tr></table></form>';
    
        $('flashContent').innerHTML = html;
    	 	// added by saraswathy on 10/11/2008
    	 $('listItems').innerHTML = "";
	    $('listProducts').innerHTML = "";
    	
	    if((Cust.length==0) ||(Cust[0].FirstName=='')||(Cust[0].FirstName=='LoginFailed')||(Cust[0].FirstName=='RegLoginFailed')||( Cust[0].FirstName=='RegSuccess')||(Cust[0].FirstName=='UnApproved')) 
        { 
	         var log =displayLogin() ;
		        $('cart').innerHTML = log;
	    }
    	
		
}


function populateLeftMenu(req)
{
  eval('var leftMenu ='+req.responseText);
var html = "";

 html +=' <span class="navTitleGray">';
  html +='<ul id="siteinfo1">';
if(leftMenu.length !=0)
{
	var tmpvalue = leftMenu[0].name; 
	var tempselp = new Array();
	var tmpid = new Array();
	var tmpiskit = new Array();
	for(var l=0;l<leftMenu.length;l++)
	{
		tempselp[l] = leftMenu[l].name;
		tmpid[l] = leftMenu[l].id;
  		tmpiskit[l] = leftMenu[l].IsCollection;
       
	}
	tmpvalue = tempselp[0];	
	
	    if((tempselp[0]!="N/A")&&(tempselp[0]!=""))
		{
        	
        	html+= '<li><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tmpid[0]+',2,\''+tempselp[0]+'\')" class="promoProductName">'+tempselp[0]+' </a></li>';
        	
        }

	for(var i=0;i<tempselp.length;i++)
	{	
		
        if((tmpvalue != tempselp[i])&&(tempselp[i]!="N/A")&&(tempselp[i]!=""))
		{
	   
			 	html+= '<li><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tmpid[i]+',2,\''+tempselp[i]+'\')" class="promoProductName">'+tempselp[i]+' </a></li>';
		}
		tmpvalue = tempselp[i];
	}	
    }
    html +='</ul></span>';
    $('leftmenu').innerHTML=html;

}
function populateRightMenu(req)
{
 eval('var rightMenu = '+req.responseText);
  var html = "";
  html +='<span class="navTitleGray"><ul id="siteinfo1">';
 
if(rightMenu.length !=0)
{
	
	var tmpvalue = rightMenu[0].name; //end here
	var tempselp = new Array();
	var tmpid = new Array();
	var tmpiskit = new Array();
	
	var tmpAuthorid = new Array();
    
	for(var l=0;l<rightMenu.length;l++)
	{
		tempselp[l] = rightMenu[l].name;
		tmpid[l] = rightMenu[l].id;
        tmpiskit[l] = rightMenu[l].IsCollection;
        // commented and modified by saraswathy on 16/12/2008
         tmpAuthorid[l]=rightMenu[l].authorid;

        
	}
	
	tmpvalue = tempselp[0];	
    
    html+= '<li><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tmpAuthorid[0]+',1,\''+tempselp[0]+'\')" class="promoProductName" >'+tempselp[0]+'</a></li>';

	for(var i=0;i<tempselp.length;i++)
	{	
		if(tmpvalue != tempselp[i])
		{
		     html+= '<li><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tmpAuthorid[i]+',1,\''+tempselp[i]+'\')" class="promoProductName">'+tempselp[i]+' </a></li>';
            
		}
		tmpvalue = tempselp[i];
	}
	
    }
     html +='</ul></span>';
    $('rightmenu').innerHTML=html;
}
//code comment and modified by senthil given by bharathi on 16/09/09
//function funSpecificSearch()
function funSpecificSearch(AttributeID)
//end here bharathi on 16/09/09
{  
    //code added by bharathi on 16/09/09
    var AttribID=AttributeID;
    //end here bharathi
  var query = document.frmSrch.elements[0].value;
  if(query =="" ||query=="Search By Title")
	{
		alert("Enter a valid Search Criteria")
		document.frmSrch.elements[0].value ="";
		return window.document.frmSrch.elements[0].focus();
		
	}
	//code added by senthil given by bharathi on 14/09/09 for show select value after select the search
	window.document.getElementById("Attributes").value=0;
	//end here bharathi
	//code comment and modified by senthil given by bharathi on 16/09/09
	//funajaxSpecificSearch(0,'funajaxSpecificSearch',0,0,query);
		funajaxSpecificSearch(0,'funajaxSpecificSearch',0,AttribID,query);
	//end here bharathi
}

function funajaxSpecificSearch(pageNo,funName,Attributevalueid,attributeid,query)
{
    displayflashContent(query)
  //code comment and modified by senthil given by bharathi on 16/09/09
  //var SpecificSearchUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=search&pageno='+pageNo+'&query='+query;
  var SpecificSearchUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=search&pageno='+pageNo+'&query='+query+'&AttibuteID='+attributeid;
  //end here bharathifunction funDisplayCharacterAttributes
    
    //Code commented and added by senthil for back button in search 
	//handleRequest(GET, SpecificSearchUrl, funDisplayProducts,progress,pageNo,funName,Attributevalueid,attributeid,query);
	handleRequest(GET, SpecificSearchUrl, funDisplayProducts,progress,pageNo,funName,Attributevalueid,attributeid,query,'Search');
    //End here
}

function funDisplayCategory(pageNo,funName,categoryID)
{

for(var i=0;i<Category.length;i++)
{ 
   if(Category[i].id == categoryID)
         name = Category[i].name;
}
//Code added by senthil on 18/03/2009
if(name =="Author")
{
		   //Code commented and added by senthil on 10/04/2009 
//		    html+='<tr><td>';
//		    html+= groupSelect("1");
//		    html+=funGroupSelect("1"); 
//			html+= '</td></tr>';
//			$('listProducts').innerHTML = html;
			funGroupSelect("1");

}
else
{
displayflashContent(name);

var DisplayCategoryUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=DisplayCategory&pageno='+pageNo+'&categoryid='+categoryID;
	handleRequest(GET, DisplayCategoryUrl, funDisplayProducts,progress,pageNo,funName,categoryID);
	}
}

function funDisplayJournalCategory(pageNo,funName,journalCategoryID)
{

for(var i=0;i<JournalCategory.length;i++)
{ 
   if(JournalCategory[i].id == journalCategoryID)
         name = JournalCategory[i].name;
}
//Code added by senthil on 18/03/2009
if(name =="Editor")
{
		    //Code commented and added by senthil on 10/04/2009 
//		    html+='<tr><td>';
//		    html+= groupSelect("3");
//		   html+=funGroupSelect("3"); 
//			html+= '</td></tr>';
//			$('listProducts').innerHTML = html;
			funGroupSelect("3");

}
else
{
//End here
displayflashContent(name);

var DisplayCategoryUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=DisplayJournalCategory&pageno='+pageNo+'&categoryid='+journalCategoryID;
	handleRequest(GET, DisplayCategoryUrl, funDisplayProducts,progress,pageNo,funName,journalCategoryID);
	}
}

function funDisplaySelectedItem(productID)
{
//Code commented by senthil on 27/06/2009 not need
//var getMagazinTypeURL = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=MagazineType&categoryid='+productID;
//handleRequest(GET, getMagazinTypeURL, funMagazineType,progress,productID);
var DisplaySelectedItemUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=SingleProduct&categoryid='+productID;
handleRequest(GET, DisplaySelectedItemUrl, funProducts,progress,productID);

}
function funDisplayCollectionItem(productID,product)
{
var DisplaySelectedItemUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=CollectionProduct&categoryid='+productID;
	handleRequest(GET, DisplaySelectedItemUrl, funCollection,progress,productID,product);

}
function funProducts(req,item)
{
  eval('var Products = '+req.responseText);
  SelectedProducts = Products;
 displaySelectedItem(item);
   
}
//function commented by senthil on 27/06/2009 not need
//var MagazineType;
//function funMagazineType(req,productID)
//{
  //eval('var MagazineType1 = '+req.responseText);
 // MagazineType = MagazineType1;
  //CollectionProduct = Products;
 //displaySelectCollectionItem(product,CollectionProduct);   
//}

function funCollection(req,productID,product)
{
  eval('var CollectionProduct = '+req.responseText);
  //CollectionProduct = Products;
 displaySelectCollectionItem(product,CollectionProduct);
   
}
//Function added by senthil on 09/05/2009 to display the Audio/Video
function funDisplayAudioVideo(pageNo,funName,categoryID)
{
displayflashContent('Audio/Video');
$('listItems').innerHTML = "";
var DisplayCategoryUrl = 'Data.aspx?mode=main&rnd='+Math.random()+'&action=DisplayCategory&pageno='+pageNo+'&categoryid='+categoryID;
	handleRequest(GET, DisplayCategoryUrl, funDisplayProducts,progress,pageNo,funName,categoryID);
}
//End here

//code added  by senthil given by bharathi on 11/09/09 for display the catelog link in the screen
function ShowCatalog(req)
{
eval('var value ='+req.responseText);
    var varCatalog="";
    var ShowCatalog=value;
    if(ShowCatalog.length!=0)
    {
     for(var i=0; i< ShowCatalog.length; i++)
     {
        if(ShowCatalog[i].ConfigName=="Catalog" && ShowCatalog[i].Criteria=="ON")
        {
                varCatalog='<center><a href='+ShowCatalog[i].ConfigDescription+'><font color="blue"><strong>Sangapalagai Catalog</strong><br>';
                varCatalog +='</font><font color="blue" size="2">click here</font></a></center>';
                document.getElementById("Catalog").innerHTML=varCatalog;
        }   
        else if(ShowCatalog[i].ConfigName=="FreeFlash" && ShowCatalog[i].Criteria=="ON")
        {
                varCatalog='<center><embed name="Parthipan" src="'+ShowCatalog[i].ConfigDescription+'" bgcolor="#E8E6D0" width="100%"';
                varCatalog+=' height="200" type="application/x-shockwave-flash">';                 
                document.getElementById("FlashImage").innerHTML=varCatalog;
        }
     }
    }   
}
//End here bharathi
//code added by senthil given by bharathi on 11/09/2009 for displaying Marquee text in the Header
function funShowLogo(req)
{
eval('var value ='+req.responseText);
    var varLogo="";
    var ShowLogo=value;
    if(ShowLogo.length!=0)
    {
        if(ShowLogo[0].Criteria=="ON")
        {
                varLogo='<center><div style="font-size:13px"><marquee scrollamount="3" onMouseOver="this.stop()" onMouseOut="this.start()"><font color="maroon">'+ ShowLogo[0].FlashNews+'</font></marquee></div></center>';
                document.getElementById("LogoImage").innerHTML=varLogo;
        }       
    }   
}
//end here bharathi

