﻿// JScript File
var flavtmp="Select";               
var sizetmp="Select";
var isavailable = "true";  
var itemnametmp;           
var directbuy = "true";
var tmpcart;
function displayItem1(item)
{
 	html ="";
 	html+= '<td valign="top">';
	html+= '<div id="promoColumn1">';
	html+= '<a href="#" onClick=" return displaySelectedItem('+item.id+');">';
	html+= '<img src="'+item.thumb+'"alt="'+item.name+'" border="0" width ="143" height="200">';
	html+= '</a></td>'
	html+= '</div>'
	return html;
}

function displayItem2(item)
{
	html ="";
	html+= '<td>'
	html+= '<div id="promoColumn2">';
	html+= '<a href="#" onClick="  return displaySelectedItem('+item.id+');"  class="promoProductName">'+item.name+'</a><br></td>';
	return html;
}

function displayItem3(item)
{
	html ="";
	html+= '<td>'
	html+= '<span class="promoProductDesc"><a href="javascript:displaySelectedItem('+item.id+')" ><font color="blue">More Info</font></a> &nbsp;&nbsp; &nbsp;&nbsp;<a href="javascript:displayReview('+item.id+')" ><font color="blue">Reviews</font></a></span><br>';
    html+= '</td></div>'
	return html;
}

