
menu_pc_gaming_computer      = new Image(200,135)
menu_pc_gaming_computer.src  = "http://www.blueaurapc.com/webimages/aura/menu_pc_gaming_computer.png"
menu_pc_gaming_computers     = new Image(200,135)
menu_pc_gaming_computers.src = "http://www.blueaurapc.com/webimages/aura/menu_pc_gaming_computers.png"

menu_pc_trading_computer      = new Image(230,135)
menu_pc_trading_computer.src  = "http://www.blueaurapc.com/webimages/aura/menu_pc_trading_computer.png"
menu_pc_trading_computers     = new Image(230,135)
menu_pc_trading_computers.src = "http://www.blueaurapc.com/webimages/aura/menu_pc_trading_computers.png"

menu_pc_multimedia_computer      = new Image(220,135)
menu_pc_multimedia_computer.src  = "http://www.blueaurapc.com/webimages/aura/menu_pc_multimedia_computer.png"
menu_pc_multimedia_computers     = new Image(220,135)
menu_pc_multimedia_computers.src = "http://www.blueaurapc.com/webimages/aura/menu_pc_multimedia_computers.png"

menu_left1          = new Image(200,28)
menu_left1.src      = "http://www.blueaurapc.com/webimages/aura/menu_left1.png"
menu_left1_over     = new Image(200,28)
menu_left1_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left1_over.png"

menu_left2          = new Image(200,28)
menu_left2.src      = "http://www.blueaurapc.com/webimages/aura/menu_left2.png"
menu_left2_over     = new Image(200,28)
menu_left2_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left2_over.png"

menu_left3          = new Image(200,28)
menu_left3.src      = "http://www.blueaurapc.com/webimages/aura/menu_left3.png"
menu_left3_over     = new Image(200,28)
menu_left3_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left3_over.png"

menu_left4          = new Image(200,28)
menu_left4.src      = "http://www.blueaurapc.com/webimages/aura/menu_left4.png"
menu_left4_over     = new Image(200,28)
menu_left4_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left4_over.png"

menu_left5          = new Image(200,28)
menu_left5.src      = "http://www.blueaurapc.com/webimages/aura/menu_left5.png"
menu_left5_over     = new Image(200,28)
menu_left5_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left5_over.png"

menu_left6          = new Image(200,28)
menu_left6.src      = "http://www.blueaurapc.com/webimages/aura/menu_left6.png"
menu_left6_over     = new Image(200,28)
menu_left6_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left6_over.png"

menu_left7          = new Image(200,28)
menu_left7.src      = "http://www.blueaurapc.com/webimages/aura/menu_left7.png"
menu_left7_over     = new Image(200,28)
menu_left7_over.src = "http://www.blueaurapc.com/webimages/aura/menu_left7_over.png"

menu1a= new Image(190,28)
menu1a.src = "http://www.blueaurapc.com/webimages/menu/menu1a.png"
menu1b = new Image(190,28)
menu1b.src = "http://www.blueaurapc.com/webimages/menu/menu1b.png"

menu2a= new Image(190,28)
menu2a.src = "http://www.blueaurapc.com/webimages/menu/menu2a.png"
menu2b = new Image(190,28)
menu2b.src = "http://www.blueaurapc.com/webimages/menu/menu2b.png"

menu3a= new Image(190,28)
menu3a.src = "http://www.blueaurapc.com/webimages/menu/menu3a.png"
menu3b = new Image(190,28)
menu3b.src = "http://www.blueaurapc.com/webimages/menu/menu3b.png"

menu4a= new Image(190,28)
menu4a.src = "http://www.blueaurapc.com/webimages/menu/menu4a.png"
menu4b = new Image(190,28)
menu4b.src = "http://www.blueaurapc.com/webimages/menu/menu4b.png"

menu5a= new Image(190,28)
menu5a.src = "http://www.blueaurapc.com/webimages/menu/menu5a.png"
menu5b = new Image(190,28)
menu5b.src = "http://www.blueaurapc.com/webimages/menu/menu5b.png"

menu6a= new Image(190,28)
menu6a.src = "http://www.blueaurapc.com/webimages/menu/menu6a.png"
menu6b = new Image(190,28)
menu6b.src = "http://www.blueaurapc.com/webimages/menu/menu6b.png"

menu7a= new Image(190,28)
menu7a.src = "http://www.blueaurapc.com/webimages/menu/menu7a.png"
menu7b = new Image(190,28)
menu7b.src = "http://www.blueaurapc.com/webimages/menu/menu7b.png"

var winpar = "scrollbars,location,resizable,status,menubar,toolbar";

function SubmitTextForm( form_name )
{
document.edit_form_01.submit();
  //document.getElementById( form_name ).submit();
}


