var retValue,fShippingCost;
var currency_conversion_factor,paypal_currency,currency_name,selRating, shopping_cart_status;
fShippingCost=0;
selRating=0;
shopping_cart_status=0;
/****************************/


var shipping_info='<ul class="pop_s_t"><span class="pop_s_t_d">Payment, delivery</span></ul><ul class="pop_s_c"><li class="pop_s_c_m">We deliver to all mainland UK addresses with a valid postcode. All items are dispatched using Royal Mail delivery service, unless otherwise mentioned.</li><li class="pop_s_c_m">IMP NOTE - Please mention your  correct delivery address while making payment.<br>If you enter the wrong/incomplete address, we will NOT be liable for any subsequent loss of the items.<br>Address  changes after making payment will NOT be considered.<br><br>Buyer is responsible for all return shipping costs for any item that is returned as undeliverable, unclaimed or  refused.&nbsp;</li><li class="pop_s_c_d">P&P charges - </span><li class="pop_s_c_m">These include transaction, advertising, distribution, delivery charges, packing, handling related costs and not just the cost of postage. Please note - Even if the p&p charges shown as free in some of our listings, we may split the item cost and the p&p charges separately in the invoice. This price includes the cost of the item, accessories, shipping of item and shipping of accessories. Price shown is total price you pay. We may split up your order into multiple packages and cost of each packet would be shown separately on each invoice. Please note you may not receive all of your packages at the same time.Click the <b>Add to Cart</b> button;</li><li class="pop_s_c_m">Get into your <b>Shopping Cart</b> page;</li><li class="pop_s_c_m">Select your country in the drop-down menu</li><li class="pop_s_c_m">Your estimated shipping cost will be displayed</li></ul><br/><br/>';

var return_info='<ul class="pop_s_t"><span class="pop_s_t_d">Our returns policy </span></ul><ul class="pop_s_c"><li class="pop_s_c_m">We offer a straightforward refund or replacement policy in the unlikely event there is a problem with your product. <br/> Although all items dispatched will be securely packaged, unfortunately if you receive damaged items, please contact within 24 hrs of receiving the item. <br/> We are happy to replace or refund faulty goods and aim to resolve issues quickly and to your satisfaction. <br/><br/> Returns are accepted within 7 days of the date of receipt. However, returns will incur a 20% restocking fee. Postage charges cannot be returned and returning postage charges should be borne by the purchaser Returned goods Must be in Perfect Unopened Condition. <br/> In the unlikely event you need to return an item, please email us for an authorisation code. This must be clearly stated on your parcel. Please note that we cannot accept returns that have not been authorised. <br/> We can not accept returns without any previous communication with the buyer.</li></ul><br/><br/>';


var email_support='<ul class="pop_s_t"><span class="pop_s_t_d">Email support</span></ul><ul class="pop_s_c"><li class="pop_s_c_m">We try to reply all queries within few hours of receiving it.<br/> Sometimes it may take up to 48 hours. Being business seller, queries received on late Friday or over  weekend/bank holiday might take more time. We appreciate your patience and support.</li></ul><br/><br/>';


/****************************/

function ShowHideDiv(divId)
{

//alert('P&p is applicable');
//alert(document.getElementById(divId).style.display);
if (document.getElementById(divId).style.display=='none'  )
{
//alert(document.getElementById(divId).style.display);

document.getElementById(divId).style.display='inline-block';
}

else
{
document.getElementById(divId).style.display='none';

}

 

return true;
}



function setCurrency(icurrency_conversion_factor, icurrency_name, ipaypal_currency)
{
currency_name=icurrency_name;
currency_conversion_factor=icurrency_conversion_factor;
paypal_currency=ipaypal_currency;
}
//trimming functions start
function ltrim(argvalue) {

  while (1) {
    if (argvalue.substring(0, 1) != " ")
      break;
    argvalue = argvalue.substring(1, argvalue.length);
  }

  return argvalue;
}

function rtrim(argvalue) {

  while (1) {
    if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
      break;
    argvalue = argvalue.substring(0, argvalue.length - 1);
  }

  return argvalue;
}

function trim(argvalue) {
  var tmpstr = ltrim(argvalue);

  return rtrim(tmpstr);

}


// trimming functions end



function floatBox(posEL,element)
{ 
  var posX,posY,pos,offTop;
  var width=539;
  var height=338;
  
  if($.browser.msie)
  {
	pos=$(posEL)[0];
    offTop=120;
  }
  else
  {
	pos=$(posEL)[0];offTop=130;
  }
  
  var et=pos.offsetTop;
  var el=pos.offsetLeft;
  
  while(pos=pos.offsetParent)
  {
    et+=pos.offsetTop;
    el+=pos.offsetLeft;
  }
  posX=el-width;
  posY=et-offTop;
  
  var box=$('#pop_window');
  box.css({position:'absolute',zIndex:999,top:posY,left:posX,width:width,height:height});
//  $("#pngBgWin").css({position:'absolute',zIndex:998,top:posY,left:posX,width:width,height:height}).show();
  
  var str="<img onclick='$(\"#floatBox_img\").parent().hide();hide_select(1,\"id\",\"attrib-\");' src='/images/close.gif' class='hand' title='close' alt='close' id='floatBox_img'/><div class='png'>";

str =  str + "<table    bgcolor='white' class='vbor4'><tr><td>";

  switch(element)
  {
    case'#shipping_info':
      str+=shipping_info;
      break;
      
    case'#payment_info':
      str+=payment_info;
      break;
	
	case'#warranty_info':
      str+=warranty_info;
      break;
    
	case'#warranty_info_2':
      str+=warranty_info_2;
      break;
      
    case'#after_service':
      str+=after_service;
      break;

 case '#return_info':
      str+=return_info;
      break;

 case '#email_support':
      str+=email_support;
      break;

  }


str+="</td></tr></table>";

  str+="</div>";
  box.html(str);
  hide_select(0,"id","attrib-");
  $('#pop_window').show();
  return false;
}

function hide_select(a,b,c)
{
  $("select").each(function(i)
  {
    var t=a==0?"hidden":"visible";
    var r=b==0?"":"["+b+"*='"+c+"']";
		
    if($.browser.version==6.0) $("select"+r).css({visibility:t});
  });
}

function popUp(URL) {
//alert('popup');
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 0,top = 0');");
}



 


 


 

//'''''''''''''Ends



function build_array_from_global_var()
{
var temp;
temp="";
//alert(global_sess);
if (global_sess!="")
{
var product_data1=global_sess.split("/");
for (i=0; i <product_data1.length; i++)
{
my_shopping_cart[i]=product_data1[i].split("*");
temp = temp + "$" + my_shopping_cart[i];
}
tot_cart_items=product_data1.length;
}
else
tot_cart_items=0;

//alert(temp);
//alert("calling post_item_data")
}

function list_product_data()
{
var str,i;
str="<table>";

for (i=0; i <3; i++)
{
str=str +  "<tr><td>" + product_item[i][1] + "...." + "<input type=button value=Buy  onclick='add_item(" + i.toString() + ",0,-1);'></input></td></tr>"  ;
}
str=str + "</table>";
product_list.innerHTML=str;
}

//function get_cart(l,price)
function get_cart(l,prod_name,price,prod_price,prod_page_link)