function displaySelectedItem(itemid)
{
   	var html='<form name="frmSelect"> ';
	directbuy="false";
	flavtmp = "Select" ;
	sizetmp = "Select";
	html +='<table width="457" border="0" cellpadding="4" cellspacing="0" bgcolor="#E4E4E4">';
	html +='<tr>';
	html +='<td>';
	html +='<table width="100%" border="0" cellpadding="0" cellspacing="4" bgcolor="#FFFFFF">';
	var tmp="";
	var BookIndex=0;

	for(var i=0;i<SelectedProducts.length;i++)
	{
		if((SelectedProducts[i].id == itemid)&&(SelectedProducts[i].ProductCategoryID==1))
		{
		    categoryid=SelectedProducts[i].ProductCategoryID;

		    BookIndex=i;
		    tmp+='	<td valign="top">'+displaySelectItem(SelectedProducts[BookIndex])+'</td>';
		}
        else if((SelectedProducts[i].id == itemid)&&(SelectedProducts[i].ProductCategoryID==2))
        {
            categoryid=SelectedProducts[i].ProductCategoryID;

            BookIndex=i;
	        tmp+='<td valign="top">'+displaySelectMagazineItem(SelectedProducts[BookIndex])+'</td>';
	    }
	    else if((SelectedProducts[i].id == itemid)&&(SelectedProducts[i].ProductCategoryID==3))
        {
            categoryid=SelectedProducts[i].ProductCategoryID;
            BookIndex=i;
	       tmp+='<td valign="top">'+funDisplayCollectionItem(itemid,SelectedProducts[BookIndex])+'</td>';
	    }
	        //Code added by magesh on 1304
	    else if((SelectedProducts[i].id == itemid)&&(SelectedProducts[i].ProductCategoryID==29))
        {
            categoryid=SelectedProducts[i].ProductCategoryID;
            BookIndex=i;            
	       tmp+='<td valign="top">'+DisplaySelectedAudioVedioItem(SelectedProducts[BookIndex])+'</td>';
	    }
	    //End here

	} 
	html+='<tr align="center">'+tmp;
	html+='</tr>';
	html +='<tr><td>';
	html+='<table width="100%" height="320px"  bgcolor="#D6DDBD">';
      html+='<tr valign="top"><td align="center">';
      html+='<table><tr><td align="center"><FONT color=#CC6600><b>விமர்சனங்கள்</b></font></td></tr>';
      html+='<tr><td align="left" width= "100%" class="promoProductDesc"><FONT color=#CC6600>உங்கள் விமர்சனங்கள் வரவேற்கப்படுகின்றன</font></td></tr>';
      html+='</table></td></tr>';

      html+='<tr style="height:280px" valign="top"><td align="left" valign="top">';

      //Code commented and Added by ranjith on 240309
      // html+='<div style="overflow: auto; width:100%;height:250px;position:absolute; border: thin solid #FFFF00"><table>';
      html+='<div style="overflow: auto; width:435px;height:250px;position:absolute; border: thin solid #FFFF00"><table>';
      html+='<tr><td><table class="promoProductDesc">';
      for (var i=0; i<BookReview.length; i++)
      {
       if(BookReview[i].id==itemid)
 	        {
      html+='<tr><td align="left"><b>Name :</b></td><td>'+ BookReview[i].Username +'</td>';
      html+='<tr><td align="left"><b>Country :</b></td><td>'+ BookReview[i].Country +'</td></tr>';
      html+='<tr><td align="left"><b>Comment :</b></td><td>'+ BookReview[i].Comments +'</td></tr>';
      html+='<tr><td><img alt="" height="3" src="images/spacer.gif" width="100%" align="middle" /></td></tr>';
            }
     
    }  
	html+='</table></td></tr></table></div>';
	html+='</td></font></tr></table>';
    html+='</table>';
    html+='</td></tr></table></td></tr></table></form>';
	
	if(categoryid!=3)
    {
	    var element = document.getElementById("flashContent");
	    element.innerHTML=html;
	    var row ="" ;
	    var element1 = document.getElementById("listProducts");
	    element1.innerHTML=row;
	    $('listItems').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;
	    }
        for(var i=0;i<SelectedProducts.length;i++)
		{	  
	         var bookid=SelectedProducts[i].id;
	         if(SelectedProducts[i].id == itemid)
	          {
	             clientSideInclude("includeone", "admin/PageContent/Products/"+itemid+"/"+SelectedProducts[i].LongDescription);
	            
              }
        }
        //Code added by ranjith J
       if(categoryid==2)
       {
         funDispPrice(itemid);
         //Code added by senthil on 15/09/2009 for magazine renewal button        
	     getIssueCount(itemid);
	     //End here
       }
      //End here       
    }
}
//Code added by magesh on 1304
function DisplaySelectedAudioVedioItem(item)
{
	flavtmp = "Select" ;
	sizetmp = "Select";
    itemnametmp=item.name; 
    var itemEnglishName=item.Bookname;
    isCollection=false;
	var html= '<table width="440" cellpadding="3" cellspacing="0" border="0" bgcolor="#D6DDBD"><form name="frmDisplayProducts" >';
	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" >'+item.name+'</center></h1></td>';
	html+='<td width="0%"><img src="gui/img/bg_title_right.gif" width="10" height="37" alt=""></td>';
	html+= '</tr></table></td></tr>';
    var tmpvalue = SelectedProducts[0].name;
    var tempselp = new Array();
    var j;
    var tempShortdescription =new Array();
    var strCriteria = "Products";
    var spqty,spmt;
    var author="";
    var tempdescription =new Array();
    var tempImage=new Array();
    var tempAuthorID="";

    for(var i=0,j=0;i<SelectedProducts.length;i++)
    {
    
        if((SelectedProducts[i].name == item.name)&&(SelectedProducts[i].ProductCategoryID==29))
	    { 
	        tempselp[j] = SelectedProducts[i].Author;
            tempShortdescription[j]=SelectedProducts[i].desc;
            tempdescription[j]=SelectedProducts[i].AuthorDescription;
            tempImage[j]=SelectedProducts[i].AuthorImage;
	        tempAuthorID=SelectedProducts[i].AuthorID;

        }
    }
    
   	    for(var i=0,j=0;i<SelectedProducts.length;i++)
   	    {
            if((SelectedProducts[i].name == item.name)&&(SelectedProducts[i].ProductCategoryID==29))
		    {
		    //commented and modified by deepika on 28/04/09
		    //newhtml = '&nbsp;<span class="PageText">$ '+SelectedProducts[i].ourprice +' (approx...Rs.'+SelectedProducts[i].ourprice * INRValue[0].value+')</span>';
		       newhtml = '&nbsp;<span class="PageText">$ '+SelectedProducts[i].ourprice +' (approx...Rs.'+(SelectedProducts[i].ourprice * INRValue[0].value).toFixed(2)+')</span>';
		      var discount=SelectedProducts[i].DiscPrice ;
		    }
	    }	
      if (tempselp[j]!= "N/A")
      {
      
        author='<table><tr><td align="left" width="30%"><img height="100" width="100" src='+ tempImage[j] +' alt="Author Image" /></td><td align="left" valign="top" width="70%"><font size="2"> <div id="LoadDescription" ></div></td></tr></table>';
         var desc=tempdescription[j];
         var attribute= desc.substr(0, desc.indexOf(".", 0))
         
         $('popupBody').innerHTML=author;
	      clientSideInclude("LoadDescription", "admin/PageContent/Author/"+ attribute +"/"+ desc);
          //Code Commented and added by senthil on 16/06/2009 for change the caption                                                                                                                                                                                                                                         
          //html+= '<tr><td align="left" class="PageText" width="30%"><strong>ஆசிரியர்:</strong></td><td class="PageText" width="30%" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tempAuthorID+',1,\''+tempselp[j]+'\')"  ><font color="Blue">'+tempselp[j]+'</font></a></td>';
          html+= '<tr><td align="left" class="PageText" width="30%"><strong>Director:</strong></td><td class="PageText" width="30%" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tempAuthorID+',1,\''+tempselp[j]+'\')"  ><font color="Blue">'+tempselp[j]+'</font></a></td>';
          //End here
      }
      //Code added by senthil on 02/06/2009 for show the image in the right corner
      else
      html+= '<tr><td></td><td></td>'; 
      //End here
      if(item.issale=="True")
      {
           //Code commented and added by senthil on 09/05/2009 for call address details only
            //html+= '<td width="40%" ><div id ="SingleDisplayBuy"><input type="button" value="Buy-DeliverybyCourier" onclick="javascript:checkbuy('+item.id+','+isCollection+', \''+strCriteria+'\');javascript:addressdetails('+item.id+','+isCollection+', \''+strCriteria+'\');"></div></td></tr>';
           //Code added and commented by senthil on 01/06/2009 for add image in the buy button
            html+= '<td align="right" width="50%" ><div id ="SingleDisplayBuy"><a href="javascript:addressdetails('+item.id+','+isCollection+', \''+strCriteria+'\')"><img src="images/buyCourier.jpg" align="right" alt="" width="125" height="25" vspace="5" border="0"></a></div></td></tr>';
            //html+= '<td width="40%" ><div id ="SingleDisplayBuy"><input type="button" value="Buy-DeliverybyCourier" onclick="javascript:addressdetails('+item.id+','+isCollection+', \''+strCriteria+'\');"></div></td></tr>';
            //End here
      }
      else if(item.isnew=="True")
      {
          //Code Commented and added by senthil on 17/06/2009 for remove new image and add buy button
          //html+= '<td ><img src="images/by_new.gif" align="center" alt="" width="46" height="17" vspace="5" border="0"></a></td></div></tr>';
          html+= '<td align="right" width="50%" ><div id ="SingleDisplayBuy"><a href="javascript:addressdetails('+item.id+','+isCollection+', \''+strCriteria+'\')"><img src="images/buyCourier.jpg" align="right" alt="" width="125" height="25" vspace="5" border="0"></a></div></td></tr>';
          //End here
      }
      else if(item.isfree=="True")
      {
          
		  html+= '<td ><input type="button" value="Download" onclick="return Download(this.form,'+item.id+')" id="Button1"/></td></tr>';
		 
		  
	  }	
      for(var i=0,j=0;i<SelectedProducts.length;i++)
      {
        if((SelectedProducts[i].name == item.name)&&(SelectedProducts[i].ProductCategoryID==29))
	    { 
	        tempselp[j] = SelectedProducts[i].Publisher;
            tempShortdescription[j]=SelectedProducts[i].desc;
        }
      }
      for(var i=0;i<tempselp.length;i++)
      {
       for(j=i+1;j<tempselp.length;j++)
       {
        if(tempselp[i] > tempselp[j])
        {
            tmpvalue = tempselp[i];
            tempselp[i] = tempselp[j];
            tempselp[j] = tmpvalue;
       }
      }
     }
    tmpvalue = tempselp[0];

     if (tempselp.length==1)
     {
        sizetmp=tmpvalue;
     }
  
    for(var i=0;i<tempselp.length;i++)
    {
	    if(tmpvalue != tempselp[i]) 
		html +='<option value="'+tempselp[i]+'" >'+tempselp[i]+'</option>'; 
 		tmpvalue = tempselp[i];  
    }     
    if(item.issale=="True")
    {
        html+= '</td></tr></select><tr><td align="left" class="PageText"><strong>Price:</strong></td><td width="50%"><div id="TestDiv">'+newhtml+'</div></td>';
      
        if (tempselp[j]!= "N/A")
        {
           html+= '<td width="50%"><div id ="SingleDisplayBuy" align="right"><img src="gui/img/CreditCard.png" align="right" alt="" width="125" height="25" vspace="5" border="0"></div></td></tr>';
        }
          if (discount!=0)
         {
         html+= '</td></tr></select><tr><td align="left" class="PageText"><strong>Discount:</strong></td><td width="50%"><div id="TestDiv">'+discount+'%</div></td>';
         }
    }

	html+= '</tr>';
	html+= '<td valign="top" align="left" width="30">';
	html+= '<a href="#" onClick="  return displaySelectedItem('+item.id+');"><br>';
	html+= '<img src="'+item.image+'" alt="'+item.name+'"  border="0">';//end here
	html+= '</a>'
	html+= '<a href="#" onClick="  return displaySelectedItem('+item.id+');" ></a><br><br></td>';
    html+='<td colspan="2" align="left" width="70%">';
    html+= '<div id="includeone" class="promoProductDesc"></div></td>';
    //Code commented by senthil on 01/06/2009 for remove size in the screen 
    //html+='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>Size:</strong></td><td class="PageText">'+item.Size + '</td>';
	if(item.Samples!="N/A")
    {
       html+= '<td colspan=2 align="left" class="PageText"><span class="promoProductDesc"><a href="'+item.Samples+'" ><font color="blue">View Sample Pages</font></a></span><br></td></tr>';
    }
    //Code commented and added by senthil on 01/06/2009 for change the lable
	//html+='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>மொ.பக்கம்:</strong></td><td class="PageText">'+item.NoOfPages + '</td></tr>';
	html+='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>Total Running Time:</strong></td><td class="PageText">'+item.NoOfPages + '</td></tr>';
    //End here
    html+='</form></table>';
    return html;
}