function limitText(limitField, limitCount, limitNum)
{
   if( limitField.value.length > limitNum )
   {
      limitField.value = limitField.value.substring(0, limitNum);
   }
   else
   {
      document.getElementById( limitCount ).innerHTML = limitNum - limitField.value.length;
   }
}


function DisplayMyAccount(which, elem_name)
{  
   var i = 0;
   
   do
   {
      productElement = document.getElementById(elem_name + i);

      if( productElement != null )
         document.getElementById(elem_name + i).style.display = (0) ? 'block' : 'none';
         
      i++;
      
   }while( productElement != null )
   
   document.getElementById(elem_name + which).style.display = (1) ? 'block' : 'none';
}


function DisplayAccount(which)
{
   var i = 1;
   
 /*  do
   {
      productElement = document.getElementById('account_' + i);

      if( productElement != null )
         document.getElementById('account_' + i).style.display = (0) ? 'block' : 'none';
         
      i++;
      
   }while( productElement != null )
*/   
   if( which != 0 )
      document.getElementById('account_' + which).style.display = (1) ? 'block' : 'none';
}

function DisplayParts(which)
{
   if( document.getElementById(which).style.display == 'none' )
   {
      document.getElementById(which).style.display = 'block';
   }
   else if( document.getElementById(which).style.display == 'block' )
   {
      document.getElementById(which).style.display = 'none';
   }
}