{
//alert('ddd');
//currency_conversion_factor=icurrency_conversion_factor;

//alert('m i on load');
var str,i;
var vprod_price;
var k9,amt=0;
//alert(price);
str="<table>";

//alert(tot_cart_items);
if (tot_cart_items<=0 )
            str=str +  "<tr><td colspan=4 class='black'>Cart is empty</td></tr>"  ;
else
{
            for (i=0; i <tot_cart_items; i++)
		{
//alert(my_shopping_cart[i][6]);

 
            if (my_shopping_cart[i][2]=="1") 
            {
                    k9=parseInt(my_shopping_cart[i][0]);//item id
                    //alert(my_shopping_cart[i][3]);
                    if (my_shopping_cart[i][3] == -1)//dnt override rice in DB
                    {
                       // str=str +  "<tr><td valign=top>" + my_shopping_cart[i][1]   + " x </td><td width='130'>" +   product_item[k9][1] + " " +product_item[k9][4] + "</td><td> <a style='cursor: hand' class='red12bold' onclick='remove_item(" + i.toString() + ");'>X</a></td></tr>"  ;
                       // str=str +  "<tr><td valign=top>" + my_shopping_cart[i][1]   + " x </td><td width='130'>" + my_shopping_cart[i][4]+" "+ my_shopping_cart[i][5] +"</td><td> <a style='cursor: hand' class='red12bold' onclick='remove_item(" + i.toString() + ");'>X</a></td></tr>"  ;

str=str +  "<tr><td valign=top class='black'>" + my_shopping_cart[i][1]   + " x </td><td width='130' class='black'><a href='"+my_shopping_cart[i][6].replace(/\|/g,'/') +"'>" + my_shopping_cart[i][4] +"</a></td><td> <a style='cursor: hand;cursor:pointer' class='red12bold' onclick='remove_item(" + i.toString() + ");'>X</a></td></tr>"  ;


retValue = LoadSubprograms(my_shopping_cart[i][0],my_shopping_cart[i][1],my_shopping_cart[i][4]);
//alert('Shopping cart updated');
 //alert(retValue );
amt=amt+parseFloat(retValue) *parseFloat(my_shopping_cart[i][1]);

                       
                       
                    }
                    else //override price in DB- use sent price
                    {
                        str=str +  "<tr><td valign=top class='black'>" + my_shopping_cart[i][1]   + " x </td><td width='130' class='black'>" + my_shopping_cart[i][4]+"  "+ my_shopping_cart[i][5] +"</td><td> <a style='cursor: hand;cursor:pointer' class='red12bold' onclick='remove_item(" + i.toString() + ");'>X</a></td></tr>"  ;
                        //alert(my_shopping_cart[i][3]);
                       // amt=amt+parseFloat(my_shopping_cart[i][4]) *parseFloat(my_shopping_cart[i][1]) ;
                       amt=amt+parseFloat(my_shopping_cart[i][5]) *parseFloat(my_shopping_cart[i][1]) ; //20-sep-10
amt=amt+parseFloat(LoadSubprograms(my_shopping_cart[i][0],my_shopping_cart[i][1],my_shopping_cart[i][4])) *parseFloat(my_shopping_cart[i][1]);
//get_item_data_price(my_shopping_cart[i][0],my_shopping_cart[i][1]);
//vprod_price=get_item_data_price(my_shopping_cart[i][0],my_shopping_cart[i][1]) ;
//alert("Y"+ vprod_price);

	

                    }

            }
		}//for?

            //str=str +  "<tr><td colspan=4>____________________________</td></tr>"  ;
            //str=str +  "<tr><td colspan=4> tot_cart_itemsal Invoice value : " + roundNumber(amt).toString() + "</td></tr>"  ;
}

str=str + "</table>";

document.getElementById("cart").innerHTML=str;
document.getElementById("product_value").innerHTML=(Math.round(amt*100)/100).toString();
//alert(my_shopping_cart[i-1][6])
build_global_var_from_array();
}

function roundNumber(inum) {
	var rnum = inum;
	var rlength = 2; // The number of decimal places to round to
	if (rnum > 8191 && rnum < 10485) {
		rnum = rnum-5000;
		var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
		newnumber = newnumber+5000;
	} else {
		var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	}
	return newnumber;
}


function build_global_var_from_array()
{
var temp;
temp="";
	if (tot_cart_items==0) 
		global_sess="";
	else
	for (i=0; i <tot_cart_items; i++)
	if (i==0) {  
temp=temp + "*" + my_shopping_cart[i][0] ;
		global_sess=my_shopping_cart[i][0] + "*" + my_shopping_cart[i][1] + "*" + my_shopping_cart[i][2] + "*" + my_shopping_cart[i][3] + "*" + my_shopping_cart[i][4] + "*" + my_shopping_cart[i][5]+ "*" + my_shopping_cart[i][6];
}
	else
{
	temp=temp + "*" + my_shopping_cart[i][0] ;
		global_sess=global_sess + "/" + my_shopping_cart[i][0] + "*" + my_shopping_cart[i][1] + "*" + my_shopping_cart[i][2] +"*" + my_shopping_cart[i][3] + "*" + my_shopping_cart[i][4] + "*" + my_shopping_cart[i][5]+ "*" + my_shopping_cart[i][6];
}
//alert(global_sess);
//alert("calling");
//alert(temp + "aaa");
post_item_data(temp);
//alert("XX"+global_sess);
post_data(global_sess);


}



function post_data(s)
{  

var objHTTP;
if (window.XMLHttpRequest) {
objHTTP= new XMLHttpRequest();
} else {
try { objHTTP= new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
try { objHTTP = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
objHTTP= false; } }
}


/*  var objHTTP;//=new XMLHttpRequest();
  objHTTP=new ActiveXObject("Microsoft.XMLHTTP");
*/
  //objHTTP.open("POST","http://www.123discountshop.com/asp/post_sess_data.asp",false);
  objHTTP.open("POST","../asp/post_sess_data.asp",false);
  objHTTP.send("<xml cart='" + s + "' ></xml>");
  //alert('<%=session.Contents("my_shopping_cart")%>');
// alert(objHTTP.responseText );
}


/****************************************/
var sessionObj1 = new sack();
var status;

function get_item_data_price(item_id, qty) //my_shopping_cart[i][0]
{


        sessionObj.requestFile ='/asp/get_item_data_price.asp?qname=' + item_id + '&qty=' + qty +'&fact='+paypal_currency+'&conv_fact='+currency_conversion_factor+'&p_name='+prod_name+'&icurr='+currency_name+'';


        
  sessionObj.onCompletion = function(){ 
        ////close registration table and open download table
        var status=sessionObj.response;
//alert(status + 'aa');
        if(status=='Success')
        {

       
        }
        else if(status=='Failed')
        {

        alert('Registration failed, Please try again');
        }
        else if(status=='LoginExist')
        {
        alert('Login Id exists');
        }
        else if(status=='EmailExist')
        {
        alert('Email Id already exists');
        }
        else
        {
        alert('Some error has occured with server,Please try again');
        } 
        


        }; 

        sessionObj.runAJAX(); 

}