function addressdetails(itemId,isCollection,strCriteria)
{
if((Cust.length==0) ||(Cust[0].FirstName=='')||(Cust[0].FirstName=='LoginFailed')||(Cust[0].FirstName=='RegLoginFailed')||(Cust[0].FirstName=='UnApproved')||(Cust[0].FirstName=='RegSuccess'))
    {
	    var log =displayLogin() ;
		var html = '<table width="100%" border="0" cellspacing="0" cellpadding="">';
	    html += '<tr>';
		html += '<td width="0%"><img src="gui/img/spacer.gif" alt="" width="10" height="24"></td>';
		html += '</tr>';
        html += '</table>';
        html += '<br/><br/><br/><br/><br/><br/><br/><br/><br/><center><span class="promoProductDesc"><center><b><font color="#8B0000">Please log in with email ID/new users  register and log in . </font></b></center></span>';   
        $('flashContent').innerHTML = html;
		$('listProducts').innerHTML = "";
		$('listItems').innerHTML = "";
		SetFocus();
	    return; 
    }	
else
{
    var url = 'Data.aspx?mode=main&rnd='+Math.random();	    	
	url += '&action=CustomerDetails';		
handleRequest(GET, url,showAddressDetails,progress,itemId,isCollection,strCriteria);
 }
 }
 //added by deepika on 18/04/09
 var CourierDetails;
 function showAddressDetails(req,itemId,isCollection,strCriteria)
 {
    eval('var CustDetails = '+req.responseText);  
    CourierDetails = CustDetails;   
 	var row='';
	row += "<table  cellpadding='0' cellspacing='0' border='0' width='460' >";
	  row +="<tr>";
	  row +="<td width='0%'><img src='gui/img/bg_stage_tl.gif' alt='' width='18' height='29' /></td>";
	  row +="<td width='100%' background='gui/img/bg_stagetop.gif'>&nbsp;</td>";
	  row +="<td width='0%'><img src='gui/img/bg_stage_tr.gif' alt='' width='18' height='29' /></td>";
	  row +="</tr>";
	  row +="<tr>";
	  row +="<td><img src='gui/img/bg_stage_bl.gif' alt='' width='18' height='36' /></td>";
	  row +="<td align='center' background='gui/img/bg_stagebottom.gif'>";
	   row +="<img src='gui/img/stage_deliverydetails_red.gif' alt='' width='105' height='21' />";
	  row +="<img src='gui/img/arrows2.gif' alt='' width='37' height='21' />";
	  row +="<img src='gui/img/stage_viewcart.gif' alt='view cart' width='70' height='21' />";
	  row +="<img src='gui/img/arrows2.gif' alt='' width='37' height='21' />";	 
	  row +="<img src='gui/img/stage_paymen.gif' alt='' width='60' height='21' />";
	  row +="<img src='gui/img/arrows2.gif' alt='' width='37' height='21' /><img src='gui/img/stage_complete_gray.gif' alt='' width='70' height='21'/></td>";
      row +="<td width='0%'><img src='gui/img/bg_stage_br.gif' alt='' width='18' height='36'/></td></tr>";    
      row +="</table>";
      //row+="</br>";      
      //row +="<img src='gui/img/grey_spacer.gif' alt='' width='100%' height='4' /><br/>";
    row +='<form name="frmAddress" method="post" action ="Address" >';    
    //Code commented by senthil on 20/07/2009 to remove buy more button 
    // row+="<br><div align='left'><input type='button' alt='Buy More' value='Buy More' OnClick='javascript:displayProductPages(0,\"displayProductPages\");'></div>";
    //row +="</br>";
    row +='<TABLE height="100%" cellPadding=0 width="460" bgColor=#ffffff border=0>';
    row +='<TBODY>';
    row +='<TR>';
    
    row +='<TD vAlign=top align=middle>';
     
    row+="</br>";      
    row+="</br>";      
    row +='<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>';
	row +='<TBODY>';
	row +='<TR>';
	//Code commented and added by senthil on 10/06/2009 as per client requirment
	//row +='<TD class=PageText align=left><B><font color="red">Please fill out the following details for delivery of your products.</font></B></TD>';
	row +='<TD class=PageText align=left><B><font color="red">Please fill out the following details for delivery of your products by Courier.</font></B></TD>';
	//end here
	row +='</TR></TBODY></TABLE></TD></TR>';
	row +='<TD vAlign=top>';
	row +='<TABLE class=PageText cellSpacing=0 cellPadding=2  width="100%" border=0><TBODY>';
	row +='<TR>';
	
   //Code added by senthil on 08/06/2009 for add to radio button and some modification
	row +='<TD><input type="hidden" name="productid" id="productid" value="'+itemId+'" /></TD>';
	//row +='<TD><input type="hidden" name="cotry" id="cotry" value="Norway" /></TD>';
	row +='<TD><input type="radio" name="addType" id="addType" value="Self" checked="checked" OnClick="javascript:displayaddress()"/> Self &nbsp;';
	row +='<input type="radio" name="addType" id="addType" value="Gift" OnClick="javascript:clearaddress()"/> Gift';
	row +='</TD></TR><TR>';
	row +='<TD>Name :</TD>';
	row +='<TD><INPUT class=formfield maxLength=50 size=39 '; 	
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{	
	      	row +=' value= "'+CustDetails[0].name+'" ';
	}
	row += 'name=Cusname onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red size=1>*</FONT></TD></TR>';
	row +='<TR>';
	//Code commented and added by senthil on 01/06/2009 for show name istead of address1
	row +='<TD>Address 1:</TD>';
	row +='<TD><INPUT class=formfield maxLength=100 size=39 '; 	
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{	
	      	row +=' value= "'+CustDetails[0].address1+'" ';
	}
	row += 'name=address1 onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red size=1>*</FONT></TD></TR>';
	row +='<TR>';
	//Code commented and added by senthil on 01/06/2009 for change the caption
	row +='<TD>Address 2: </TD>';
	//row +='<TD>Address : </TD>';
	//Code commented and added by senthil on 01/06/2009 for change the filed length
	//row +='<TD><INPUT class=formfield maxLength=50 size=39 ';	
	row +='<TD><INPUT class=formfield maxLength=100 size=39 ';	
	//row +='<TD><textarea rows="2" cols="20" class=formfield name=address2 onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()">';	
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{
	      	row +=' value= "'+CustDetails[0].address2+'" ';
	      	//row +='+CustDetails[0].address2+';
	}
	//Code commented and added by senthil on 16/06/09 for address2 is not mandatory
	//row +='name=address2 onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red size=1>*</FONT></TD></TR>';
	row +='name=address2 onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"></TD></TR>';
	//End here
	//row +='</textarea></TD></TR>';
	row +='<TR>';
	row +='<TD>Town/City: </TD>';
	row +='<TD><INPUT class=formfield maxLength=50 size=39';
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{
      		row +=' value= "'+CustDetails[0].city+'" ';
	}
	row +='name=city onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red  size=1>*</FONT></TD></TR>';
	row +='<TD>State: </TD>';
	row +='<TD><INPUT class=formfield maxLength=50 size=39';
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{
      		row +=' value= "'+CustDetails[0].state+'" ';
	}
	row +='name=state onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red  size=1>*</FONT></TD></TR>';
	row +='<TR>';
	row +='<TD>ZIP/Postcode: </TD>';
	row +='<TD><INPUT class=formfield maxLength=10 size=39';	
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{
      		row +=' value= "'+CustDetails[0].zipcode+'" ';
	}
	row +='name=zip onKeyPress="return checkIt(event)" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red size=1>*</FONT></TD></TR>';
	row +='<TR>';
      row+='<td width="20%" class="PageText" align="left">Country:</td>';
    row+='<td width="39px" class="PageText">';
    if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=fnCountries();
	}
	else{
    row+= fnCountries(CustDetails[0].country);    
    	}
    row+='</td></tr>';
	row +='<TR>';
	row +='<TD>Phone: </TD>';
	row +='<TD><INPUT class=formfield maxLength=20 size=39';
	
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{
	      	row +=' value= "'+CustDetails[0].phonenumber+'" ';
	} 
	//Code commented and added by senthil on 11/04/2009 to remove mantory mark
	//row +='name=telephone onKeyPress="return checkIt(event)" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red  size=1>*</FONT></TD></TR>';
	row +='name=telephone onKeyPress="return checkIt(event)" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"></TD></TR>';
	//End here
	row +='<TD>Mobile: </TD>';
	row +='<TD><INPUT class=formfield maxLength=50 size=39';
	if(CustDetails.length==0 ||Cust[0].FirstName==''){
		row +=' ';
	}
	else{
      		row +=' value= "'+CustDetails[0].mobilenumber+'" ';
	}
	//Code commented and added by senthil on 11/04/2009 to remove mantory mark
	//row +='name=mobile onKeyPress="return checkIt(event)" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT color=red  size=1>*</FONT></TD></TR>';
	row +='name=mobile onKeyPress="return checkIt(event)" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"></TD></TR>';
	//End here
	row +='<TR>';
	
	row +='<TD>Email: </TD>'