function DisplayDriver(which)
{  
   var split_it = which.split( "_" );
   var save_it;
   
   if( document.getElementById(which).style.display == 'none' )
   {
      save_it = 1;
   }
   else if( document.getElementById(which).style.display == 'block' )
   {
      save_it = 0;
   }
   
   var i = 1;
   
   do
   {
      productElement = document.getElementById(split_it[0] + '_' + i);

      if( productElement != null )
         document.getElementById(split_it[0] + '_' + i).style.display = (0) ? 'block' : 'none';
         
      i++;
      
   }while( productElement != null )

   if( save_it == 1 )
   {
      document.getElementById(which).style.display = (1) ? 'block' : 'none';
   }
   else if( save_it == 0 )
   {
      document.getElementById(which).style.display = (1) ? 'none' : 'block';
   }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used on checkout.php page to do the spinning 'waiting' animation
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function DisplayCheckout(which)
{  
   if( which == 'Checkout_Google' )
   {  
      //document.getElementById('Checkout_Google_Animation').style.display = (1) ? 'block' : 'none';
      //document.getElementById('Checkout_Google_Button').style.display = (1) ? 'none' : 'block';
   }
   else
   {
   
   }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used on the System Customization Pages to display each part table (click on it & it drops down)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function DisplayPart(which)
{  
   //var save_it; 
   //var i = 1;
   //var flag_it = 0;
   
   //do
   //{
   //   productElement = document.getElementById('part_'+i);

   //   if( productElement != null )
   //   {
   //      if( document.getElementById('part_'+i).style.display == 'block' )
   //      {
   //         flag_it++;
   //      }
   //   }
        
   //   i++;
      
   //}while( productElement != null && flag_it < 2 )
   

   if( document.getElementById(which).style.display == 'none' )
   {
      document.getElementById(which).style.display = (1) ? 'block' : 'none';
      //save_it = 1;
   }
   else if( document.getElementById(which).style.display == 'block' )
   {
      document.getElementById(which).style.display = (1) ? 'none' : 'block';
      //save_it = 0;
   }

   //if( flag_it < 2 )
   //{
   //   i = 1;
   
   //   do
   //   {
   //      productElement = document.getElementById('part_'+i);

   //      if( (productElement != null) && ('part_'+i != which) )
   //         document.getElementById('part_'+i).style.display = (0) ? 'block' : 'none';
         
   //      i++;
      
   //   }while( productElement != null )
   //}

   //if( save_it == 1 )
   //{
   //   document.getElementById(which).style.display = (1) ? 'block' : 'none';
   //}
   //else if( save_it == 0 )
   //{
   //   document.getElementById(which).style.display = (1) ? 'none' : 'block';
   //}
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used on the System Customization Pages to display each part table (click on it & it drops down)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function DisplayAllParts()
{  
   var i = 1;
   
   do
   {
      productElement = document.getElementById('part_'+i);

      if( productElement != null )
         document.getElementById('part_'+i).style.display = (1) ? 'block' : 'none';
         
      i++;
      
   }while( productElement != null )
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Bring the shopping cart up in a new window
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function CallView()
{
   cartwin = window.open ("http://www.blueaurapc.com/viewcart.php", "local29", winpar);
   //cartwin.focus ();
}

function submit_form(frm)
{
   if(event.key==13)
   {
      document.getElementById(frm).submit();
   }
}


function resetForms()
{
  var i;
  
  for (i=0; i < document.forms.length; i++)
  {
    document.forms[i].reset();
  }
}


function InitializeForm(obj1, category, showIt, whichone, whichchecked)
{
   if( showIt != 2 )
      doit(category, showIt, whichone, whichchecked);

   UpdateTotal(obj1);

   var i, obj, component_price, temp, section, section_prev, radio, price, string_price, flag_sub, subract_price;
   var checked_prices = new Array();
   var name_section_radio = new Array();

   section = '';
   section_prev = '';
   
   var t1 = 1;

   for (i=0; i<obj1.length; i++)            // Get all checked prices into an array
   {
      obj = obj1.elements[i];
      
      if (obj.type == "radio")
      {
         temp = obj.id;
         name_section_radio = temp.split("_");
         section = name_section_radio[1];
         
         if( section != section_prev )
            t1 = 1;
 
         section_prev = section;
         radio = name_section_radio[2];

         if(obj.checked)
         {   
            if( name_section_radio.length <= 3 )  // Just a regular radio button in the main section
            {
               var grp = document.getElementById((temp + "_" + t1));

               if( grp == null )
               {
                  checked_prices[section] = GetPlusValue(obj.value);
               }
            }
            else  //There is a 4th variable in name_section_radio[] - this means this radio button is part of a drop down section
            {
               checked_prices[section] = GetPlusValue(obj.value);
               
               if( t1 == parseInt(name_section_radio[3]) )
                  t1++;               
            }

         }
      }   
   }


   for (i=0; i<obj1.length; i++)            // run whole form
   {
      obj = obj1.elements[i];               // ref particular element
    
      if (obj.type == "radio")              // radio buttons
      {
         temp = obj.id;
         name_section_radio = temp.split("_");
         section = name_section_radio[1];  
         radio = name_section_radio[2];

         if( name_section_radio.length > 3 )
            radio = radio + '_' + name_section_radio[3];   
         
         subtract_price = checked_prices[section];         

         component_price = GetPlusValue(obj.value);

         if (obj.checked)        
         {
            document.getElementById("Span_" + section + "_" + radio).innerHTML = "[Selected]";         
         }
         else
         {
            price = component_price - subtract_price;

            if(price < 0)
               string_price = "[-] $";
            else
               string_price = "[+] $";

            string_price = string_price + Math.abs(price);

            document.getElementById("Span_" + section + "_" + radio).innerHTML = string_price;
         }
      }
   }
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Updates prices & stuff
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function UpdatePartText(whichpart, thetext)
{
   document.getElementById( "Span_Part_" + whichpart ).innerHTML = thetext;
}











function newWindow(theURL)
{
   picWin = window.open(theURL,'','menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=no,width=722,height=423,top=150,left=150');      picWin.focus();
}



function swapIt(which_png, which_image) 
{
   if(document.images)
      document[which_image].src = 'http://www.blueaurapc.com/form_data/'+which_png;
}


function echeck(str)
{
   var at="@"
   var dot="."
   var lat=str.indexOf(at)
   var lstr=str.length
   var ldot=str.indexOf(dot)
		
   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					
}

function ValidateCreateAccount(thisform)
{
   var emailID=document.register.email_address
	
   if ((emailID.value==null)||(emailID.value=="")){
      alert("Please Enter your Email ID")
	  emailID.focus()
      return false
   }
	
   if (echeck(emailID.value)==false){
      emailID.value=""
	  emailID.focus()
	  return false;
   }
	
   //thisform.form.submit();
}


function ValidateLoginAccount()
{
   var emailID=document.login.login_username
	
   if ((emailID.value==null)||(emailID.value=="")){
      alert("Email Address Invalid")
	  emailID.focus()
      return false
   }
	
   if (echeck(emailID.value)==false){
      emailID.value=""
	  emailID.focus()
	  return false
   }
	
   return true
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//stopRKey()
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function stopRKey(evt)
{ 
   var evt = (evt) ? evt : ((event) ? event : null); 
   var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
   
   if ((evt.keyCode == 13) && (node.type=="text"))
   {
      return false;
   } 
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Updates prices & stuff
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function Update(obj1, price, category, showIt, whichone, whichchecked)
{
/*
   if( showIt != 2 )
      doit(category, showIt, whichone, whichchecked);
*/

   UpdateTotal(obj1);

  
//XION II Main
//
//id= "Button_systemcase_07"
//name= "systemcase"
//<span id="Span_systemcase_07">

//Black (Drop down #1)
//
//id= "Button_systemcase_07_1"
//name= "systemcase_1"
//<span id="Span_systemcase_07_1">

//Silver (Drop down #2)
//
//id= "Button_systemcase_08_1"
//name= "systemcase_1"
//<span id="Span_systemcase_08_1">

//Span_systemcase_07_1
//Span_systemcase_08_1
//Span_systemcase_09_1
//Span_systemcase_10_1

   var section, radio, radio_drop, price, check;
   var drop_down = 1;
   var name_section_radio = new Array();
   
   var i = 0;
   var cat_length = document.systemform[category].length;

   while( i < cat_length )
   {
      if( document.systemform[category][i].type == "radio" )
      {
         check = document.systemform[category][i].value;
         temp = document.systemform[category][i].id;
         name_section_radio = temp.split("_");
         section = name_section_radio[1];
         radio = name_section_radio[2];
         
         component_price = GetPlusValue(document.systemform[category][i].value);      

         if( document.systemform[category][i].checked )
         {
            document.getElementById( "Span_"+section+"_"+radio ).innerHTML = "[Selected]";
         }
         else
         {
            component_price = component_price - price;
            
            if( component_price < 0 )
               string_price = "[-] $" + Math.abs(component_price);
            else
               string_price = "[+] $" + Math.abs(component_price);  

            document.getElementById( "Span_"+section+"_"+radio ).innerHTML = string_price;
         }
      }
      
      i++;
   }
}

function UpdateTotal(obj1)   // Keeps the Display_Total variable current
{
   var i,j,k,obj,temp,val,tok, Shipping_Total, Display_Total, name_temp;
   var ary = new Array();

   temp_obj = document.getElementsByName("base_price");
   Display_Total = parseInt(temp_obj[0].value);

   var i = 0;
   var obj_length = obj1.length;

   while( i < obj_length )
   {
      obj = obj1.elements[i];          
    
      if (obj.type == "radio" || obj.type == "checkbox")
      {
         if (obj.checked)              
         {
            temp = obj.value;
            ary = temp.split(" ");

            if( ary[0] != "##" )
            {
               for(j=0; j<ary.length; j++)
               { 
                  if (ary[j].length < 2) continue;
               
                  tok = ary[j].charAt(0);
                  val = "";
                  k = 1;
                       
                  while( k < ary[j].length )
                  {
                     val += ary[j].charAt(k);
                     k++;
                  }
                  
                  //tok = ary[j].substring (0,1);   // first character + token
                  //val = ary[j].substring (1);     // Get part upgrade cost $$$

                  if(tok == "+")
                  {
                     Display_Total = Display_Total + parseFloat(val);
                     break;
                  }
               }
            }         
         }      
      }
      
      i++;
   }

   document.getElementById("total_cost").innerHTML = "$" + Display_Total;
} 

function GetPlusValue(val)
{
   var j, k, value, tok, ary;

   ary = val.split(" ");

   for(j=0; j<ary.length; j++)
   { 
      if (ary[j].length < 2) continue;
      
      //tok = ary[j].charAt(0);
      //tok = ary[j][0];
      tok = ary[j].substring (0,1);   // first character + token

      if(tok == "+")
      {
         //k = 1;
         //value = "";
         
         //while( k < ary[j].length )
         //{
            //value += ary[j][k];
         //   value += ary[j].charAt(k);
         //   k++;
         //}
         
         value = ary[j].substring (1);     // Get part upgrade cost $$$
         value = parseInt(value);
         return value;
      }
   }       
}


function doit(category, showIt, whichone, whichchecked)
{
   max = 2;
   zeroIt = 0;
   i = 1;

   var productElement = document.getElementById(category + '_display_box1');

   while( productElement != null )
   {
      document.getElementById(category + '_display_box' + i).style.display = (zeroIt) ? 'block' : 'none';
      i++;
      productElement = document.getElementById(category + "_display_box"+i);
   }
   
   
   if( (showIt == 0) || (showIt == 1) )
   {  
      rad_btn = 0;
      drop_sect = 1;

      outerloop:
         while( 1 )
         {
            productElement = document.getElementsByName(category+'_'+drop_sect);

            if( productElement.length == 0 )
               break outerloop;

            if( rad_btn < 10 )
               productElement = document.getElementById('Button_' + category + '_0' + rad_btn + '_' + drop_sect);
            else
               productElement = document.getElementById('Button_' + category + '_' + rad_btn + '_' + drop_sect);

            if( productElement != null )  //If the productElement is real
            {
               innerloop:
                  while(1)
                  {
                     if( productElement.checked )
                     {
                        productElement.checked = 0;
                        break outerloop;    
                     }
                     else
                     {
                        rad_btn++;
                 
                        if( rad_btn < 10 )
                           productElement = document.getElementById('Button_' + category + '_0' + rad_btn + '_' + drop_sect);
                        else
                           productElement = document.getElementById('Button_' + category + '_' + rad_btn + '_' + drop_sect);

                        if( productElement == null )
                           break innerloop;
                     }  
                  }

               drop_sect++;
            }
            else
               rad_btn++;
         }//End while loop

      if(showIt == 1)
      {
         document.getElementById('Button_' + whichchecked).checked = 1;
         document.getElementById(category + '_display_box' + whichone).style.display = (showIt) ? 'block' : 'none';
      }
   }
}