function sessComplete(){ 
        ////close registration table and open download table
 
          status=sessionObj1.response;

retValue=status;
//alert(retValue+'retValue');
 
        if(status=='Success')
        {

       
        }
        else if(status=='Failed')
        {

        alert('Registration failed, Please try again');
        }
        else if(status=='LoginExist')
        {
        alert('Login Id exists');
        }
        else if(status=='EmailExist')
        {
        alert('Email Id already exists');
        }
        else
        {
       // alert('Some error has occured with server,Please try again');
        } 
        
//return status;

        }

  function getHTTPObject(){
          if (window.ActiveXObject)
              return new ActiveXObject("Microsoft.XMLHTTP");
          else if (window.XMLHttpRequest)
              return new XMLHttpRequest();
          else {
              alert("Your browser does not support AJAX.");
              return null;
          }
      }

    function LoadSubprograms(item_id, qty,prod_name){
 

        httpObject = getHTTPObject();
        if (httpObject != null) {

            httpObject.open('GET', '/asp/get_item_data_price.asp?qname=' + item_id + '&qty=' + qty +'&fact='+paypal_currency+'&conv_fact='+currency_conversion_factor+'&p_name='+prod_name+'&icurr='+currency_name+'', false);
            httpObject.send(null);         
		 
		retValue= httpObject.responseText

		return retValue; 

        }

    }
    
   
function LoadShippingPrices(strDispatchTo,shippingMethod,strSessionCurrency){
var sentData, strDispatchFrom
sentData='';
//qty
//my_shopping_cart[i][1]

//name
//my_shopping_cart[i][4]

//item id
//my_shopping_cart[i][0]

 for (i=0; i <tot_cart_items; i++)
		{

if (my_shopping_cart[i][4].search('Factory')>0)

strDispatchFrom= 'China';

else
strDispatchFrom= 'UK';


sentData = sentData + my_shopping_cart[i][0] + '$$$' + my_shopping_cart[i][1] + '$$$' + strDispatchFrom + '$$$' + strDispatchTo +   '$$$' + strSessionCurrency + '$$$'+ shippingMethod +'***' ;

}
//alert (sentData); 

        httpObject = getHTTPObject();
        if (httpObject != null) {

//alert('/asp/get_item_shipping_price.asp?qStr='+ sentData  + '');
            httpObject.open('GET', '/asp/get_item_shipping_price.asp?qStr='+ sentData  + '', false);
            httpObject.send(null); 
//		alert('/asp/get_item_shipping_price.asp?qStr='+ sentData  + '');        
		 
		retValue= httpObject.responseText

		return retValue; 

        }

    }


function post_item_data(s)
{  


  var sessionObj = new sack();
//alert('/asp/post_item_sess_data.asp?qname=' + s) ;
        sessionObj.requestFile ='/asp/post_item_sess_data.asp?qname=' + s ;
        
        sessionObj.onCompletion = function(){ 
        ////close registration table and open download table
        var status=sessionObj.response;
//alert(status);
//alert(status);
        if(status=='Success')
        {

       
        }
        else if(status=='Failed')
        {

        alert('Registration failed, Please try again');
        }
        else if(status=='LoginExist')
        {
        alert('Login Id exists');
        }
        else if(status=='EmailExist')
        {
        alert('Email Id already exists');
        }
        else
        {
        alert('Some error has occured with server,Please try again');
        } 
        


        }; 

        sessionObj.runAJAX(); 


 
}



/**********************************/

function post_order_data(s)
{  


  var sessionObj = new sack();
//alert('/asp/post_item_sess_data.asp?qname=' + s) ;
        sessionObj.requestFile ='/asp/post_order_data.asp?qname=' + s ;

//alert('/asp/post_order_data.asp?qname=' + s )        ;
        sessionObj.onCompletion = function(){ 
        ////close registration table and open download table
        var status=sessionObj.response;
	  //alert(status);
        if(status=='Success')
        {
		 alert('Order received successfully. We will shortly call you to confirm your order.')     ;
        }
        else if(status=='Failed')
        {

        alert('Registration failed, Please try again');
        }
        else if(status=='LoginExist')
        {
        alert('Login Id exists');
        }
        else if(status=='EmailExist')
        {
        alert('Email Id already exists');
        }
        else
        {
        alert('Some error has occured with server,Please try again');
        } 
        


        }; 

        sessionObj.runAJAX(); 


 
}

function post_review_data(p_id, n,t,r,e,c)
{  


  var sessionObj = new sack();
//alert('/asp/post_review_data.asp?i='+p_id+'&n='+n+'&t='+t+'&r='+r+'&e='+e+'&c='+c+'');

        sessionObj.requestFile ='/asp/post_review_data.asp?i='+p_id+'&n='+n+'&t='+t+'&r='+r+'&e='+e+'&c='+c+'';

//alert('/asp/post_order_data.asp?qname=' + s )        ;
        sessionObj.onCompletion = function(){ 
        ////close registration table and open download table
        var status=sessionObj.response;
	  //alert(status);
        if(status=='Success')
        {
		 alert('Comment sent successfully for approval.')     ;
        }
        
         else
        {
        alert('Some error has occured with server,Please try again');
        } 
        


        }; 

        sessionObj.runAJAX(); 


 
}


function get_item_id(folder_name)
{

for (var i_item_cnt=0 ;(i_item_cnt <GLB_product_item_length); i_item_cnt++)			
	{
	    if (product_item[i_item_cnt][10] == (folder_name + ".asp") )
	    {
	    	return i_item_cnt;
	    	i_item_cnt=GLB_product_item_length;
	    }	
	 }   
}


function add_item(k,prod_name, l,price,prod_price,prod_page_link)
//add_item(11,'prod name',1.99,
{

var WT_POSITIVE_NUMBER = /^[0-9]+\.*[0-9]*$/;
if (prod_page_link == undefined)
prod_page_link="#";
if (/^[0-9]+\.*[0-9]*$/.test(l.toString())  && l > 0){
add_item_to_cart(k,prod_name, l,price,prod_price,prod_page_link)

get_cart(l,prod_name,price,prod_price,prod_page_link);

}
else
{
alert('Please enter valid quantity');
}
}


function add_item_to_cart(k,prod_name, l,price,prod_price,prod_page_link)

{
//alert(prod_page_link);
var exists_flag=0,exists_i=0;
//for (i=0; i <tot_cart_items; i++)


alert('This item will now be added to your shopping cart');
for (i=0; i <tot_cart_items; i++)
{
//alert(my_shopping_cart[i][6]);
if (my_shopping_cart[i][4]==prod_name) //check if item exists
{

    exists_flag=1;
    exists_i=i;
}
}

if (exists_flag==1) 
{

        my_shopping_cart[exists_i][1]=(parseInt(my_shopping_cart[exists_i][1]) +parseInt(l) ).toString();
        if ((parseFloat(my_shopping_cart[exists_i][3]) > parseFloat(price)) && price != -1)
        {
	        my_shopping_cart[exists_i][3]=price;
        	
	        my_shopping_cart[exists_i][4]=prod_name;
	        my_shopping_cart[exists_i][5]=prod_price;
		   my_shopping_cart[exists_i][6]=prod_page_link;

	        
        }

}

else
{
        my_shopping_cart[tot_cart_items][0]=k; //item
        my_shopping_cart[tot_cart_items][1]=l;//qty

        my_shopping_cart[tot_cart_items][2]="1";
        my_shopping_cart[tot_cart_items][3]=price;
        my_shopping_cart[tot_cart_items][4]=prod_name;        
        my_shopping_cart[tot_cart_items][5]=prod_price;
		   my_shopping_cart[tot_cart_items][6]=prod_page_link;
       
        //alert('helo?');
// alert(my_shopping_cart[tot_cart_items][4]);
        tot_cart_items=tot_cart_items+1;
}
//alert(my_shopping_cart[exists_i][6])



}


