/*----------------- Rich Text Box -----------------*/
 
 // set_rich_text()
 // This function initializes the Richtextbox component
 function set_rich_text()
 {
     document.getElementById('hdnrte1').value =document.getElementById('hid_rich').value;
     enableDesignMode('rte1', document.getElementById('hdnrte1').value, false);
 }
  
 // get_rich_text()
 // This function stores the rich text box value in a hidden field for later use
 function get_rich_text()
 {
     updateRTE('rte1');
     document.getElementById('hid_rich').value=document.getElementById('hdnrte1').value;
 }
 
 
 /*----------------- Featured Products -----------------*/
 
 // product_checked()
 // This functions ensures no more than one product is checked to be the featured product
 function product_checked(var_control)
 {
     // Declare Variables
     var productId = var_control.value;
     var state = document.getElementById('hidden_productId').value * 1;
     var state1 = document.getElementById('hidden_productId1').value * 1;
     document.getElementById('error_project').style.visibility = "hidden"; 
     document.getElementById('error_project').innerHTML = "You cannot select more than Two Products!";  
     var id = 0;
     var tableHolder = document.getElementById('products_table');
     var inputHolder = tableHolder.getElementsByTagName('input');
     var len = inputHolder.length;
     for (count = 0 ; count < len ; count = count + 2)
     {
         if( inputHolder[count].id == var_control.id)
             id = inputHolder[count + 1].value * 1;
     }
     // if there's no featured products selected
     if ((var_control.checked && state == 0) )
     {
         state = productId;
         document.getElementById('hidden_productId').value = id;
     }
     else if ((var_control.checked && state1 == 0) )
     {
         state = productId;
         document.getElementById('hidden_productId1').value = id;
     }
     else if (!var_control.checked && state == id )
     {
         document.getElementById('hidden_productId').value = 0;
     }
     else if (!var_control.checked && state1 == id )
     {
         document.getElementById('hidden_productId1').value = 0;
     }
     else
     {
         var_control.checked = false;
         document.getElementById('error_project').style.visibility = "visible"; 
     }
     
 }
 
 // products_save()
 // This function ensures that there's a featured product selected
 function products_save()
 {
     var state = document.getElementById('hidden_productId').value * 1;
     var state1 = document.getElementById('hidden_productId1').value * 1;
     if ( state == 0 && state1 == 0)
     {
         document.getElementById('error_div').innerHTML = "Please select a Product first.";   
         document.getElementById('error_div').style.visibility = "visible"; 
         return false;
     }
 }
 
 // products_load()
 // This function determines if there's a featured product selected
 function products_load()
 {
     var tableHolder = document.getElementById('products_table');
     var inputHolder = tableHolder.getElementsByTagName('input'); 
     var inputHolderLength = inputHolder.length;
     for (count = 0 ; count < inputHolderLength  ; count = count + 2)
     {
         if (inputHolder[count].type == 'checkbox')
         {
             if (inputHolder[count].checked)
             {
                 if ( document.getElementById('hidden_productId').value * 1 == 0 )
                     document.getElementById('hidden_productId').value = inputHolder[count + 1].value * 1;
                 else
                 {
                     document.getElementById('hidden_productId1').value = inputHolder[count + 1].value * 1;
                 }    
             }
         }
     }
 }
 
 /*----------------- Featured Projects -----------------*/
 
 // project_checked()
 // This functions ensures no more than one project is checked to be the featured project
 function project_checked (var_control)
 {
     // Declare Variables
     var projectId = var_control.value;
     var state = document.getElementById('hidden_projectId').value * 1;
     
     
     document.getElementById('error_project').style.visibility = "hidden"; 
         document.getElementById('error_project').innerHTML = "You cannot select more than ONE Project!";  
     // if there's no featured projects selected
     if (var_control.checked && state == 0)
     {
         state = projectId;
         document.getElementById('hidden_projectId').value = state;
     }
     else if (! var_control.checked)
     {
         document.getElementById('hidden_projectId').value = 0;
     }
     else
     {
         var_control.checked = false;
         document.getElementById('error_project').style.visibility = "visible"; 
     }
 }
 
 // projects_save()
 // This function ensures that there's a featured project selected
 function projects_save()
 { 
     var state = document.getElementById('hidden_projectId').value * 1;
     if ( state == 0)
     {
         document.getElementById('error_div').innerHTML = "Please select a project first.";   
         document.getElementById('error_div').style.visibility = "visible"; 
         return false;
     }
     return true;
 }
 
 // projects_load()
 // This function determines if there's a featured project selected
 function projects_load()
 {
     var tableHolder = document.getElementById('projects_table');
     var inputHolder = tableHolder.getElementsByTagName('input'); 
     var inputHolderLength = inputHolder.length;
     for (count = 0 ; count < inputHolderLength  ; count = count + 2)
     {
         if (inputHolder[count].type == 'checkbox')
         {
             if ( inputHolder[count].checked)
             {
                 document.getElementById('hidden_projectId').value = inputHolder[count + 1].value * 1;
                 return true;
             }
         }
     }
 }
 
 // project_validation()
 //
 function project_validation()
 {
     var ulvar = document.getElementById('vsproject');
     var title = document.getElementById('txtprojectTitle');
     var description  = document.getElementById('hid_rich');
     var validationString = "";
     if (title.value == "")
         validationString = validationString + "<li>Specify a Project Title Please.</li>" ;
     if (description.value == "")
         validationString = validationString + "<li>Specify a Project Description Please.</li>" ;
     if (validationString == "")
         return true ;
     else
     {
         ulvar.innerHTML = validationString;
         return false;
     }    
     return false;
 }
 
 
 
 /*---------------- Products Page ------------------*/
 
 // product_validation()
 //
 function product_validation()
 {
     var img = document.getElementById('hidupload');
     var ulvar = document.getElementById('vsproduct');
     var title = document.getElementById('txtproductTitle');
     var description  = document.getElementById('hid_rich');
     var validationString = "";
     if (title.value == "")
         validationString = validationString + "<li>Specify a Product Title Please.</li>" ;
     if (description.value == "")
         validationString = validationString + "<li>Specify a Product Description Please.</li>" ;
     if (img.value == "no")
         validationString = validationString + "<li>Attach a Product Image Please.</li>" ;
     if (validationString == "")
         return true ;
     else
     {
         ulvar.innerHTML = validationString;
         return false;
     }    
     return false;
 }
 
 // product_load()
 //
 function product_load()
 {
     var inner_title = document.getElementById('prod_div');
     var divHolder = inner_title.getElementsByTagName('a');
     if ( divHolder.length == 0)
         document.getElementById('prod_div').style.height="278px";
 
 }
 
 
 /*---------------- Partners Page ------------------*/
 
 // partner_validation()
 //
 function partner_validation()
 {
     var img = document.getElementById('hidupload');
         var ulvar = document.getElementById('vspartner');
         var url = document.getElementById('txtURL');
         var title = document.getElementById('txtPartnerTitle');
         var description  = document.getElementById('hid_rich');
         var validationString = "";
         if (title.value == "")
             validationString = validationString + "<li>Specify Partner Name Please.</li>" ;
         if (url.value == "")
             validationString = validationString + "<li>Specify Partner URL Please.</li>" ;
         if (description.value == "")
             validationString = validationString + "<li>Specify Partner Description Please.</li>" ;
         if (img.value == "no")
             validationString = validationString + "<li>Attach Partner Logo Please.</li>" ;
         if (validationString == "")
             return true ;
         else
         {
             ulvar.innerHTML = validationString;
             return false;
         }    
         return false;
 }
 
 
 
 // client_validation()
 //
 function client_validation()
 {
         var img = document.getElementById('hidupload');
         var ulvar = document.getElementById('vsclient');
         var title = document.getElementById('txtclientTitle');
         var description  = document.getElementById('txtURL');
         var validationString = "";
         if (title.value == "")
             validationString = validationString + "<li>Specify Client Name Please.</li>" ;
         if (description.value == "")
             validationString = validationString + "<li>Specify Client URL Please.</li>" ;
         if (img.value == "no")
             validationString = validationString + "<li>Attach Client Logo Please.</li>" ;
         if (validationString == "")
             return true ;
         else
         {
             ulvar.innerHTML = validationString;
             return false;
         }    
         return false;
 }
 
 /*----------------- Home Page -----------------*/
 
 // textfield_clear()
 //
 function textfield_clear(var_control)
 {
     if ( var_control.id == "aCompanyName" )
     {
         if (document.getElementById('txtCompanyName').value == " your company name")
             document.getElementById('txtCompanyName').value = "";
     }
     else
     {
         if (document.getElementById('txtEmailAddress').value == " your e-mail")
             document.getElementById('txtEmailAddress').value = "";
     }
 }
 
 
 // home_load()
 //
 function home_load()
 {
     var mainDivHolder = document.getElementById('home_products');
     var divHolder = mainDivHolder.getElementsByTagName('div');
     var length = divHolder.length;
     if (length == 0)
     {    document.getElementById('Image1').src = "../images/no_img.gif";
         document.getElementById('temp_div').style.display = "block";
     }
     else if ( length > 8)
     {
         document.getElementById('temp_div').style.display = "none";
         document.getElementById('image2_div').style.border= "solid 1px";
         document.getElementById('Image2').style.display = "block";
         document.getElementById('image3_div').style.display = "block";
     }    
         
 }
 
 /*----------------- Sitemap Page -----------------*/
 
 // sitemap_load()
 //
 function sitemap_load()
 {
     document.getElementById('services_sub_ul').style.display = "none";
     document.getElementById('products_sub_ul').style.display = "none";
     document.getElementById('about_sub_ul').style.display = "none";
     document.getElementById('contact_sub_ul').style.display = "none";
     document.getElementById('strategy_sub_ul').style.display = "none";
     document.getElementById('business_sub_ul').style.display = "none";
     document.getElementById('offer_sub_ul').style.display = "none";
     document.getElementById('training_sub_ul').style.display = "none";
     document.getElementById('services_li').style.backgroundImage = "url('images/arrow_down.gif')"; 
     document.getElementById('services_li').style.backgroundImage = "url('images/arrow_right.gif')"; 
     document.getElementById('services_sub_ul').style.background = "transparent url('images/arrow1_down.gif') 11px 9px no-repeat"; 
     document.getElementById('services_sub_ul').style.background = "transparent url('images/arrow1_right.gif') 11px 9px no-repeat"; 
 }
 
 
 // expand_collapse()
 //
 function expand_collapse(ul_id,li_id,s)
 {
         var sub_ul = document.getElementById(ul_id);
         if ( sub_ul.style.display == 'none')
         {    
             sub_ul.style.display = "block";
             document.getElementById(li_id).style.backgroundImage = "url('images/arrow" + s + "_down.gif')";
         }    
         else
         {
             sub_ul.style.display = "none";
             document.getElementById(li_id).style.backgroundImage = "url('images/arrow" + s + "_right.gif')";  
         }
 }
 
 
 
 
 
 /*----------------- News Page & Careers Page-----------------*/
 
 // news_load()
 // This function modifies the news_div style according to its content
 function news_load(id)
 {
     //    var oRows = document.getElementById('MyTable').getElementsByTagName('tr');
     //    var iRowCount = oRows.length;
     var innerhtm = document.getElementById('news_div').innerHTML;
     var index = innerhtm.split("<div");
     if (index.length == 1)
         index = innerhtm.split("<DIV");
     if (index.length < 8)
     {
         document.getElementById('profile_main').style.height = "330px";
     }
     // check if the calling page is careers page
     if ( id == 2)
     {
     
         var news_div = document.getElementById('profile_main');
         var divHolder = news_div.getElementsByTagName('div');
         var len = divHolder.length;
         if (len <  6  )
             document.getElementById('error_career').style.display="block";
         else
             document.getElementById('error_career').style.display = "none";
     }
 }
 
 
 
 /*----------------- Project Page -----------------*/
 
 // project_load()
 // This function modifies the news_div style according to its content
 function project_load(id)
 {
     var innerhtm = document.getElementById('profile_main').innerHTML;
     var index = innerhtm.split("<div");
     if (index.length == 1)
         index = innerhtm.split("<DIV");
     if (index.length < 7)
     {
         document.getElementById('profile_main').style.height = "294px";
         document.getElementById('service_right').style.marginTop = "131px";
     }
     if ( id == 2)
     {
         var profile_main = document.getElementById('profile_main');
         var divHolder = profile_main.getElementsByTagName('div');
         var len = divHolder.length;
         if (len < 5)
             document.getElementById('error_client').style.display="block";
         else
             document.getElementById('error_client').style.display = "none";
     }
 }
 
 
 function new_user_load()
 {
     if ((document.getElementById('hid_rich').value * 1) == 0)
     {
         document.getElementById('txtUsername1').value = "";
         document.getElementById('txtPassword1').value = "";
      }
 }
 
 
  /*---------------- Upload File ---------------- */
  function delete_file()
  {
     document.getElementById('imgupload1').visible = false;
     document.getElementById('lblupload1').visible = false;
     document.getElementById('lbDelete1').visible = false;
     document.getElementById('lblupload1').value = "";
     document.getElementById('file_uploaded').value = 0;
  }
  
  
  /*---------------- Newsletters Page ----------------*/
 // newsletter_load
 //
 function newsletter_load()
 {
     var inner_title = document.getElementById('news_div');
     var divHolder = inner_title.getElementsByTagName('input');
     if ( divHolder.length < 18)
         document.getElementById('news_div').style.height="281px";
     if ( divHolder.length > 16)
         document.getElementById('news_div').style.paddingBottom="30px";
 }
 
 //newsletters_validation
 //
function newsletters_validation()
{
    if(document.getElementById('file_ipload1').value == "")
    {
        document.getElementById('error_div2').style.visibility = "visible" ;
        return false;
    }
    return true;    
}
