// MakePayment Popup Close function 
zbankwin=null; 
function makepaypop()
	{
//alert("dsf");
if(zbankwin)  
			{
					zbankwin.close(); 
			}
			
}


function cookiesEnabled( ) {
    document.cookie = "testCookies=cookiesEnabled";
    var pos = document.cookie.indexOf( "testCookies=" );
    if( pos == -1 )
    {
		window.location="enableCookies.jsp";
    }
}
cookiesEnabled();

zbankwin=null; 
function makepaypop()
	{
if(zbankwin)  
			{
					zbankwin.close(); 
			}			
}


function validate()
{
	makepaypop();
	omniSet();
	var x = document.NavForm;
	var min_rs = x.min1.value.search("[^0-9]");
	var max_rs = x.max1.value.search("[^0-9]");
	var key_word = x.query_star.value.search("[^A-Za-z0-9+*-/&$#!@%^()= ]");
	var error="Sorry we were unable to complete this step because :\n";
	var flag=0;

	var user_keyword=x.query_star.value;
    var user_min=x.min1.value;
    var user_max=x.max1.value;

	if(x.category.selectedIndex==0 && x.query_star.value=="")
	{
	  error=error+"You have not specified a Keyword\n";
	  flag++;
	}
	 else
	{
	  x.query.value=x.query_star.value+"*";
	}

	if(x.query_star.value.length>0 && key_word >= 0)
		{
        error=error+"You have not specified a Keyword\n";
			flag++;
		}

if(x.max1.value=="0")
	{
     error=error+"The value of Max must be more than 0\n";
	 			flag++;
	}

	  if(x.min1.value.length>0 && min_rs >= 0)
		{
        error=error+"Enter only digits[0-9] in Min Rs\n";
        x.min1.value="";
			flag++;
		}
	  if(x.max1.value.length>0 && max_rs >= 0)
		{
        error=error+"Enter only digits[0-9] in Max Rs\n";
		x.max1.value="";
			flag++;
		}
   if(x.min1.value=="")
	{
	   x.min.value="0";
    }
    if(x.max1.value=="")
	{
	  x.max.value="0";
	}

    if((min_rs < 0) &&(max_rs < 0) && (x.min1.value!="")&& (x.max1.value!="") && (x.max1.value!="0") && (parseInt(x.min1.value) >parseInt(x.max1.value)))
	{
	  flag++;

	  error=error+"Please make sure that the Minimum Price is greater than the Maximum Price\n";
	}
	if(flag!=0)
		 {
			alert(error);
		   return false;
		 }
         else
			{
			 if(x.min1.value=="")
				{
				 x.min.value="0";
				}
			 else
			    {
                 x.min.value=x.min1.value;
				}
			 if(x.max1.value=="")
				{
                 //alert("max is 0");
				 x.max.value="0";
				}
			 else
				{
			     x.max.value=x.max1.value;
				}

				//alert(document.NavForm.query.value);
				
			return true;

            }

}
function omniSet()
{
			var xmlHttp;
  try
  {    // Firefox, Opera 8.0+, Safari    
				xmlHttp=new XMLHttpRequest();
		}
  catch (e)
  {    // Internet Explorer    
				try
    {
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
				}
    catch (e)
    {
						try
      {
								xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
						}
      catch (e)
      {   
								alert("Your browser does not support AJAX!");    
								return false;  
						}
				} 
		} 
		  xmlHttp.open("GET","/b2c_futurebazaar/b2c/omniSearch.jsp?sid="+Math.random(),true);
    xmlHttp.send(null);
}

function resetForm()
{
  document.getElementById("errors1").innerHTML="";

  document.NavForm.reset();

}

function emptyTxtBox(id)
{
	if(document.getElementById(id).value == "Search"){
		document.getElementById(id).value="";
	}
}
function fillIt(id)
{
	if(document.getElementById(id).value == ""){
		document.getElementById(id).value = "Search";
	}
}