function decrease_item_from_cart(k,prod_name, l,price,prod_price)

{

var exists_flag=0,exists_i=0;
alert('This item will now be updated to your shopping cart');
for (i=0; i <tot_cart_items; i++)
{
if (my_shopping_cart[i][4]==prod_name) //check if item exists
{

 
    exists_flag=1;
    exists_i=i;
 
}


if (exists_flag == 1) 
{

	if ( my_shopping_cart[exists_i][1] ==1) 
	{
 
	remove_item_from_view_cart(i);
	break;
	}

 
        my_shopping_cart[exists_i][1]=(parseInt(my_shopping_cart[exists_i][1]) - parseInt(l) ).toString();

        if ((parseFloat(my_shopping_cart[exists_i][3]) > parseFloat(price)) && price != -1)
        {
	        my_shopping_cart[exists_i][3]=price;
        	
	        my_shopping_cart[exists_i][4]=prod_name;
	        my_shopping_cart[exists_i][5]=prod_price;
 my_shopping_cart[exists_i][6]=prod_page_link;

	        
        }
break;


}

 
}//for

}//function


/***************************/
function add_view_cart_item(k,prod_name, l,price,prod_price)
//add_item(11,'prod name',1.99,
{
var WT_POSITIVE_NUMBER = /^[0-9]+\.*[0-9]*$/;
//alert(l);
if (/^[0-9]+\.*[0-9]*$/.test(l.toString())  && l > 0){
add_item_to_cart(k,prod_name, l,price,prod_price)

get_view_cart(l,prod_name,price,prod_price);

}
else
{
alert('Please enter valid quantity');
}
}


function decrease_from_view_cart_item(k,prod_name, l,price,prod_price)
//add_item(11,'prod name',1.99,
{
var WT_POSITIVE_NUMBER = /^[0-9]+\.*[0-9]*$/;
//alert(l);
if (/^[0-9]+\.*[0-9]*$/.test(l.toString())  && l > 0){

	decrease_item_from_cart(k,prod_name, l,price,prod_price)

get_view_cart(l,prod_name,price,prod_price);

}
else
{
alert('Please enter valid quantity');
}
}


/**********************************/

function remove_item(k)
{


//alert(k + '-' + tot_cart_items);
if (k<(tot_cart_items-1))
for(i=k;i<tot_cart_items-1;++i)
{

//alert(i + '-' +my_shopping_cart[i][0] + '=' + my_shopping_cart[i+1][0])
	my_shopping_cart[i][0]=my_shopping_cart[i+1][0];
	my_shopping_cart[i][1]=my_shopping_cart[i+1][1];
	my_shopping_cart[i][2]=my_shopping_cart[i+1][2];
my_shopping_cart[i][3]=my_shopping_cart[i+1][3];
my_shopping_cart[i][4]=my_shopping_cart[i+1][4];

my_shopping_cart[i][5]=my_shopping_cart[i+1][5];
 my_shopping_cart[i][6]=my_shopping_cart[i+1][6];
 



}
tot_cart_items=tot_cart_items-1;
get_cart(-1,-1);
}

function remove_item_from_view_cart(k)
{
if (k<(tot_cart_items-1))
for(i=k;i<tot_cart_items-1;++i)
{
my_shopping_cart[i][0]=my_shopping_cart[i+1][0];
my_shopping_cart[i][1]=my_shopping_cart[i+1][1];
my_shopping_cart[i][2]=my_shopping_cart[i+1][2];
my_shopping_cart[i][3]=my_shopping_cart[i+1][3];
my_shopping_cart[i][4]=my_shopping_cart[i+1][4];

my_shopping_cart[i][5]=my_shopping_cart[i+1][5];
my_shopping_cart[i][6]=my_shopping_cart[i+1][6];

//


}
tot_cart_items=tot_cart_items-1;
get_view_cart();

}
/*
for(i=k;i<tot_cart_items-1;i++)
{
	//alert(i + '-' + my_shopping_cart[i][1] + '=' + my_shopping_cart[i+1][1]);
	 
}

	if (k<(tot_cart_items-1))
for(i=k;i<tot_cart_items-1;i++)
{
	my_shopping_cart[i][0]=my_shopping_cart[i+1][0];
	my_shopping_cart[i][1]=my_shopping_cart[i+1][1];
	my_shopping_cart[i][2]=my_shopping_cart[i+1][2];
}
	tot_cart_items=tot_cart_items-1;
	get_view_cart();
}
*/
function get_view_cart()
{

var str,i;
var k9;
var amt=0;
var pr_price;

//alert(global_sess);
//str="<table>";
//str="";
str=" <table width='100%' border='0' align='center' cellpadding='2' cellspacing='2' valign='top'>";

if (tot_cart_items<=0 )
	str=str +  "<tr><td colspan=4>Your shopping cart is empty</td></tr>"  ;
else
{
for (i=0; i <tot_cart_items; i++)
	if (my_shopping_cart[i][2]=="1")
	{
	k9=parseInt(my_shopping_cart[i][0]);

	if (i%2 != 0)
	{
		str=str + "<tr bgcolor='#F0FCA3'>";
	}
	else
	{
		str=str + "<tr>";
	}




pr_price=LoadSubprograms(my_shopping_cart[i][0],my_shopping_cart[i][1],my_shopping_cart[i][4])

//alert(paypal_currency);
if (pr_price == 0) 
{
pr_price=my_shopping_cart[i][5] ;
}
	 
//alert(my_shopping_cart[i][6].replace(/\$/g,'/'));

	str=str +  "<td width='40%' class='black' valign='center' height='30' align='center'><a href='"+my_shopping_cart[i][6].replace(/\|/g,'/')+"'>" +my_shopping_cart[i][4]+ "</a></td>";
	
	if (my_shopping_cart[i][3] != -1)
{
		str=str +  "<td width='16%' class='black' align='center'>" + currency_name + ' '+ pr_price + " </td>" ;

}
else
{
str=str +  "<td width='16%' class='black' align='center'>" + currency_name + ' ' + pr_price + " </td>" ;

}
//alert(my_shopping_cart[i][4]);
	str=str +  "<td width='17%' class='black' align='center'>"

	str=str +  "<img src='/images/e_minus.gif'   style='cursor: pointer;'" ;
	str=str +  " onclick=" + '"' + "javascript:"; 

	str=str +  " decrease_from_view_cart_item(" + my_shopping_cart[i][0]+",'"+my_shopping_cart[i][4]+"',1,-1,10)" + '"' + ">"
	str=str +  " &nbsp;" + my_shopping_cart[i][1] +"&nbsp; "

	str=str +  " <img src='/images/e_plus.gif'   style='cursor: pointer;'" ;
	str=str +  " onclick=" + '"' + "javascript:"; 

	str=str +  " add_view_cart_item(" + my_shopping_cart[i][0]+",'"+my_shopping_cart[i][4]+"',1,-1,10)" + '"' + ">" 

//alert(str);
//;add_view_cart_item("+my_shopping_cart[i][0]+",'"+my_shopping_cart[i][4]+"',1,-1,10)
//	str=str +  "<td width='17%' class='black' align='center'><input size=6 maxlength=6 type=text name='txtQ'" + my_shopping_cart[i][0] + "' value='"+ my_shopping_cart[i][1] +"'></td>" 

	str=str +  "<td   class='black' align='center' > <a style='cursor: pointer;cursor:hand' class='red12bold' onclick='remove_item_from_view_cart(" + (i).toString() + ");'>X</a></td>" ;
	str=str + "</tr>"

	//amt=amt+parseFloat(product_item[k9][4]) * parseFloat(my_shopping_cart[i][1]) ;
	if (my_shopping_cart[i][3] != -1)
	{
//	amt=amt+parseFloat(my_shopping_cart[i][5]) * parseFloat(my_shopping_cart[i][1]) ;

amt=amt+parseFloat(pr_price) *parseFloat(my_shopping_cart[i][1]);

}
else
{

//alert(amt);
//amt=amt+parseFloat(my_shopping_cart[i][5]) * parseFloat(my_shopping_cart[i][1]) ;
//alert(get_item_data_price(my_shopping_cart[i][0],my_shopping_cart[i][1]));
amt= amt+ parseFloat(pr_price) *parseFloat(my_shopping_cart[i][1]);
//alert(my_shopping_cart[i][0] + ' ' + my_shopping_cart[i][1] + ' ' + my_shopping_cart[i][1]);

}


	}


}

str=str + "</table>";

document.getElementById("cart").innerHTML=str;

document.getElementById("divCartTotal").innerHTML='';

document.getElementById("divCartTotal").innerHTML=Math.round(amt*100)/100;

//document.getElementById("div1").innerHTML='';
//document.getElementById("divFinalCheckoutTotal").innerHTML=+ roundNumber(Math.round(amt*100)/100 + Math.round(document.frmCheckOut.selShippingMethod.value*100)/100);
//document.getElementById("divFinalCheckoutTotal").innerHTML=roundNumber(parseFloat(document.getElementById("divFinalCheckoutTotal").innerHTML)-parseFloat(document.getElementById("divDiscount").innerHTML));
//document.getElementById("div1").innerHTML=Math.round(amt*100)/100;
//parseFloat(document.frmCheckOut.selShippingMethod.value);


build_global_var_from_array();
UpdatePromoOffer();


 
if ((document.getElementById("mnuCountry").selectedIndex!="0" ) || (document.getElementById("mnuShippingMethod").selectedIndex!="0" ))
{
/* if (document.getElementById("mnuCountry").selectedIndex=="0" )
	alert('Please select shipping country');
if (document.getElementById("mnuShippingMethod").selectedIndex=="0" )
	alert('Please select shipping method');	*/
}
else
{
 
GetShippingPrices();
}

if ((document.getElementById("mnuCountry").selectedIndex!="0" ) && (document.getElementById("mnuShippingMethod").selectedIndex!="0" ))
{
GetShippingPrices();
}
}