//Code commented and added by senthil on 01/06/2009 for default	show login email id 
//	if(CustDetails.length==0 && Cust[0].FirstName==''){
//	      	row +='<TD><INPUT class=formfield maxLength=50 size=39 name=email onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT  color=red size=1>*</FONT></TD>';
//	} 
//	else if(Cust[0].Email.substring(0,6)=='Exists'){	
//		row +='<TD><INPUT class=formfield maxLength=50 size=39 name=email value= "'+ Cust[0].Email.substring(6) +'" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT  color=red size=1>*</FONT></TD>';
//	}
//	else{
//		row +='<TD><INPUT class=formfield maxLength=50 size=39 name=email value= "'+ Cust[0].Email +'" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"><FONT  color=red size=1>*</FONT></TD>';
//	}
if(CustDetails.length==0 ){
	      	
	if(Cust[0].Email.substring(0,6)=='Exists')	
		row +='<TD><INPUT class=formfield maxLength=50 size=39 name=email value= "'+ Cust[0].Email.substring(6) +'" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"></TD>';
	else
	    row +='<TD><INPUT class=formfield maxLength=50 size=39 name=email value= "'+ Cust[0].Email +'" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"></TD>';
    }
	    
else{
		row +='<TD><INPUT class=formfield maxLength=50 size=39 name=email value= "'+ CustDetails[0].Email +'" onkeydown="if(event.keyCode==13) event.keyCode=9;" onchange="funEnableButton()"></TD>';
	}
	//End here
	row +='</TR></TBODY></TABLE></TD></TR>';
	
	row +='<TR>';
	row +='<TD align=left colSpan=3>&nbsp; <BR><SPAN class="PageText style1"><STRONG><font color="red">Please ensure your details are correct before proceeding.</font></STRONG></SPAN>';
	row +='<BR></TD></TR>';
	row +='<TR>';
    //	row +='<TD align="center" colSpan=6><INPUT type="button" alt="proceed"  src="gui/img/bt_proceed.gif" OnClick="javascript:validateDeliverycheck(this.form,'+itemId+','+isCollection+', \''+strCriteria+'\');this.disabled=true;javascript:checkbuy('+itemId+','+isCollection+', \''+strCriteria+'\');" value="Save Details">'; 
    CustDetails[0].name
    //if(CustDetails.length==0)
    if(CustDetails.length==0 || CustDetails[0].name=='')
    {
       //Code commented and added by senthil on 01/06/2009 for change the button caption to checkout
    //row +='<TD align="center" colSpan=6><INPUT type="button" id="savedetails" alt="proceed"  src="gui/img/bt_proceed.gif" OnClick="javascript:validateDeliverycheck(this.form,'+itemId+','+isCollection+', \''+strCriteria+'\');" value="Save Details">'; 
    row +='<TD align="center" colSpan=6><INPUT type="button" id="savedetails" alt="proceed"  src="gui/img/bt_proceed.gif" OnClick="javascript:validateDeliverycheck(this.form,'+itemId+','+isCollection+', \''+strCriteria+'\');" value="Checkout">'; 
    //row +='<input type="button" id="shopping" name="shopping" value="Continue Shopping" class="input" disabled=true OnClick="javascript:checkbuy('+itemId+','+isCollection+', \''+strCriteria+'\');this.disabled=true;">';
    row +='<input type="button" id="shopping" name="shopping" value="Continue Shopping" class="input" disabled=true OnClick="javascript:funIntCourierAddress('+itemId+','+isCollection+', \''+strCriteria+'\');this.disabled=true;">';
    }
	else
	{
	//Code commented and added by senthil on 01/06/2009 for change the button caption to checkout
	//row +='<TD align="center" colSpan=6><INPUT type="button" id="savedetails" alt="proceed"  disabled=true src="gui/img/bt_proceed.gif" OnClick="javascript:validateDeliverycheck(this.form,'+itemId+','+isCollection+', \''+strCriteria+'\');" value="Save Details">'; 
	row +='<TD align="center" colSpan=6><INPUT type="button" id="savedetails" alt="proceed"  disabled=true src="gui/img/bt_proceed.gif" OnClick="javascript:validateDeliverycheck(this.form,'+itemId+','+isCollection+', \''+strCriteria+'\');" value="Checkout">'; 
	//row +='<input type="button" id="shopping" name="shopping" value="Continue Shopping" class="input" OnClick="javascript:checkbuy('+itemId+','+isCollection+', \''+strCriteria+'\');">';
	row +='<input type="button" id="shopping" name="shopping" value="Continue Shopping" class="input" OnClick="javascript:funIntCourierAddress('+itemId+','+isCollection+', \''+strCriteria+'\');">';
	}
	row +='<input type="button" name="Reset" value="Clear" class="input" OnClick="javascript:clearaddress();">';
	row +='</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>';
	row +='</form>';
	
	var element = document.getElementById("flashContent");
	    element.innerHTML=row;
	   
	    $('listProducts').innerHTML="";
	    $('listItems').innerHTML = "";
}
//added by deepika on 28/04/09
function checkIt(evt) 
{
    //checkNumbers();
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
    {
        if(charCode ==45 || charCode ==109 || charCode ==77 ||charCode ==46)
        {
        
        }
        else
        {
            alert("Enter only numeric values(0-9)");
            return false;
        }
    }
    status = ""
    return true
}
//function checkNumbers()
//{
//var maxLen = 10; 
//if (document.getElementById('telephone').value.length >= maxLen) 
//{
//var msg = "You have reached your maximum limit of characters allowed";
//document.getElementById('telephone').value = document.getElementById('telephone').value.substring(0, maxLen-1);
//alert(msg);
//}
//}
//end here
//function added by senthil on 08/06/2009
function displayaddress()
{
            var doc = document.frmAddress;
			doc.Cusname.value = CourierDetails[0].name;
			doc.address1.value = CourierDetails[0].address1;
			doc.address2.value = CourierDetails[0].address2;
			doc.city.value = CourierDetails[0].city;
			doc.state.value = CourierDetails[0].state;
			doc.country.selected = fnCountries(CourierDetails[0].country);
			doc.zip.value = CourierDetails[0].zipcode;
			doc.telephone.value = CourierDetails[0].phonenumber;
			doc.mobile.value = CourierDetails[0].mobilenumber;
			doc.email.value = CourierDetails[0].Email;
			funDisableButton();
}
//end here
function clearaddress()
{
			var doc = document.frmAddress;
			doc.Cusname.value = "";
			doc.address1.value = "";
			doc.address2.value = "";
			doc.city.value = "";
			doc.state.value = "";
			doc.country.value = "";
			doc.zip.value = "";
			doc.telephone.value = "";
			doc.mobile.value = "";
			doc.email.value = "";
			funEnableButton();
}
//end here
//Code added by senthil on 09/05/2009 for enable save details button when value is changed
function funEnableButton()
{  
 
    document.getElementById("shopping").disabled=true;
    document.getElementById("savedetails").disabled=false;  
}
function funDisableButton()
{  
//Condtion added by senthil on 11/06/2009 for disable  contiune shopping button when the value are empty
 if(CourierDetails[0].name != '')
  {
  document.getElementById("shopping").disabled=false;
  document.getElementById("savedetails").disabled=true;
  }
}
//End here
//Code added by senthil on 09/05/2009 for enable save details button when value is changed
function funIntCourierAddress(itemId, isCollection, strCriteria)
{ 
    checkbuy(itemId, isCollection, strCriteria);
    var url = 'Data.aspx?mode=main&rnd='+Math.random();	    	
	url += '&action=IntCourierAddress&productid='+itemId;		
    handleRequest(GET, url);
}
//End here

