// JavaScript Document
// Store Configuration variables



function GET_HTTP_QueryString(Query_String_Name) {
			 var i, pos, argname, argvalue, queryString, pairs;
			 // get the string following the question mark
			 queryString = location.href.substring(location.href.indexOf("?")+1);
			 // split parameters into pairs, assuming pairs are separated by ampersands
			 pairs = queryString.split("&");
			 // for each pair, we get the name and the value
					for (i = 0; i < pairs.length; i++) { 
				  pos = pairs[i].indexOf('='); 
				  if (pos == -1) {
				  continue; 
				  }
				  argname = pairs[i].substring(0,pos);
				  argvalue = pairs[i].substring(pos+1); 
				// Replaces "Google-style" + signs with the spaces they represent
					if (argname == Query_String_Name) {
					   return unescape(argvalue.replace(/\+/g, " "));
					}
				}
				return false;
			}
	 
 // Configure variable 	 
	 	if (GET_HTTP_QueryString('HTML')!=false)
		  {
		 	 strCurrency = '';
		 		
		  }

   
	// RVI
	function writeCookie(name, value, hours)
	{
		  var expire = "";
		  if(hours != null)
		  {
			expire = new Date((new Date()).getTime() + hours * 3600000);
			expire = "; expires=" + expire.toGMTString();
		  }
			 document.cookie = name + "=" + escape(value) + expire;
	}
 
  
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

//Add RVI  
  function RVI(id)
 	{	
		var strRVI;
		
		strRVI = readCookie("RVI");
	
	
		if ( strRVI == '')	
		 { 
		 	writeCookie("RVI",id,25);
		 }
		else if (  strRVI!=id ) 
		 {	
		 	  if ( strRVI.match(id+",") ==null  )  // if not exist 
				 {	
					if ( strRVI != '')
					 	{  id = id+","+strRVI; }
				  writeCookie("RVI",id,25);
				 } 	
		}
	//document.write( readCookie("RVI"));
	}
//Delete RVI  
  function RVI_Del(pid)
 	{	
		var strRVI,id;
		
		strRVI = readCookie("RVI");
		 
		  if ( strRVI.match(",") !=null  )
		 {		var RVI_array=strRVI.split(",");
				var i=0;
				strRVI='';
				
				
			  while( i < RVI_array.length)
			 {
					
					 id = RVI_array[i];
					if ( pid != id )  
					{
					  if ( strRVI == '')	
							strRVI = id;		
					 else
						   strRVI = strRVI+","+id;
					}
					else
					{
					//	document.write('<BR> pid :  '+id);
					}
				//	document.write('<BR>'+strRVI);
					 i+=1;
			  }
			 writeCookie("RVI",strRVI,25);
			// alert(RVI_array.length);
			window.location = location.href	;
				
			// document.forms[1].submit();
		}
	 
	}	
	
	// Delete All
	 function RVI_DelAll()
	{
		writeCookie("RVI","",25);
		window.location = location.href	;
		
	}	
	
	 	
	function ShowHideTag(id,style,value)
		{
			  
			  obj = document.getElementById(id);	
			 if ( value != 'Y' ) 
				 { 
				 	if ( obj!=null)
				 	 {	 
					 	if ( style=='innerHTML')
							{obj.innerHTML	='';}
						else
							{obj.style.display='none';}
									
					 }
					 else
					 { 
					   var	i =0; 
					 	obj = document.getElementById(id+i);			
					  	   if ( obj!=null )
						   		{
									 while ( obj!=null )
									 	{
												if ( style=='innerHTML')
													{obj.innerHTML	='';}
												else
													{obj.style.display='none';}
											i=i+1;
											obj = document.getElementById(id+i);	
											//alert(id+i);
										}
								}
						
					 } 
				 }
		}
	
	function configTemplate()
		{
		 
		  //1.showInventory
		   	ShowHideTag('showInventory','innerHTML',showInventory);
		//2.showAvailability
			ShowHideTag('showAvailability','innerHTML',showAvailability);
		//3.showGuest_Reviews
			ShowHideTag('showGuest_Reviews','display',showGuest_Reviews);	
	//4.showBest_Saller
			ShowHideTag('showBest_Saller','display',showBest_Saller);	
	//5.showTodays_Special
			ShowHideTag('showTodays_Special','display',showTodays_Special);	
	//6.showCross_Sales
			ShowHideTag('showCross_Sales','display',showCross_Sales);	
	//7.showPrice
			ShowHideTag('showPrice','innerHTML',showPrice);	
	//8.showRVI
			ShowHideTag('showRVI','display',showRVI);	
	//9.showProduct_Code
			ShowHideTag('showProduct_Code','innerHTML',showProduct_Code);
	}
 
// 07-April-06  
//Editor Ajay 