function build_paypal_var()
{


 var k9,amt=0;
 var strPaypal;
 strPaypal='';
var pr_price;

// strPaypal='<form name="frmCheckOut" action="https://www.paypal.com/uk/cgi-bin/webscr?__track=_ext-enter:p/xcl/pay/buy-index-blank_reg:_xclick-user-submit" method="post" >'

 strPaypal=strPaypal + '<input type="hidden" name="business" value="sales@123discountshop.com">';
 strPaypal=strPaypal + '<input type="hidden" name="cmd" value="_cart">';
 strPaypal=strPaypal + '<input type="hidden" name="upload" value="1">';
 strPaypal=strPaypal + '<input type="hidden" name="rm" value="2">';
 strPaypal=strPaypal + '<input type="hidden" name="discount_amount_cart" value="'+roundNumber(document.getElementById("divDiscount").innerHTML )+'">';

var iCurrency1
/*
if (currency_name =="$") 
iCurrency1="USD";
else if (currency_name=="EUR" )
iCurrency1="EUR";
else if (currency_name =="Rs")
iCurrency1="INR";
else if (currency_name =="£")
iCurrency1="GBP";

*/
 strPaypal=strPaypal + '<input type="hidden" name="currency_code" value="'+paypal_currency+'">';

//alert('name-' +paypal_currency);
 

var replaceProdId=new Array(31)
for (iProd=0; iProd <31; iProd++)
replaceProdId[iProd]=new Array(2)

 replaceProdId[0][0]=128;
 replaceProdId[1][0]=129;
 replaceProdId[2][0]=130;
 replaceProdId[3][0]=131;
 replaceProdId[4][0]=132;
 replaceProdId[5][0]=133;
 replaceProdId[6][0]=135;
 replaceProdId[7][0]=136;
 replaceProdId[8][0]=137;
 replaceProdId[9][0]=138;
 replaceProdId[10][0]=139;
 replaceProdId[11][0]=140;
 replaceProdId[12][0]=8110;
 replaceProdId[13][0]=8137;
 replaceProdId[14][0]=8201;
 replaceProdId[15][0]=8202;
 replaceProdId[16][0]=8511;
 replaceProdId[17][0]=8518;
 replaceProdId[18][0]=8519;
 replaceProdId[19][0]=8523;
 replaceProdId[20][0]=8524;
 replaceProdId[21][0]=8525;
 replaceProdId[22][0]=8526;
 replaceProdId[23][0]=8530;
 replaceProdId[24][0]=8129;
 replaceProdId[25][0]=8063;
 replaceProdId[26][0]=8109;
 replaceProdId[27][0]=8106;
 replaceProdId[28][0]=8113;
 replaceProdId[29][0]=8131;
 replaceProdId[30][0]=8140;
 replaceProdId[0][1]=8557;
 replaceProdId[1][1]=8541;
 replaceProdId[2][1]=8547;
 replaceProdId[3][1]=8553;
 replaceProdId[4][1]=8551;
 replaceProdId[5][1]=8558;
 replaceProdId[6][1]=8550;
 replaceProdId[7][1]=8537;
 replaceProdId[8][1]=8545;
 replaceProdId[9][1]=8554;
 replaceProdId[10][1]=8559;
 replaceProdId[11][1]=8548;
 replaceProdId[12][1]=8549;
 replaceProdId[13][1]=8555;
 replaceProdId[14][1]=8538;
 replaceProdId[15][1]=8536;
 replaceProdId[16][1]=8544;
 replaceProdId[17][1]=8539;
 replaceProdId[18][1]=8542;
 replaceProdId[19][1]=8565;
 replaceProdId[20][1]=8540;
 replaceProdId[21][1]=8552;
 replaceProdId[22][1]=8566;
 replaceProdId[23][1]=8567;
 replaceProdId[24][1]=8543;
 replaceProdId[25][1]=8546;
 replaceProdId[26][1]=8556;
 replaceProdId[27][1]=8561;
 replaceProdId[28][1]=8562;
 replaceProdId[29][1]=8563;
 replaceProdId[30][1]=8564;

var mappedProductId

 if (tot_cart_items> 0 )
 {
 for (i=0; i <tot_cart_items; i++)
 	if (my_shopping_cart[i][2]=="1")//qty > 0
 	{
 	k9=parseInt(my_shopping_cart[i][0]);

 	//Assign here
//alert('"item_number_' + my_shopping_cart[i][0].toString() +'"');
 	strPaypal=strPaypal + '<input type="hidden" name="item_name_' + (parseInt(i) +1).toString() +'" value="'+ my_shopping_cart[i][4] +'-(123DS)">';

for (iMapp=0; iMapp <31; iMapp++){
//alert(parseInt(replaceProdId[iMapp][0]) + "==" + parseInt(my_shopping_cart[i][0]));
if (parseInt(replaceProdId[iMapp][0])==parseInt(my_shopping_cart[i][0]))
{	mappedProductId=replaceProdId[iMapp][1];
break;
}
else
{	mappedProductId=my_shopping_cart[i][0];}
}

//alert(mappedProductId)
	//strPaypal=strPaypal + '<input type="hidden" name="item_number_' + (parseInt(i) +1).toString() +'" value="'+my_shopping_cart[i][0].toString()+'">';

strPaypal=strPaypal + '<input type="hidden" name="item_number_' + (parseInt(i) +1).toString() +'" value="'+mappedProductId.toString()+'">';

	//strPaypal=strPaypal + '<input type="hidden" name="item_number_' + (parseInt(i) +1).toString() +'" value="50'+(parseInt(i) +1).toString()+'">';

//	strPaypal=strPaypal + '<input type="hidden" name="amount_' + (parseInt(i) +1).toString() +'" value="'+ product_item[k9][4] +'">';
 	strPaypal=strPaypal + '<input type="hidden" name="quantity_' + (parseInt(i) +1).toString() +'" value="'+my_shopping_cart[i][1]+'">';
pr_price=LoadSubprograms(my_shopping_cart[i][0],my_shopping_cart[i][1],my_shopping_cart[i][4])
//strPaypal=strPaypal + '<input type="hidden" name="amount_' + (parseInt(i) +1).toString() +'" value="'+ my_shopping_cart[i][5] +'">';

strPaypal=strPaypal + '<input type="hidden" name="amount_' + (parseInt(i) +1).toString() +'" value="'+ pr_price +'">';

if (1==2)
{
if (my_shopping_cart[i][0].toString() == '55')

{
	strPaypal=strPaypal + '<input type="hidden" name="tax_' + (parseInt(i) +1).toString() +'" value="0">';
	strPaypal=strPaypal + '<input type="hidden" name="amount_' + (parseInt(i) +1).toString() +'" value="'+ my_shopping_cart[i][5] +'">';

}
else
{

VAT= parseFloat(my_shopping_cart[i][5])* parseFloat(0.15);
VAT2=Math.round(VAT*100)/100;
price=parseFloat(my_shopping_cart[i][5])-parseFloat(VAT2);

	strPaypal=strPaypal + '<input type="hidden" name="tax_' + (parseInt(i) +1).toString() +'" value="'+VAT2+'">';
	strPaypal=strPaypal + '<input type="hidden" name="amount_' + (parseInt(i) +1).toString() +'" value="'+ price +'">';

}
}

 	}

 	//strPaypal=strPaypal + '<input type="hidden" name="shipping_1" value="2.00">';

 	strPaypal=strPaypal + '<input type="hidden" name="shipping_1" value="'+ fShippingCost +'">';
 //document.frmCheckOut.selShippingMethod.options[document.frmCheckOut.selShippingMethod.selectedIndex ].value
	//strPaypal=strPaypal + '<input type="hidden" name="return" value="http://www.123discountshop.com/asp/prod_payment_thank_you.asp">';
	//strPaypal=strPaypal + '<input type="hidden" name="cancel_return" value="http://www.theory-test.co.uk/asp/payment_cancel.asp">' ;

strPaypal=strPaypal + '<input type="hidden" name="custom" value="REF-123DSWeb">';

	//strPaypal=strPaypal + '<input type="hidden" name="currency_code" value="GBP">';
	
	strPaypal=strPaypal + '<input type="hidden" name="cancel_return" value="http://www.123discountshop.com/asp/payment_cancel.asp">';


	//strPaypal=strPaypal + '</form>';

//alert(strPaypal);
	document.getElementById("divForm").innerHTML=strPaypal;
	//alert(document.frmCheckOut.selShippingMethod.value);

//alert('XYX' + document.getElementById("divForm").innerHTML)

 
//alert(currency_name);
if (currency_name== 'INR')
{
alert('Payment can be made using online bank transfer, DD, cheque etc.\nCall us for further details on 09820 5181 49 @ Oasis-BS Pvt Ltd,Mumbai to confirm your order\nThank you for your order.');
//window.location='/Laptop-accessories/xxall_products_search.asp?wholesale=Y&iCurrency=INR';
}
else
{
if (document.getElementById("mnuCountry").selectedIndex!="0" && document.getElementById("mnuShippingMethod").selectedIndex !="0")
{
post_shopping_cart();
strPaypal=strPaypal + '<input type="hidden" name="return" value="http://www.123discountshop.co.uk/asp/prod_payment_thank_you.asp?utm_nooverride=1&i='+shopping_cart_status+'">';
//alert(strPaypal);
	document.frmCheckOut.submit();
}
else
{
if (document.getElementById("mnuCountry").selectedIndex=="0" ) 
	alert('Please select shipping country');
if (document.getElementById("mnuShippingMethod").selectedIndex=="0" )
 	alert('Please select shipping method');
}
}
 }
 else
 {
 	alert('Your shopping cart is empty');
 }


}