function displaySelectItem(item)
{
	flavtmp = "Select" ;
	sizetmp = "Select";
    itemnametmp=item.name; 
    var itemEnglishName=item.Bookname;
	isCollection=false;
	var html= '<table width="440" cellpadding="3" cellspacing="0" border="0" bgcolor="#D6DDBD"><form name="frmSelectProducts" >';
	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" >'+item.name+'</center></h1></td>';
	html+='<td width="0%"><img src="gui/img/bg_title_right.gif" width="10" height="37" alt=""></td>';
	html+= '</tr></table></td></tr>';
    var tmpvalue = SelectedProducts[0].name;
    var tempselp = new Array();
    var j;
    var tempShortdescription =new Array();
    var strCriteria = "Products";
    var spqty,spmt;
    var author="";
    var tempdescription =new Array();
    var tempImage=new Array();
    var tempAuthorID="";

    for(var i=0,j=0;i<SelectedProducts.length;i++)
    {
        if((SelectedProducts[i].name == item.name)&&(SelectedProducts[i].ProductCategoryID==1))
	    { 
	        tempselp[j] = SelectedProducts[i].Author;
            tempShortdescription[j]=SelectedProducts[i].desc;
            tempdescription[j]=SelectedProducts[i].AuthorDescription;
            tempImage[j]=SelectedProducts[i].AuthorImage;
	        tempAuthorID=SelectedProducts[i].AuthorID;

        }
    }
    
   	    for(var i=0,j=0;i<SelectedProducts.length;i++)
   	    {
            if((SelectedProducts[i].name == item.name)&&(SelectedProducts[i].ProductCategoryID==1))
		    {
		        //commented and modified by deepika on 28/04/09
		       //newhtml = '&nbsp;<span class="PageText">$ '+SelectedProducts[i].ourprice +' (approx...Rs.'+SelectedProducts[i].ourprice * INRValue[0].value+')</span>';
		       newhtml = '&nbsp;<span class="PageText">$ '+SelectedProducts[i].ourprice +' (approx...Rs.'+(SelectedProducts[i].ourprice * INRValue[0].value).toFixed(2)+')</span>';
		      var discount=SelectedProducts[i].DiscPrice ;
		    }
	    }	
      if (tempselp[j]!= "N/A")
      {
      
        author='<table><tr><td align="left" width="30%"><img height="100" width="100" src='+ tempImage[j] +' alt="Author Image" /></td><td align="left" valign="top" width="70%"><font size="2"> <div id="LoadDescription" ></div></td></tr></table>';
         var desc=tempdescription[j];
         var attribute= desc.substr(0, desc.indexOf(".", 0))
         
         $('popupBody').innerHTML=author;
	      clientSideInclude("LoadDescription", "admin/PageContent/Author/"+ attribute +"/"+ desc);
	      //commented and modifed by geetha on 25/03/2009
          //html+= '<tr><td align="left" class="PageText" width="30%"><strong>ஆசிரியர்:</strong></td><td class="PageText" width="30%" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:displaySearchedBooks('+tempAuthorID+',1,this.form)"  ><font color="Blue">'+tempselp[j]+'</font></a></td>';
                                                                                                                                                                                                                                          
          html+= '<tr><td align="left" class="PageText" width="30%"><strong>ஆசிரியர்:</strong></td><td class="PageText" width="30%" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+tempAuthorID+',1,\''+tempselp[j]+'\')"  ><font color="Blue">'+tempselp[j]+'</font></a></td>';
          //ends here
      }
      if(item.issale=="True")
      {
          html+= '<td width="50%" ><div id ="SingleDisplayBuy"><a href="javascript:checkbuy('+item.id+','+isCollection+', \''+strCriteria+'\')"><img src="images/buybutton.gif" align="left" alt="" width="125" height="25" vspace="5" border="0"></a></div></td></tr>';
      }
      else if(item.isnew=="True")
      {
          //Code Commented and added by senthil on 17/06/2009 for add button image for isfree option
          //html+= '<td ><img src="images/by_new.gif" align="center" alt="" width="46" height="17" vspace="5" border="0"></a></td></div></tr>';
          html+= '<td width="50%" ><div id ="SingleDisplayBuy"><a href="javascript:checkbuy('+item.id+','+isCollection+', \''+strCriteria+'\')"><img src="images/buybutton.gif" align="left" alt="" width="125" height="25" vspace="5" border="0"></a></div></td></tr>';
            //End here
      }
      else if(item.isfree=="True")
      {
		  html+= '<td ><input type="button" value="Download" onclick="return Download(this.form,'+item.id+')" id="Button1"/></td></tr>';
	  }	
      for(var i=0,j=0;i<SelectedProducts.length;i++)
      {
        if((SelectedProducts[i].name == item.name)&&(SelectedProducts[i].ProductCategoryID==1))
	    { 
	        tempselp[j] = SelectedProducts[i].Publisher;
            tempShortdescription[j]=SelectedProducts[i].desc;
        }
      }
      if (tempselp[j]!= "N/A")
      {
         html+= '<tr><td align="left" class="PageText"><strong>பதிப்பாளர்:</strong></td><td class="PageText">'+tempselp[j]+'</td>';
      }
      for(var i=0;i<tempselp.length;i++)
      {
       for(j=i+1;j<tempselp.length;j++)
       {
        if(tempselp[i] > tempselp[j])
        {
            tmpvalue = tempselp[i];
            tempselp[i] = tempselp[j];
            tempselp[j] = tmpvalue;
       }
      }
     }
    tmpvalue = tempselp[0];

     if (tempselp.length==1)
     {
        sizetmp=tmpvalue;
     }
  
    for(var i=0;i<tempselp.length;i++)
    {
	    if(tmpvalue != tempselp[i]) 
		html +='<option value="'+tempselp[i]+'" >'+tempselp[i]+'</option>'; 
 		tmpvalue = tempselp[i];  
    }     
    if(item.issale=="True")
    {
        html+= '</td></tr></select><tr><td align="left" class="PageText"><strong>Price:</strong></td><td width="50%"><div id="TestDiv">'+newhtml+'</div></td>';
      
        if (tempselp[j]!= "N/A")
        {
           html+= '<td width="50%"><div id ="SingleDisplayBuy" align="right"><img src="gui/img/CreditCard.png" align="right" alt="" width="125" height="25" vspace="5" border="0"></div></td></tr>';
        }
          if (discount!=0)
         {
         html+= '</td></tr></select><tr><td align="left" class="PageText"><strong>Discount:</strong></td><td width="50%"><div id="TestDiv">'+discount+'%</div></td>';
         }
    }

	html+= '</tr>';
	html+= '<td valign="top" align="left" width="30">';
	html+= '<a href="#" onClick="  return displaySelectedItem('+item.id+');"><br>';
	html+= '<img src="'+item.image+'" alt="'+item.name+'"  border="0">';//end here
	html+= '</a>'
	html+= '<a href="#" onClick="  return displaySelectedItem('+item.id+');" ></a><br><br></td>';
    html+='<td colspan="2" align="left" width="70%">';
    html+= '<div id="includeone" class="promoProductDesc"></div></td>';
    html+='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>Size:</strong></td><td class="PageText">'+item.Size + '</td>';
	if(item.Samples!="N/A")
    {
       html+= '<td colspan=2 align="left" class="PageText"><span class="promoProductDesc"><a href="'+item.Samples+'" ><font color="blue">View Sample Pages</font></a></span><br></td></tr>';
    }
	html+='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>மொ.பக்கம்:</strong></td><td class="PageText">'+item.NoOfPages + '</td></tr>';
    html+='</form></table>';
    return html;
}
function checkbuy(itemId,isCollection,strCriteria)
{
 var itemidtmp; 
 isavailable="false";
  for(var i=0;i<SelectedProducts.length;i++)
  {
	if(SelectedProducts[i].id == itemId)
	{
		itemnametmp = SelectedProducts[i].name;		
	}
 }
 //commented by deepika on 18/04/09
// for(var i=0;i<document.frmSelect.elements.length;i++)
// {  
//	if(document.frmSelect.elements[i].name == itemnametmp)
//	{
//		flavtmp=document.frmSelect.elements[i+1].value;
//		sizetmp=document.frmSelect.elements[i].value;	
//		break;
//	}
// }

 for(var i=0;i<SelectedProducts.length;i++)
 {
	if(SelectedProducts[i].name==itemnametmp)
	{
		isavailable="true";
		itemidtmp=SelectedProducts[i].id;
	}	
 }
	if(isavailable=="true")
	{
	
	return buy(itemidtmp,isCollection,strCriteria);
	}
}

