// NOTE: some functions appear both here and on the main server !

function activateDropMenu() {
    	
      
      if (document.all&&document.getElementById) {
    		navRoot = document.getElementById("nav");
    		for (i=0; i<navRoot.childNodes.length; i++) {
    		
    			node = navRoot.childNodes[i];
    			if (node.nodeName=="LI") {

            node.onmouseover=function() {
    					this.className+=" over";
    				}
    				node.onmouseout=function() {
    					this.className=this.className.replace(" over", "");
    				}
    			}
    		}
    	}
    }
    


function date_today() {
//returns date format
    var X;
    with (new Date()) {
        X = String((getFullYear() * 100 + getMonth() + 1) * 100 + getDate());
    }
    return X;
}



function js_bypass(){
  // allows override with 'onclick's...
}




function get_base_path( baseType ){

 // for php/dynamic (default):  

 var base_path="";
        if (location.href.match('yes3'))
        { base_path = "http://yes3.home.jungo.com/root/home/yanive/site/www/";  }
        if( !base_path )
        base_path = "http://www.jungo.com/openrg/";
  return base_path;
}


function get_scripts_path(){
    var base_path = "";
    
    if (location.href.match('yes3'))
	base_path = "http://yes3.home.jungo.com/root/home/yanive/site/www/openrg/scripts/";
    if(!base_path )
        base_path = "http://www.jungo.com/openrg/scripts/";

  return base_path;

}   


function submit_form( form_name ){

  //alert(' submitting '+ form_name );
  document.getElementById(form_name).submit();
  
}




function check_opt_out_email(){

  var error='';
  
  
  error += checkEmail( document.opt_out_form.email_field );
  
  
  if( error!='' )  
  {
    // errors notice:
    $('form-edit-comments').innerHTML = 'Email address invalid. Please check again...';
    $('form-edit-comments').show();
    new Effect.Highlight('form-edit-comments');
    return false;
  }  
  
  else
  {
    // wait notice:
    $('form-edit-comments').innerHTML = "<div class='ajax-box'><img src='../../images/ajax_load.gif' border='0'></div> " +
                                     "Please wait while processing information...";
    $('form-edit-comments').show();
    
    document.opt_out_form.submit();
    
    return true;
  
  }

}



function google_track_as( virtual_page ){


    urchinTracker( virtual_page );

}




function update_checkbox_selection( form_name, result_field, checkboxes_arr ){
    
     
     var form_handler = document[ ''+form_name+'' ];
     var checkboxes_count = form_handler[ ''+checkboxes_arr+''].length;
     
     var final_result = '';
     
     
     for (i=0; i < checkboxes_count; i++)
     {
        //console.log( 'i: '+i+' value: '+ checkboxes_arr[i].value );
        
        if( form_handler[ ''+checkboxes_arr+''][i].checked == true )
         final_result = final_result + form_handler[''+checkboxes_arr+''][i].value + ', ';
     }
     
    
    $( result_field ).value = final_result;
    

}



function redirect_to_download( product_name, custom_tag ){
  
  var download_path =  get_base_path() + "scripts/download.php?product=" + product_name;
  
  if( custom_tag )  
    download_path += "&tag=" + custom_tag;
  else
    download_path += "&tag=" + location.pathname;  // default tag is referring page
  
  location.href = download_path;                               
                              

}




function redirect_to_contact( contact_subject, custom_tag ){

  var contact_path =  get_base_path() + "scripts/contact_form.php?subject=" + contact_subject;
  
  if( custom_tag )  
    contact_path += "&tag=" + custom_tag;
  else
    contact_path += "&tag=" + location.pathname;  // default tag is referring page 
    
  
  
  location.href = contact_path;                               
  

}


function redirect_to_st_store( product_id ){

  var store_path =  get_base_path() + "scripts/store/index.php";
  
  if( product_id ) store_path += "?pid=" + product_id; 
  
  location.href = store_path;
  
}