function post_shopping_cart()
{

var objHTTP =null;

// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  objHTTP=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  objHTTP=new ActiveXObject("Microsoft.XMLHTTP")
  }

   
  
  var getData= '/asp/post_shopping_cart_data.asp?c='+global_sess+''

  objHTTP.open("POST",getData,false);
 
		try
		{
		objHTTP.send(null);
		}
		catch(e)
		{
		//alert(e.toString());
		return false;
		}
		
// alert(objHTTP.responseText );
shopping_cart_status=objHTTP.responseText ;
 

/*  var sessionObj = new sack();

var status;
        sessionObj.requestFile ='/asp/post_shopping_cart_data.asp?c='+global_sess+'';

        sessionObj.onCompletion = function(){ 
        status=sessionObj.response;

       shopping_cart_status= status;



        }; 

        sessionObj.runAJAX();

*/

}

function onChangeUpdateCartTotal(selectObj)
{
	//alert('here');
//alert(roundNumber(parseFloat(document.frmCheckOut.selShippingMethod.value)));
//	document.getElementById("divFinalCheckoutTotal").innerHTML= roundNumber(roundNumber(parseFloat(document.getElementById("divCartTotal").innerHTML));  + roundNumber(parseFloat(document.frmCheckOut.selShippingMethod.value)));
}