function funcFreeDownloads()
{
 var log =displayLogin() ;
		 var html ="";
		 var author="";
         var tmp="";
            html +="<br><br>";
            html +='<span><center><font color="#CC6600"><strong>FREE DOWNLOADS<font></strong></span>';
            html +='<center><table class="promoProductDesc" width="460"><tr><td align="center" colspan="4"></td></tr>';
			html += '<tr>';
			html += '</table></center>';
			if((Cust[0].FirstName=='')||(Cust[0].FirstName=='LoginFailed')||(Cust[0].FirstName=='RegLoginFailed')||(Cust[0].FirstName=='UnApproved')||(Cust[0].FirstName=='RegSuccess')||(Cust[0].FirstName=='SignUp')||(Cust[0].FirstName=='Registeruser'))
            {
			html += '<br/><center><span class="promoProductDesc"><center><b><font color="#8B0000">Please log in with email ID/new users  register and log in to avail Free Offers. </font></b></center></span>';   
		    }
           if((Cust[0].FirstName!='')&&(Cust[0].FirstName!='LoginFailed')&&(Cust[0].FirstName!='RegLoginFailed')&&(Cust[0].FirstName!='UnApproved')&&(Cust[0].FirstName!='RegSuccess')&&(Cust[0].FirstName!='SignUp')&&(Cust[0].FirstName!='Registeruser'))
	        {

    		html +="<br><br><span class='PageText style1'><font color='#8B0000' size=2><center><strong>After download open the SPReader and read.</strong></font></center></span>";
    		}
		    html += '<br/><table>';
			for(var i=0;i<FreeDownloads.length;i++)
			{	  
	                var bookid=FreeDownloads[i].id;
	                var strDate = FreeDownloads[i].issueDate;
	                var strOpt="isfree";
                    tmp += '<tr><td><table><tr><td>';
                    tmp += '<form name="frmfreedownload'+i+'" method="post" action="downloadGift">';
                    tmp += '<table  align="top" class="listTable" width="0"   border="0"  cellpadding="0" cellspacing="0" >';
	                tmp += '<tr valign="top">';
	                tmp += '<td align="top">';
	                tmp += '<img src="'+FreeDownloads[i].thumb+'"alt="'+FreeDownloads[i].name+'" border="1%"></td>';
                    tmp += '</tr>'
                    if((Cust[0].FirstName!='')&&(Cust[0].FirstName!='LoginFailed')&&(Cust[0].FirstName!='RegLoginFailed')&&(Cust[0].FirstName!='UnApproved')&&(Cust[0].FirstName!='RegSuccess')&&(Cust[0].FirstName!='SignUp')&&(Cust[0].FirstName!='Registeruser'))
	                {                                                                                                                     
	                  //Code commented and added by senthil given by magalakshmi on 10/05/2010 for pass macid string to freedownload function
	                  // tmp += '<tr><td>&nbsp;</td></tr><tr><td><input type="button" value="Download" onclick="return Download(this.form,'+bookid+',\''+strDate+'\',\''+strOpt+'\')" id="Button1"/></td></tr>';
	                   tmp += '<tr><td>&nbsp;</td></tr><tr><td><input type="button" value="Download" onclick="return Download(this.form,'+bookid+',\''+strDate+'\',\''+strOpt+'\',\'MacId1\')" id="Button1"/></td></tr>';
	                 //End here senthil 10/05/2010
	                }
		            tmp += '</table></form></td>';
		            tmp += '<td><table broder ="2">';
		            if(FreeDownloads[i].ProductCategoryID == 1)
		            {
		               if (FreeDownloads[i].Author!= "N/A")
                       {
                        author='<table><tr><td align="left" width="30%"><img height="100" width="100" src='+ FreeDownloads[i].AuthorImage +' alt="Author Image" /></td><td align="left" valign="top" width="70%"><font size="2"> <div id="LoadDescription" ></div></td></tr></table>';
                        
                        var desc=FreeDownloads[i].AuthorDescription;
                        var attribute= desc.substr(0, desc.indexOf(".", 0))
                        $('popupBody').innerHTML=author;
                                                                       
                        
                        clientSideInclude("LoadDescription", "admin/PageContent/Author/"+ attribute +"/"+ desc);
                        //commented and modified by geetha from saraswathy on 25/03/2009
                               //tmp += '<tr><td align="left" class="PageText" ><strong>ஆசிரியர்:</strong></td><td class="PageText" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:displaySearchedBooks('+FreeDownloads[i].AuthorID+',1,this.form)"  > <font color="blue">'+FreeDownloads[i].Author+'</font></a></td></tr>';
		                       tmp += '<tr><td align="left" class="PageText" ><strong>ஆசிரியர்:</strong></td><td class="PageText" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+FreeDownloads[i].AuthorID+',1,\''+FreeDownloads[i].Author+'\')"><font color="blue">'+FreeDownloads[i].Author+'</font></a></td></tr>'; 
		                       //ends here
		               }
		            }
		            else
		            {
		               if (FreeDownloads[i].Editor!= "N/A")
                       {
                       //commented and modified by geetha on 25/03/2009
                        //tmp += '<tr><td align="left" class="PageText"><strong>ஆசிரியர்:</strong></td><td class="PageText" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:displaySearchedBooks('+FreeDownloads[i].EditorID+',1,this.form)"  > <font color="blue">'+FreeDownloads[i].Editor+'</font></a></td></tr>';
                        tmp += '<tr><td align="left" class="PageText"><strong>ஆசிரியர்:</strong></td><td class="PageText" onmouseover="javascript:popUpAuthor()" onmouseout="javascript:popUpAuthor()" style="cursor: pointer;" ><a href="javascript:funDisplaySearchedBooks(0,\'funDisplaySearchedBooks\','+FreeDownloads[i].EditorID+',1,\''+FreeDownloads[i].Editor+'\')"> <font color="blue">'+FreeDownloads[i].Editor+'</font></a></td></tr>';
                        //ends here
    	               }
    	            }
		            if (FreeDownloads[i].Publisher!= "N/A")
                    {
                        tmp += '<tr><td align="left" class="PageText"><strong>பதிப்பாளர்:</strong></td><td class="PageText">'+FreeDownloads[i].Publisher+'</td></tr>';
                    }
                    tmp +='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>Size:</strong></td><td class="PageText">'+FreeDownloads[i].Size + '</td></tr>';
	                tmp +='<tr><td align="left"  width="25%" colspan="0" class="PageText"><strong>மொ.பக்கம்:</strong></td><td class="PageText">'+FreeDownloads[i].NoOfPages + '</td></tr>';
		            tmp += '<tr><td colspan="3"><div id="includeone'+i+'" class="promoProductDesc"></div></td></tr></table></td>'; 
			        tmp+='<tr></table></td></tr>';

			        tmp+='<tr></table></td></tr>';
	 	}
	 	html+=tmp;
		html +='</table>';
		html += '<img src="images/spacer.gif" alt="" width="1" height="50"><img src="images/spacer.gif" alt="" width="1" height="50">';
	    html += '<img src="images/spacer.gif" alt="" width="1" height="50"><img src="images/spacer.gif" alt="" width="1" height="50">';
		 $('flashContent').innerHTML = html;
		 $('listProducts').innerHTML = "";
		 $('listItems').innerHTML = "";
		 for(var i=0;i<FreeDownloads.length;i++)
		 {	  
	         var bookid=FreeDownloads[i].id;
             clientSideInclude("includeone"+i,"admin/PageContent/Products/"+bookid+"/"+FreeDownloads[i].LongDescription);
         }
         if((Cust.length==0) ||(Cust[0].FirstName=='')||(Cust[0].FirstName=='LoginFailed')||(Cust[0].FirstName=='RegLoginFailed')||( Cust[0].FirstName=='RegSuccess')||(Cust[0].FirstName=='UnApproved'))   
         { 
		    $('cart').innerHTML = log;
		 }
}