function dataTransfer(){
	document.getElementById("search").value = document.getElementById("search1").value;
	if(validate()){
		document.NavForm.submit();
	}else{
	}


}

function doBlink() {
	var blink = document.all.tags("BLINK")
	for (var i=0; i<blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
}

function startBlink() {
	if (document.all)
		setInterval("doBlink()",750)
}
window.onload = startBlink;


function popup(page)
{
var url
url = "http://images.futurebazaar.com/catalog/fb_images/"+page+".htm";
popuppage  = window.open(url,'','toolbar=no,location=middle,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=600,height=600');
popuppage.focus();
}

function bulkOrderPopup()
{
	bulkOrderWin = window.open('/b2c_futurebazaar/b2c/bulkorderform.jsp','',
	'toolbar=no,location=middle,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=450,height=550');
	bulkOrderWin.focus();
}


function expandCollapse() {
for (var i=0; i<expandCollapse.arguments.length; i++) {
var element = document.getElementById(expandCollapse.arguments[i]);
element.style.display = (element.style.display == "none") ? "block" : "none";
}
}

function emptyTxtBox_email()
{
	if(document.getElementById("email").value == "Enter E-mail Id")
	{
		document.getElementById("email").value="";
	}
}

function fillIt_email()
{
	if(document.getElementById("email").value == "")
	{
		document.getElementById("email").value="Enter E-mail Id";
	}
}

function emailid_validation(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var special_symbol = /[\<\>\:\;\/\"\'\%\=\[\]]+/;

	//alert("ppp"+str.substring(lat,lstr)+"ppp");

	if (special_symbol.test(str)){
		alert("Invalid E-mail ID")
		return false;
	}

	if (str.substring(lat,lstr) == "@futurebazaar.com"){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true
}


//to trim string functions
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,"");};

function ajax_email()
{
	var email;
	email = document.getElementById("email").value;
	document.getElementById("email").value = "Enter E-mail Id";
	var xmlHttp;

	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	//alert("testing"+ email);
	//alert("<isa:webappsURL name='/b2c/ajax_email.jsp'/>?email="+ email);

	xmlHttp.onreadystatechange=function()
	{
	  if(xmlHttp.readyState == 4)
		{

			var resvalue = xmlHttp.responseText;
			resvalue = resvalue.trim();

			window.open("/b2c_futurebazaar/b2c/home_email.jsp?resvalue="+resvalue+"&email="+email, "", 'width=400, height=300, scrollbars=no,menubar=no,status=no,toolbar=no,top=250,left=250');
		}
	}
	xmlHttp.open("GET","/b2c_futurebazaar/b2c/ajax_email.jsp?email="+ email,true);
	//document.getElementById("email").focus();
	//document.getElementById("email").value = "Enter your Email add ";
	xmlHttp.send(null);
	//document.getElementById("email").focus();
}

function ValidateForm(){

	//alert("in");
	var error = false;
	var emailID = document.getElementById("email").value;

	if ((emailID==null)||(emailID=="")){
		document.getElementById("ajaxemail").innerHTML="<font color='red'>Please Enter your E-mail ID</font>";
		document.getElementById("email").focus()
		//return false
		error = true
	}

	if (emailid_validation(emailID)==false){
		emailID=""
		document.getElementById("ajaxemail").innerHTML="<font color='red'>Invalid E-mail ID</font>";
		document.getElementById("email").focus()
		//return false
		error = true
	}

	//alert("not yet saved");
	if(error == false)
		ajax_email()
	else
		document.getElementById("ajaxemail").innerHTML="";

	//alert("saved");
	//document.getElementById("email").focus();

	//return true
 }
 
 function pcworldpop()
{
	pcworldwin = window.open('http://images.futurebazaar.com/catalog/FB_Images/pcworld.htm','','toolbar=no,location=middle,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=600,height=600');
	pcworldwin.focus();
}