function add_item_and_checkout(k,l,price)
{ 

var exists_flag=0,exists_i=0;
alert('This item will now be added to your shopping cart');
for (i=0; i <tot_cart_items; i++)
if (my_shopping_cart[i][0]==k) //check if item exists
{
exists_flag=1;
exists_i=i;
}

if (exists_flag==1) 
{
my_shopping_cart[exists_i][1]=(parseInt(my_shopping_cart[exists_i][1]) +parseInt(l) ).toString();


if ((parseFloat(my_shopping_cart[exists_i][3]) > parseFloat(price)) && price != -1)
{

	my_shopping_cart[exists_i][3]=price;
}

}

else
{
my_shopping_cart[tot_cart_items][0]=k; //item
my_shopping_cart[tot_cart_items][1]=l;//qty

my_shopping_cart[tot_cart_items][2]="1";
my_shopping_cart[tot_cart_items][3]=price;
tot_cart_items=tot_cart_items+1;
}

//var str,i;
var k9,amt=0;

str="<table>";
if (tot_cart_items<=0 )
str=str +  "<tr><td colspan=4>Cart is empty</td></tr>"  ;
else
{
for (i=0; i <tot_cart_items; i++)
if (my_shopping_cart[i][2]=="1")
{
k9=parseInt(my_shopping_cart[i][0]);//item
//alert(k9);
if  (my_shopping_cart[i][3] == -1)
{
str=str +  "<tr><td valign=top>" + my_shopping_cart[i][1]   + " x </td><td width='130'>" +   product_item[k9][1] + " " +product_item[k9][4] + "</td><td> <a style='cursor: hand;cursor:pointer' class='red12bold' onclick='remove_item(" + i.toString() + ");'>X</a></td></tr>"  ;
amt=amt+parseFloat(product_item[k9][4]) *parseFloat(my_shopping_cart[i][1]) ;
}
else
{
str=str +  "<tr><td valign=top>" + my_shopping_cart[i][1]   + " x </td><td width='130'>" +   product_item[k9][1] + " " +parseFloat(my_shopping_cart[i][3]) + "</td><td> <a style='cursor: hand;cursor:pointer' class='red12bold' onclick='remove_item(" + i.toString() + ");'>X</a></td></tr>"  ;
amt=amt+parseFloat(my_shopping_cart[i][3]) *parseFloat(my_shopping_cart[i][1]) ;
}

}

//str=str +  "<tr><td colspan=4>____________________________</td></tr>"  ;
//str=str +  "<tr><td colspan=4> tot_cart_itemsal Invoice value : " + roundNumber(amt).toString() + "</td></tr>"  ;
}

str=str + "</table>";
//document.getElementById("cart").innerHTML=str;
//document.getElementById("product_value").innerHTML=''+(Math.round(amt*100)/100).toString();
	if (tot_cart_items==0) 
		global_sess="";
	else
	for (i=0; i <tot_cart_items; i++)
	if (i==0)
		global_sess=my_shopping_cart[i][0] + "*" + my_shopping_cart[i][1] + "*" + my_shopping_cart[i][2] + "*" + my_shopping_cart[i][3] + "*" + my_shopping_cart[i][4] ;
	else
		global_sess=global_sess + "/" + my_shopping_cart[i][0] + "*" + my_shopping_cart[i][1] + "*" + my_shopping_cart[i][2] +"*" + my_shopping_cart[i][3] + "*" + my_shopping_cart[i][4] ;
//add_item("+i_item_cnt+",document.getElementById('txtQ" + product_item[i_item_cnt][0]+"').value,-1);
}

function takeToAmazon(cartContents)
{

var objHTTP =null;

// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  objHTTP=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  objHTTP=new ActiveXObject("Microsoft.XMLHTTP")
  }

   
  
  var getData= "asp/create_amazon_cart.aspx?cart="+cartContents ; 

  objHTTP.open("POST",getData,false);
 
		try
		{
		objHTTP.send(null);
		}
		catch(e)
		{
		//alert(e.toString());
		return false;
		}
		
 alert(objHTTP.responseText );
 
}
build_array_from_global_var();




function validateChars(str)
{
//alert(str);
var iChars = "!#$%^&*()+=[]\\\';/{}|\":<>?";	
  for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {
  	  	return false;
  	}
  	
  }
  return true;
}


/*alert(validateChars(document.getElementById('txtQty').value )&&validateChars(document.getElementById('txtQuery').value )&&validateChars(document.getElementById('txtmobile').value )&&validateChars(document.getElementById('txtmodel').value && validateChars(document.getElementById('txtName').value ) && validateChars(document.getElementById('txtAddress').value )));
if (validateChars(document.getElementById('txtmobile').value )&&validateChars(document.getElementById('txtmodel').value && validateChars(document.getElementById('txtName').value ) && validateChars(document.getElementById('txtAddress').value )))
{
post_order_data(document.getElementById('txtmobile').value + '$$$' + document.getElementById('txtmodel').value + '$$$' + document.getElementById('txtName').value + '$$$' + document.getElementById('txtAddress').value ) ;
}
else {
alert('Please enter valid data');
}"*/

function valInquiry(me)
{

if(me.txtName.value=="" || validateChars(me.txtName.value )==false )
		{
		alert("Please enter valid name.");
		//me.user_name.value=""
		me.txtName.focus();
		return false;
		}

 if (me.txtmobile.value == "" || isInteger(me.txtmobile.value)==false)
                    {
                        alert("Please enter valid contact no.");
                        me.txtmobile.focus();
                        return false;          
                     }

if(me.txtQty.value=="" )
		{
		alert("Please enter quantity");
		
                        me.txtQty.focus();
		return false;

		}


            if (isInteger(me.txtQty.value)==false)
                    {
                        alert("Please enter valid quantity");
                        me.txtQty.focus();
                        return false;          
                     }

	

		 if(me.txtAddress.value=="" || validateChars(me.txtAddress.value )==false )
		{
		alert("Please enter valid address.");
		//me.user_name.value=""
		me.txtAddress.focus();
		return false;
		}

if(me.txtmodel.value=="" || validateChars(me.txtmodel.value )==false )
		{
		alert("Please enter laptop model name.");
		//me.user_name.value=""
		me.txtmodel.focus();
		return false;
		}




           
		

return true;

}



function valGeneralInquiry(me)
{

if(me.txtName.value=="" || validateChars(me.txtName.value )==false )
		{
		alert("Please enter valid name.");
		//me.user_name.value=""
		me.txtName.focus();
		return false;
		}

 if (me.txtmobile.value == "" || isInteger(me.txtmobile.value)==false)
                    {
                        alert("Please enter valid contact no.");
                        me.txtmobile.focus();
                        return false;          
                     }

if(me.txtQty.value=="" )
		{
		alert("Please enter quantity");
		
                        me.txtQty.focus();
		return false;

		}


            if (isInteger(me.txtQty.value)==false)
                    {
                        alert("Please enter valid quantity");
                        me.txtQty.focus();
                        return false;          
                     }

	

		 if(me.txtAddress.value=="" || validateChars(me.txtAddress.value )==false )
		{
		alert("Please enter valid address.");
		//me.user_name.value=""
		me.txtAddress.focus();
		return false;
		}

           if (isInteger(me.txtPincode.value)==false)
                    {
                        alert("Please enter valid pin code");
                        me.txtPincode.focus();
                        return false;          
                     }

 

if (me.txtEmailId1.value!="")
{
 if (val_email(me.txtEmailId1.value)==false)
		{
		val_email(me.txtEmailId1.value);
		alert("Please enter valid email Id.");
		me.txtEmailId1.focus();
		return false;
		}
 } 
return true;

}


function valSubmitReview(me)
{

me=document.getElementById('frmCheckOut');

if(me.txtRName.value=="" || validateChars(me.txtRName.value )==false )
		{
			alert("Please enter valid name.");
			me.txtRName.focus();
			return false;
		}

 if (val_email(me.txtEmailId.value)==false)
		{
		val_email(me.txtEmailId.value);
		alert("Please enter valid email Id.");
		me.txtEmailId.focus();
		return false;
		}

 
 if(me.txtReviewTitle.value=="" || validateChars(me.txtReviewTitle.value )==false )
		{
			alert("Please enter valid title.");
			me.txtReviewTitle.focus();
			return false;
		}

	
//alert(me.txtComment.value );
		if(me.txtComment.value=="" || validateChars(me.txtComment.value )==false )
		{
			alert("Please enter valid comment.");
			me.txtComment.focus();
			return false;
		}
return true;

}