function displayProducts(booklist) 
{	
	flavtmp = "Select" ;
	sizetmp = "Select";
    var html ='<form name="frmProducts" <div id="list" style="overflow: auto; width: 480px; height: 850px">';
    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)
    {
	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++;
		}		
	}
    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>';
			html+='<br/><br/><br/><br/><br/><br/><br/><br/><br/><tr><td><center><font color="#CC6600"><b>விரைவில் வருகிறது....</b></font></center></td></tr>';
	}
    html+='</table></div></form>';
	$('listProducts').innerHTML = html;

}
//Code commented and added by senthil on 15/09/2009 for add one more parameter renewal
//function buy(itemID,isCollection,strCriteria)
function buy(itemID,isCollection,strCriteria,strRenewal)
//End here
{
     if((Cust.length==0) ||(Cust[0].FirstName=='')||(Cust[0].FirstName=='LoginFailed')||(Cust[0].FirstName=='RegLoginFailed')||(Cust[0].FirstName=='UnApproved')||(Cust[0].FirstName=='RegSuccess'))
     {
		     var log =displayLogin() ;
		     var html = '<table width="100%" border="0" cellspacing="0" cellpadding="">';
	         html += '<tr>';
		     html += '<td width="0%"><img src="gui/img/spacer.gif" alt="" width="10" height="24"></td>';
		     html += '</tr>';
             html += '</table>';
             html += '<br/><br/><br/><br/><br/><br/><br/><br/><br/><center><span class="promoProductDesc"><center><b><font color="#8B0000">Please log in with email ID/new users  register and log in . </font></b></center></span>';   
             $('flashContent').innerHTML = html;
		     $('listProducts').innerHTML = "";
		     $('listItems').innerHTML = "";
		     SetFocus();
	         return; 
    }	
    else
    { 
       //Code added by senthil on 15/09/2009 for add one more parameter renewal
	    var Renewal;
		if(strRenewal == undefined)
		{
		   Renewal = "Buy";
		}else
		{
		   Renewal = strRenewal;
		}
		//End here
	    var url = 'Data.aspx?mode=main&rnd='+Math.random();
	    var itemavailable =true;	
		url += '&action=buy';
		url += '&itemID='+itemID;
		url += '&isCollection='+isCollection;	
		url += '&criteria='+strCriteria;
		//Code added by senthil on 15/09/2009 for add one more parameter renewal
		url += '&Renewal='+ Renewal;
		//End here
		
		handleRequest(GET, url, function(req)
		 {
		 
            eval('var cart = '+req.responseText);
	        
			if (cart.Status=="MacIDNull")
			{
			    var html = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><span class='promoProductDesc'><center><b><font color='#8B0000'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please Activate the SPReader.</font></b></center></span>";
			    passwordemailed(html);
			    var log =displayLogin() ;
			}
			else if (cart.Status=="NoSessionState")
			{
			    var html = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><span class='promoProductDesc'><center><b><font color='#8B0000'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Your session has expired unexpectedly. Please close the browser try after some time.</font></b></center></span>";
			    passwordemailed(html);
			    var log =displayLogin() ;
			}
			else
			{
			tmpcart = cart;
			viewCart(cart);
			}

		});
			
directbuy="true";
}
}	