/************************************/
function  GetINRShippingPrices(){

build_array_from_global_var();

fShippingCost=0;

document.getElementById("divShippingTotal").innerHTML = fShippingCost;

document.getElementById("divAllCartTotal").innerHTML = roundNumber(parseFloat(fShippingCost) + roundNumber(parseFloat(document.getElementById("divCartTotal").innerHTML)));




} 



/*************************************/


function  GetShippingPrices(){
var select_list_selected_index = document.getElementById("mnuCountry").selectedIndex;

var dispatchToCountry= document.getElementById("mnuCountry").options[select_list_selected_index].text;

var select_list_selected_index_method = document.getElementById("mnuShippingMethod").selectedIndex;

var shippingMethod= document.getElementById("mnuShippingMethod").options[select_list_selected_index_method].text;


build_array_from_global_var();
var sShippingText,i
sShippingText=LoadShippingPrices(dispatchToCountry,shippingMethod,paypal_currency).split("|");
//alert(sShippingText);

//for (i=0; i <sShippingText.length; i++)
//my_shopping_cart[i]=sShippingText[i];

//if (sShippingText[1]==0)
document.getElementById("divShippingText").innerHTML=  '<br>Shipping price from Jersey, UK for Shipping items with total weight: '+ sShippingText[1] + 'kg <br>Shipping price direct from Overseas, Factory for Shipping items with total weight: ' + sShippingText[4] + 'kg' + ' <br> Delivery Time : <b>' + sShippingText[6] + '</b>';
fShippingCost=parseFloat(sShippingText[2])+ parseFloat(sShippingText[5]);
fShippingCost=Math.round(fShippingCost*100)/100;

document.getElementById("divShippingTotal").innerHTML = fShippingCost;

document.getElementById("divAllCartTotal").innerHTML = roundNumber(parseFloat(fShippingCost) + roundNumber(parseFloat(document.getElementById("divCartTotal").innerHTML)));




} 

function callPage(){

var selPriceType;
var select_list_selected_index = document.getElementById("mnuPriceType").selectedIndex;
selPriceType=document.getElementById("mnuPriceType").options[select_list_selected_index].value
//alert('Welcome');
  	httpObject = getHTTPObject();
//alert('Welcome2');


      if (httpObject != null) {

      httpObject.open('GET', '/asp/setvalues.asp?qname=' + selPriceType + '', false);
      httpObject.send(null);    

		 

	retValue= httpObject.responseText
//alert(retValue)     ;

	return retValue;
}

      }  



function assignPost()
{
var select_list_selected_index = document.getElementById("mnuCategory").selectedIndex;
selCatg=document.getElementById("mnuCategory").options[select_list_selected_index].value

document.getElementById("frmProduct").action="/Laptop-accessories/all_products_search.asp" + "?cat="+selCatg+"&term="+document.getElementById("txtSearchTerm").value.replace(/ /g,'+')+"";

}


function roll_over(img_name, img_src)
   {
   document[img_name].src = img_src;

   }

function assignImages(i)
{
selRating=i;
var j, img_name;

for (j=1;j<=5;++j)
{
	img_name='review_'+j;
	document.getElementById(img_name).src = '/images/review3.gif';
}

for (j=1;j<=i;++j)
{
	img_name='review_'+j;
	document.getElementById(img_name).src = '/images/review2.gif';
}

}

function valUKInquiry(me)
{

if(me.txtName.value=="" || validateChars(me.txtName.value )==false )
		{
		alert("Please enter valid email id.");
		//me.user_name.value=""
		me.txtName.focus();
		return false;
		}

 if (me.txtCCode.value != "" && isMobileInteger(me.txtCCode.value)==false)
                    {
                        alert("Please enter valid country code eg UK-44, USA-1");
                        me.txtCCode.focus();
                        return false;          
                     }


 if (me.txtmobile.value == "" || isMobileInteger(me.txtmobile.value)==false)
                    {
                        alert("Please enter valid contact no.");
                        me.txtmobile.focus();
                        return false;          
                     }

		if(me.txtQty.value=="" )
		{
		alert("Please enter quantity");
		
                        me.txtQty.focus();
		return false;

		}


            if (isInteger(me.txtQty.value)==false)
                    {
                        alert("Please enter valid quantity");
                        me.txtQty.focus();
                        return false;          
                     }

	

		 if(me.txtAddress.value=="" || validateCommentChars(me.txtAddress.value )==false)
		{
		alert("Please enter valid comment. space # & ' are not allowed");
		//me.user_name.value=""
		me.txtAddress.focus();
		return false;
		}

          
		

return true;

}



function isMobileInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (( (c < "0") || (c > "9") )) return false;
    }
    // All characters are numbers.
    return true;
}




function validateCommentChars(str)
{
//alert(str);
var iChars = "&#'";	
  for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {
  	  	return false;
  	}
  	
  }
  return true;
}


function CheckPromoOffer(val,isGo)
{
//alert(val);
if (document.getElementById("divCartTotal").innerHTML != '0')
{
	if(val=='')
	{
		alert('Please enter promotional code. If you dont have promo code, click on paypal button to proceed with the payment');
		document.getElementById("btnSubmitCode").disabled=false;
		document.getElementById("hdnCheckPromo").value="N";
		document.getElementById("promo_code").focus();
		return false;
	}


	if ((trim(val.toUpperCase())=='TT51109') ||(trim(val.toUpperCase())=='TT51209'))
	{
		//alert("Promo code accepted");
		document.getElementById("btnSubmitCode").disabled=true;
		document.getElementById("hdnCheckPromo").value="Y";
		UpdatePromoOffer(isGo);
		alert("Promo code is accepted, click on paypal button to proceed with the payment");

	}
	else
	{
		alert('Please enter valid promotional code');
		document.getElementById("promo_code").focus();
		return false;
	}
}
else
{
	alert("Your shopping cart is empty");
}

}

function UpdatePromoOffer(isGo) //if isGo button pressed
{
var updatePromoTotal;
updatePromoTotal=document.getElementById('divCartTotal').innerHTML;
//alert(isGo);
if (document.getElementById("hdnCheckPromo").value == "Y" && isGo=="N")
{
return false;
}
if (parseFloat(updatePromoTotal)< 6.99 ) //hard coded
{
alert('Promo code not accepted for products in the cart');
return false;
}
//alert(updatePromoTotal);
	if (document.getElementById("hdnCheckPromo").value == "Y")
	{
	
if (currency_name== 'USD')
{
	document.getElementById('divDiscount').innerHTML =  6.99 ;
		document.getElementById('tdTotalText').innerHTML = "<b><font color='red' size='2'>" +currency_name+ " 6.99  <br> </font></b>";


}
else
{
	document.getElementById('divDiscount').innerHTML =  4.99 ;
		document.getElementById('tdTotalText').innerHTML = "<b><font color='red' size='2'>" +currency_name+ " 4.99 <br> </font></b>";

}


		//updatePromoTotal=parseFloat(updatePromoTotal.toString().substring(updatePromoTotal.toString().indexOf(' '),updatePromoTotal.toString().length));
//alert(updatePromoTotal);
		document.getElementById('divCartTotal').innerHTML= roundNumber(roundNumber(parseFloat(document.getElementById('divCartTotal').innerHTML ))- roundNumber(parseFloat(document.getElementById('divDiscount').innerHTML)));

document.getElementById("divAllCartTotal").innerHTML = roundNumber(parseFloat(fShippingCost) + roundNumber(parseFloat(document.getElementById("divCartTotal").innerHTML)));


	}
	else
	{
	}
}


